Skip to content

timoyan/id4-demo-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

id4-demo-sample

Prerequisite

Create solution and project

dotnet new sln -n id4-netcore-sample
dotnet new web -n id4-server -o ./src/id4-server -lang C# --type project
dotnet sln id4-demo-sample.sln add ./src/id4-server/id4-server.csproj

Install package

dotnet add src/id4-server/id4-server.csproj package IdentityServer4 -v 3.0.1
dotnet add src/id4-server/id4-server.csproj package Serilog -v 2.8.0
dotnet add src/id4-server/id4-server.csproj package Serilog.AspNetCore -v 3.0.0
dotnet add src/id4-server/id4-server.csproj package Serilog.Sinks.Console -v 3.1.1
dotnet add src/id4-server/id4-server.csproj package Serilog.Sinks.File -v 4.0.0

Container SQL Server settings

  • Get docker image SQL server
docker pull mcr.microsoft.com/mssql/server
  • Run container with SQL server image
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<YourStrong@Passw0rd>"\
    -p 1433:1433 --name sql1
    -d mcr.microsoft.com/mssql/server:latest
  • Enter container
docker exec -it sql1 "bash"
  • Login SQL server
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "<YourStrong@Passw0rd>"
  • Azure Data Studio for mac

https://docs.microsoft.com/en-us/sql/azure-data-studio/download?view=sql-server-ver15

  • Generated DB Script
dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb
dotnet ef migrations add InitialIdentityServerConfigurationDbMigration -c ConfigurationDbContext -o Data/Migrations/IdentityServer/ConfigurationDb

Create api project

dotnet new webapi -n api -o ./src/api -lang C# --type project
dotnet sln id4-demo-sample.sln add ./src/api/api.csproj

Access https://localhost:5004/WeatherForecast to validate service status.

Create client project

dotnet new console -n console-client -o ./src/console-client -lang C# --type project
dotnet sln id4-demo-sample.sln add ./src/console-client/console-client.csproj

Create resource owner project

dotnet new console -n console-resource-owner -o ./src/console-resource-owner -lang C# --type project
dotnet sln id4-demo-sample.sln add ./src/console-resource-owner/console-resource-owner.csproj

Update EF

dotnet ef migrations add identity -c ApplicationDbContext -o Data/Migrations/IdentityServer/IdentityDb
dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb
dotnet ef migrations add InitialIdentityServerConfigurationDbMigration -c ConfigurationDbContext -o Data/Migrations/IdentityServer/ConfigurationDb

dotnet ef database update identity -c ApplicationDbContext
dotnet ef database update InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext
dotnet ef database update InitialIdentityServerConfigurationDbMigration -c ConfigurationDbContext

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages