Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ggercman/AIS.Demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ggercman committed Dec 2, 2021
2 parents 9b1ea40 + f5a0e34 commit c5c18c6
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions samples/Ais.Extensibility.AuthenticationSamples/readme.md
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
}
}
```


0 comments on commit c5c18c6

Please sign in to comment.