-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/ggercman/AIS.Demo
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Authentication integration example | ||
|
||
This sample shows how to create ASP.Net Core application with authorization integrated with AIS. | ||
Prerequisites - AIS must be running and AIS.Identity application must be configured in appSettings to allow clients. | ||
|
||
## AIS.Identity | ||
appSettings must be configured by adding additional client configuration. ClientSecret is stored as hash value, calculated using formula Base64(SHA56(client_secret)). | ||
ClientId, client_secret will be required in ClientApp. | ||
For example | ||
``` | ||
"Clients2": [ | ||
{ | ||
"Enabled": true, | ||
"ClientId": "Temp", | ||
"ClientName": "Resource Owner Password", | ||
"ClientSecrets": [ { "Value": "u4QNzdMbk/WFriEg5DikXSaP27X7LjId/WS3L0r+scs" } ], | ||
"AllowedGrantTypes": [ "password" ], | ||
"AllowedScopes": [ "api1" ] | ||
}, | ||
{ | ||
"Enabled": true, | ||
"ClientId": "Sample", | ||
"ClientName": "Resource Owner Password", | ||
"ClientSecrets": [ { "Value": "u4QNzdMbk/WFriEg5DikXSaP27X7LjId/WS3L0r+scs" } ], | ||
"AllowedGrantTypes": [ "password" ], | ||
"AllowedScopes": [ "api1" ] | ||
} | ||
] | ||
}, | ||
``` | ||
|
||
## ClientApp | ||
|
||
Console client application, authenticates to AIS.Identity, calls AuthorizedAPI with Authorization: Bearer token. | ||
Before running - change identity to URL in program.cs file | ||
|
||
## AuthorizedAPI | ||
|
||
ASP.Net Core Web application, requires authenticated web requests. | ||
* Update appSettings.json Authority value to actual AIS.Identity server. For example: https://identityserver/identity/ | ||
|
||
Important places: | ||
* **Startup.cs** | ||
``` | ||
// ConfigureServices | ||
// adds bearer authentication and configured JwtBearerOptions from appSettings.json | ||
builder.Services.AddAppAuthentication(builder.Configuration); | ||
//Configure | ||
app.UseAuthentication(); | ||
app.UseAuthorization(); | ||
``` | ||
* **appSettings.json** | ||
``` | ||
"JwtBearer": { | ||
"Authority": "https://localhost:6001", | ||
"TokenValidationParameters": { | ||
"ValidateAudience": false | ||
} | ||
} | ||
``` | ||
|
||
|