Skip to content

Commit 75a5716

Browse files
committed
Update sign in sample to not use hybrid flow (implicit id token)
1 parent a9dd76a commit 75a5716

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

1-WebApp-OIDC/1-1-MyOrg/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ As a first step you'll need to:
9696
- In the Redirect URIs section, select **Web** in the combo-box and enter the following redirect URIs.
9797
- `https://localhost:44321/`
9898
- `https://localhost:44321/signin-oidc`
99-
- In the **Advanced settings** section set **Logout URL** to `https://localhost:44321/signout-oidc`
100-
- In the **Advanced settings** | **Implicit grant** section, check **ID tokens** as this sample requires
101-
the [ID Token](https://docs.microsoft.com/azure/active-directory/develop/id-tokens) to be enabled to
102-
sign-in the user.
99+
- In the **Advanced settings** section set **Logout URL** to `https://localhost:44321/signout-oidc`
103100
<details open=true>
104101
<summary>Expand/collapse screenshot</summary>
105102
@@ -109,7 +106,12 @@ As a first step you'll need to:
109106
110107
1. Select **Save**.
111108
112-
> Note that unless the Web App calls a Web API, no certificate or secret is needed.
109+
1. In the app's registration screen, select the **Certificates & secrets** blade in the left to open the page where we can generate secrets and upload certificates.
110+
1. In the **Client secrets** section, select **New client secret** and add a new secret
111+
112+
> [!NOTE]
113+
> Secrets are weak credentials. In production, use a federated credential if you are hosted on Azure, or a certificate otherwise. See https://aka.ms/idweb/client-credentials
114+
113115
114116
### Step 2: Download/ Clone this sample code or build the application using a template
115117
@@ -132,7 +134,8 @@ cd "1-WebApp-OIDC\1-1-MyOrg"
132134
- replace the `ClientID` value with the *Application ID* from the application you registered in Application Registration portal on *Step 1*.
133135
- replace the `TenantId` value with the *Tenant ID* where you registered your Application on *Step 1*.
134136
- replace the `Domain` value with the *Microsoft Entra domain name*, e.g. contoso.onmicrosoft.com where you registered your Application on *Step 1*.
135-
137+
- replace the `ClientSecret` value with the *client secret* you created in the previous step.
138+
136139
#### Option 2: Create the sample from the command line
137140

138141
1. Run the following command to create a sample from the command line using the `SingleOrg` template:

1-WebApp-OIDC/1-1-MyOrg/Startup.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ public void ConfigureServices(IServiceCollection services)
3333
options.HandleSameSiteCookieCompatibility();
3434
});
3535

36-
// Sign-in users with the Microsoft identity platform
3736
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
38-
.AddMicrosoftIdentityWebApp(options => Configuration.Bind("AzureAd", options));
37+
.AddMicrosoftIdentityWebApp(options => Configuration.Bind("AzureAd", options))
38+
.EnableTokenAcquisitionToCallDownstreamApi() // This is needed to exchange the authorization code for an ID Token
39+
.AddInMemoryTokenCaches();
3940

4041
services.AddControllersWithViews(options =>
4142
{

1-WebApp-OIDC/1-1-MyOrg/appsettings.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
"TenantId": "[Enter 'common', or 'organizations' or the Tenant Id (Obtained from the Azure portal. Select 'Endpoints' from the 'App registrations' blade and use the GUID in any of the URLs), e.g. da41245a5-11b3-996c-00a8-4d99re19f292]",
66
"ClientId": "[Enter the Client Id (Application ID obtained from the Azure portal), e.g. ba74781c2-53c2-442a-97c2-3d60re42f403]",
77
"CallbackPath": "/signin-oidc",
8-
"SignedOutCallbackPath": "/signout-callback-oidc"
8+
"SignedOutCallbackPath": "/signout-callback-oidc",
9+
"ClientCredentials": [
10+
{
11+
"SourceType": "ClientSecret", // Secrets are weak credentials. Use certificates or federated credentials instead. See https://aka.ms/idweb/client-credentials
12+
"ClientSecret": "[Enter you secret here]"
13+
}
14+
]
915
},
1016
"Logging": {
1117
"LogLevel": {

0 commit comments

Comments
 (0)