Skip to content

Update sign in sample to not use hybrid flow (implicit id token) #817

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

Merged
merged 2 commits into from
Jul 27, 2025

Conversation

bgavrilMS
Copy link
Contributor

Remove implicit id token

@bgavrilMS bgavrilMS requested review from jmprieur and Copilot July 23, 2025 12:52
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the sign-in sample to use the authorization code flow instead of the hybrid flow with implicit ID tokens, following modern OAuth 2.0 security best practices.

  • Removes the requirement for implicit ID token grant in Azure AD app registration
  • Adds client credentials configuration to enable proper token exchange
  • Updates authentication setup to use authorization code flow with token acquisition capabilities

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
appsettings.json Adds ClientCredentials configuration section with client secret setup
Startup.cs Updates authentication to enable token acquisition and adds in-memory token cache
README.md Removes implicit grant instructions and adds client secret setup documentation

services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(options => Configuration.Bind("AzureAd", options));
.AddMicrosoftIdentityWebApp(options => Configuration.Bind("AzureAd", options))
.EnableTokenAcquisitionToCallDownstreamApi() // This is needed to exchange the authorization code for an ID Token
Copy link
Preview

Copilot AI Jul 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is technically inaccurate. EnableTokenAcquisitionToCallDownstreamApi() enables token acquisition for calling downstream APIs, not specifically for exchanging authorization code for ID tokens. The comment should be updated to reflect the actual purpose.

Suggested change
.EnableTokenAcquisitionToCallDownstreamApi() // This is needed to exchange the authorization code for an ID Token
.EnableTokenAcquisitionToCallDownstreamApi() // Enables token acquisition for calling downstream APIs

Copilot uses AI. Check for mistakes.

@bgavrilMS bgavrilMS merged commit eec1856 into master Jul 27, 2025
2 checks passed
@bgavrilMS bgavrilMS deleted the bogavril/remove_implicit branch July 27, 2025 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant