Skip to content

Commit

Permalink
feature: split identity (#5)
Browse files Browse the repository at this point in the history
* scafolded structure for identity

* added common Directory.Build.props

* infrastructure for identity (wip)

* api fro identity (wip)

* solution compiles again, failing tests (wip)

* all tests passing again

* added common.props

* deployed latest client

* fixed wrong sample configuration on readme.md

* updated notes.txt

* removed GrantType Password

* updated notes.txt

* removed bower and gulpfile files

* removed MVC controllers and respective files

* fixed usings to tests compile again

* removed publish task

* added working page based server ui

* correct logout now also working

* deployed frontend client

* removed unused asset folder

* updated notes.txt

* updated to latest nuget packages

* edited notes.txt

* typos and installed todo parser extension in devcontainer.json

* updated to latest nuget packages

* introduces suite projects

* updated readme

* build.sh adjusted

* updated to latest ng version

* redone migrations
  • Loading branch information
thomasduft committed Aug 18, 2021
1 parent b6d426e commit 1801649
Show file tree
Hide file tree
Showing 708 changed files with 5,638 additions and 142,262 deletions.
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"formulahendry.dotnet-test-explorer",
"minhthai.vscode-todo-parser",
"ms-dotnettools.csharp",
"ryanluker.vscode-coverage-gutters",
"formulahendry.dotnet-test-explorer"
"ryanluker.vscode-coverage-gutters"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-server",
"program": "${workspaceFolder}/samples/Server/bin/Debug/net5.0/Mvc.Server.dll",
"program": "${workspaceFolder}/samples/Server/bin/Debug/net5.0/Server.dll",
"args": [],
"cwd": "${workspaceFolder}/samples/Server",
"stopAtEntry": false,
Expand Down
12 changes: 10 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
{
"dotnet-test-explorer.testProjectPath": "tests",
"editor.tabSize": 2,
"editor.rulers": [
100
],
"dotnet-test-explorer.testProjectPath": "tests",
"omnisharp.enableRoslynAnalyzers": true
"omnisharp.enableRoslynAnalyzers": true,
"TodoParser": {
"include": ["cs, cshtml, ts"],
"folderExclude": ["node_modules", ".vscode", ".devcontainer", ".github"],
"only": ["samples", "src", "tests"],
"showInProblems": false,
"markers": ["NOTE:", "REMINDER:", "TODO:", ["FIXME", "Warning"]],
"autoDefaultMarkers": true
}
}
16 changes: 2 additions & 14 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "process",
"args": [
"build",
"${workspaceFolder}/samples/Server/Mvc.Server.csproj",
"${workspaceFolder}/samples/Server/Server.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand All @@ -25,26 +25,14 @@
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/samples/Server/Mvc.Server.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"${workspaceFolder}/samples/Server/Mvc.Server.csproj",
"${workspaceFolder}/samples/Server/Server.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
Expand Down
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ As a goodie the samples demonstrates this features by an Angular SPA client that

Assuming you downloaded the sources and opened [VS Code](https://code.visualstudio.com/) in the root repo directory you should be good to go! Ahh and of course you need [.NET Core](https://dotnet.microsoft.com/download) and [node.js](https://nodejs.org/en/) installed on your development environment.

### Running the Server
### Running the sample Server

1. Open the integrated terminal in VS Code and type

```bash
Expand All @@ -29,6 +30,14 @@ That ensures you are able to build the dotnet related stuff!

2. Go to the VS Code Debug tab (Ctrl+Shift+D) and run the Server project.

### Develop the sample Client (Angular based frontend)

1. Make sure you installed [Node.js](https://nodejs.org/en/).

> If you develop in a [devcontainer](https://code.visualstudio.com/docs/remote/containers) then you are already good to go!
2. First run the backend (see previous chapter)

3. After the Server is running navigate within your favorite command line to the `Client` directory and type:

```bash
Expand Down Expand Up @@ -57,7 +66,7 @@ You should see now the login screen. You can now login with the pre-configured a

## Using it

Follow the original setup of the OpenIddict in the `Startup.ConfigureServices(...)` - method and add the two additional extension hooks `AddUIStore(...)` and `AddUIApis<TIdentityUser>(...)` and you should be good to go.
Follow the original setup of the OpenIddict in the `Startup.ConfigureServices(...)` - method and add your required additional extension hooks `AddUIStore(...)`, `AddUIApis(...)`, `AddUIIdentityStore(...)` and `AddUIIdentityApis<TIdentityUser>()`.

```csharp
...
Expand Down Expand Up @@ -89,7 +98,7 @@ services.AddOpenIddict()
.Name));
})
// Register the API for the EF and ASP.NET Identity based UI Store
.AddUIApis<ApplicationUser>(options =>
.AddUIApis(options =>
{
// Tell the system about the allowed Permissions it is built/configured for.
options.Permissions = new List<string>
Expand All @@ -106,7 +115,20 @@ services.AddOpenIddict()
Permissions.Scopes.Roles,
Permissions.Prefixes.Scope + "demo_api"
}
});
})
// Register the EF based OpenIddict Identity Store
.AddUIIdentityStore(options =>
{
options.OpenIddictUIIdentityContext = builder =>
builder.UseSqlite(Configuration.GetConnectionString("DefaultConnection"),
sql => sql.MigrationsAssembly(typeof(Startup)
.GetTypeInfo()
.Assembly
.GetName()
.Name));
})
// Register the Api for the EF based OpenIddict Identity Store
.AddUIIdentityApis<ApplicationUser>();

...
```
Expand Down
26 changes: 19 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if [ -z "$1" ];
then
echo No version specified! Please specify a valid version like 1.2.3!
echo No version specified! Please specify a valid version like 1.2.3 or 1.2.3-rc1!
exit 1
fi

Expand All @@ -27,14 +27,26 @@ echo ----
if [ $2 = "r" ];
then
echo Packaging solution with Version = $1
dotnet pack src/OpenIddict.UI.Core -c Release -p:PackageVersion=$1 -p:Version=$1 -o ./dist/nupkgs/
dotnet pack src/OpenIddict.UI.Infrastructure -c Release -p:PackageVersion=$1 -p:Version=$1 -o ./dist/nupkgs/
dotnet pack src/OpenIddict.UI.Api -c Release -p:PackageVersion=$1 -p:Version=$1 -o ./dist/nupkgs/
dotnet pack src/suite/OpenIddict.UI.Suite.Core -c Release -p:PackageVersion=$1 -p:Version=$1 -o ./dist/nupkgs/
dotnet pack src/suite/OpenIddict.UI.Suite.Api -c Release -p:PackageVersion=$1 -p:Version=$1 -o ./dist/nupkgs/

dotnet pack src/openiddict/OpenIddict.UI.Infrastructure -c Release -p:PackageVersion=$1 -p:Version=$1 -o ./dist/nupkgs/
dotnet pack src/openiddict/OpenIddict.UI.Api -c Release -p:PackageVersion=$1 -p:Version=$1 -o ./dist/nupkgs/

dotnet pack src/identity/OpenIddict.UI.Identity.Core -c Release -p:PackageVersion=$1 -p:Version=$1 -o ./dist/nupkgs/
dotnet pack src/identity/OpenIddict.UI.Identity.Infrastructure -c Release -p:PackageVersion=$1 -p:Version=$1 -o ./dist/nupkgs/
dotnet pack src/identity/OpenIddict.UI.Identity.Api -c Release -p:PackageVersion=$1 -p:Version=$1 -o ./dist/nupkgs/
else
echo Packaging solution with PackageVersion = $1
dotnet pack src/OpenIddict.UI.Core -c Release -p:PackageVersion=$1 -o ./dist/nupkgs/
dotnet pack src/OpenIddict.UI.Infrastructure -c Release -p:PackageVersion=$1 -o ./dist/nupkgs/
dotnet pack src/OpenIddict.UI.Api -c Release -p:PackageVersion=$1 -o ./dist/nupkgs/
dotnet pack src/suite/OpenIddict.UI.Suite.Core -c Release -p:PackageVersion=$1 -o ./dist/nupkgs/
dotnet pack src/suite/OpenIddict.UI.Suite.Api -c Release -p:PackageVersion=$1 -o ./dist/nupkgs/

dotnet pack src/openiddict/OpenIddict.UI.Infrastructure -c Release -p:PackageVersion=$1 -o ./dist/nupkgs/
dotnet pack src/openiddict/OpenIddict.UI.Api -c Release -p:PackageVersion=$1 -o ./dist/nupkgs/

dotnet pack src/identity/OpenIddict.UI.Identity.Core -c Release -p:PackageVersion=$1 -o ./dist/nupkgs/
dotnet pack src/identity/OpenIddict.UI.Identity.Infrastructure -c Release -p:PackageVersion=$1 -o ./dist/nupkgs/
dotnet pack src/identity/OpenIddict.UI.Identity.Api -c Release -p:PackageVersion=$1 -o ./dist/nupkgs/
fi

if [ -z "$3" ];
Expand Down
35 changes: 30 additions & 5 deletions notes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
TODO:

- add RequireConsent-property for application detail

- structuring
- suite (openiddict-ui-suite)
- Core
- Infrastructure
- Infrastructure.EF
- Infrastructure.EF.Sqlite
- Api (WebApplication)
- identity (openiddict-ui-identity)
- Core
- Infrastructure.EF
- API
- openiddict (openiddict-ui)
- Core
- Infrastructure.EF
- Api
- policy (openiddict-ui-policy)
- Core
- Infrastructure.EF
- API
- PolicyClient


- load options.Permissions from database instead of configuring it


- better Client deployment
- introduce deploy.js
- check server stylings not removed
Expand All @@ -22,11 +50,6 @@ TODO:

- ??? authorizations, tokens

----------------------------------------------------------------------------------------------------
DEV Containers:
- https://hub.docker.com/_/microsoft-vscode-devcontainers
- https://github.com/microsoft/vscode-dev-containers/tree/master/containers/dotnet


----------------------------------------------------------------------------------------------------
EF:
Expand All @@ -36,12 +59,14 @@ EF:

- dotnet ef migrations add Initial -c ApplicationDbContext -o Models/Data
- dotnet ef migrations add InitialUI -c OpenIddictUIContext -o Models/Data/UI
- dotnet ef migrations add InitialIdentity -c OpenIddictUIIdentityContext -o Models/Data/Identity

----------------------------------------------------------------------------------------------------
Tests:
dotnet test /p:ParallelizeTestCollections=false /p:CollectCoverage=true /p:Include=[tomware.*]tomware.OpenIddict.UI.* /p:CoverletOutputFormat=lcov /p:CoverletOutput=./../lcov

----------------------------------------------------------------------------------------------------
Tips:
- dotnet tool install --global dotnet-ef
- dotnet tool install --global dotnet-outdated-tool
export PATH="$PATH:/home/vscode/.dotnet/tools"
Loading

0 comments on commit 1801649

Please sign in to comment.