Update OIDC Azure Sample
1. Add set up instructions. 2. Add user secret tools. 3. Clean up codes.
This commit is contained in:
parent
792b316950
commit
61d03b9316
|
|
@ -1,6 +1,5 @@
|
|||
using System.IO;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace OpenIdConnect.AzureAdSample
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
# How to set up the sample locally
|
||||
|
||||
## Set up [Azure Active Directory](https://azure.microsoft.com/en-us/documentation/services/active-directory/)
|
||||
|
||||
1. Create your own Azure Active Directory (AD). Save the "tenent name".
|
||||
2. Add a new Application: in the Azure AD portal, select Application, and click Add in the drawer.
|
||||
3. Set the sign-on url to `http://localhost:42023`.
|
||||
4. Select the newly created Application, navigate to the Configure tab.
|
||||
5. Find and save the "Client Id"
|
||||
8. In the keys section add a new key. A key value will be generated. Save the value as "Client Secret"
|
||||
|
||||
## Configure the local environment
|
||||
1. Set environment ASPNETCORE_ENVIRONMENT to DEVELOPMENMT. ([Working with Multiple Environments](https://docs.asp.net/en/latest/fundamentals/environments.html))
|
||||
2. Set up user secrets:
|
||||
```
|
||||
dotnet user-secrets set oidc:clientid <Client Id>
|
||||
dotnet user-secrets set oidc:clientsecret <Client Secret>
|
||||
dotnet user-secrets set oidc:authority https://login.windows.net/<Tenent Name>.onmicrosoft.com
|
||||
```
|
||||
|
||||
|
|
@ -7,7 +7,6 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Authentication;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.AspNetCore.Http.Features.Authentication;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
|
@ -88,7 +87,7 @@ namespace OpenIdConnect.AzureAdSample
|
|||
{
|
||||
var request = context.HttpContext.Request;
|
||||
var currentUri = UriHelper.BuildAbsolute(request.Scheme, request.Host, request.PathBase, request.Path);
|
||||
var credential = new ClientCredential(clientId, clientSecret);
|
||||
var credential = new ClientCredential(clientId, clientSecret);
|
||||
var authContext = new AuthenticationContext(authority, AuthPropertiesTokenCache.ForCodeRedemption(context.Properties));
|
||||
|
||||
var result = await authContext.AcquireTokenByAuthorizationCodeAsync(
|
||||
|
|
|
|||
|
|
@ -31,9 +31,10 @@
|
|||
},
|
||||
"userSecretsId": "aspnet5-OpenIdConnectSample-20151210110318",
|
||||
"tools": {
|
||||
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*"
|
||||
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-*",
|
||||
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-*"
|
||||
},
|
||||
"scripts": {
|
||||
"postpublish": "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue