Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: split identity #5

Merged
merged 30 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a968e38
scafolded structure for identity
thomasduft Jun 23, 2021
3e26b1e
added common Directory.Build.props
thomasduft Jun 23, 2021
9768203
infrastructure for identity (wip)
thomasduft Jun 23, 2021
46c3c5d
api fro identity (wip)
thomasduft Jun 30, 2021
5a4234d
solution compiles again, failing tests (wip)
thomasduft Jun 30, 2021
be9e26a
all tests passing again
thomasduft Jun 30, 2021
2200f8a
added common.props
thomasduft Jun 30, 2021
178ec4d
deployed latest client
thomasduft Jun 30, 2021
3f83103
fixed wrong sample configuration on readme.md
thomasduft Jun 30, 2021
03b92da
updated notes.txt
thomasduft Jun 30, 2021
697524f
removed GrantType Password
thomasduft Jun 30, 2021
9790a19
updated notes.txt
thomasduft Jun 30, 2021
8c7b767
removed bower and gulpfile files
thomasduft Jul 6, 2021
faf39c4
removed MVC controllers and respective files
thomasduft Jul 6, 2021
18b362d
fixed usings to tests compile again
thomasduft Jul 6, 2021
9e4b918
removed publish task
thomasduft Jul 6, 2021
4ce6c59
added working page based server ui
thomasduft Jul 7, 2021
7b0f51c
correct logout now also working
thomasduft Jul 7, 2021
ba49032
deployed frontend client
thomasduft Jul 7, 2021
b124fb8
removed unused asset folder
thomasduft Jul 7, 2021
1982fe3
updated notes.txt
thomasduft Jul 7, 2021
917aa2b
updated to latest nuget packages
thomasduft Jul 30, 2021
7c98683
edited notes.txt
thomasduft Jul 30, 2021
f08eec8
typos and installed todo parser extension in devcontainer.json
thomasduft Aug 4, 2021
297f638
updated to latest nuget packages
thomasduft Aug 13, 2021
6bd2ed4
introduces suite projects
thomasduft Aug 18, 2021
4562f38
updated readme
thomasduft Aug 18, 2021
57594ee
build.sh adjusted
thomasduft Aug 18, 2021
841d69e
updated to latest ng version
thomasduft Aug 18, 2021
2934d5a
redone migrations
thomasduft Aug 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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