active-directory-aspnetcore-webapp-openidconnect-v2 icon indicating copy to clipboard operation
active-directory-aspnetcore-webapp-openidconnect-v2 copied to clipboard

App redirects to RedirectURI Without Running Flow

Open jamesW360DotNet opened this issue 3 years ago • 1 comments

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

The issue was found for the following scenario:

Please add an 'x' for the scenario(s) where you found an issue

  1. Web app that signs in users
    1. [ ] with a work and school account in your organization: 1-WebApp-OIDC/1-1-MyOrg
    2. [ ] with any work and school account: /1-WebApp-OIDC/1-2-AnyOrg
    3. [ ] with any work or school account or Microsoft personal account: 1-WebApp-OIDC/1-3-AnyOrgOrPersonal
    4. [ ] with users in National or sovereign clouds 1-WebApp-OIDC/1-4-Sovereign
    5. [ ] with B2C users 1-WebApp-OIDC/1-5-B2C
  2. Web app that calls Microsoft Graph
    1. [ ] Calling graph with the Microsoft Graph SDK: 2-WebApp-graph-user/2-1-Call-MSGraph
    2. [ ] With specific token caches: 2-WebApp-graph-user/2-2-TokenCache
    3. [ ] Calling Microsoft Graph in national clouds: 2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph
  3. [ ] Web app calling several APIs 3-WebApp-multi-APIs
  4. [ ] Web app calling your own Web API
    1. [ ] with a work and school account in your organization: 4-WebApp-your-API/4-1-MyOrg
    2. [ ] with B2C users: 4-WebApp-your-API/4-2-B2C
    3. [ ] with any work and school account: 4-WebApp-your-API/4-3-AnyOrg
  5. Web app restricting users
    1. [ ] by Roles: 5-WebApp-AuthZ/5-1-Roles
    2. [ ] by Groups: 5-WebApp-AuthZ/5-2-Groups
  6. [ ] Deployment to Azure
  7. [x ] Other (please describe)

Repro-ing the issue

Follow the current instructions under "Configure authentication in a sample web app by using Azure AD B2C" including the prerequisites up to and including Step 5, point 3 but without being previously signed in.

Expected behavior I am presented with the user flow, configured in "Set up a sign-up and sign-in flow in Azure Active Directory B2C"

Actual behavior I am redirected to the RedirectURI without having to sign up or sign in and the JWT is empty.

Additional context/ Error codes / Screenshots

I am following the guide here: https://docs.microsoft.com/en-gb/azure/active-directory-b2c/configure-authentication-sample-web-app

I'm brand new to B2C so there is probably something very basic I'm missing.

The following 2 lines from my output window may be useful: Microsoft.AspNetCore.Hosting.Diagnostics: Information: Request starting HTTP/2 GET https://localhost:44316/MicrosoftIdentity/Account/SignIn? - - Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler: Information: OpenIdConnect was not authenticated. Failure message: Not authenticated

jamesW360DotNet avatar Jun 24 '22 08:06 jamesW360DotNet

Im also facing the same issue.

after i changed appsetting.json to my client and instance details, when i click on signup/signin app redirects to localhost without prompting for user credentials.

Any help is appreciated.

mohamedalijinnah avatar Aug 09 '22 09:08 mohamedalijinnah

@jamesW360DotNet @mohamedalijinnah

In your appsettings.json file do you have the following line uncommented?

"CallbackPath": "/signin/B2C_1_sign_up_in"

By default your application will use https://localhost:44316/signin-oidc as the login path for your application.

When you have this line uncommented but your application is configured to use https://localhost:44316/signin-oidc in the portal instead what will happen is your application will be configured to expect a redirect URL of https://localhost:44316/signin/B2C_1_sign_up_in but the server will send a post request to https://localhost:44316/signin-oidc which would trigger the failure you're seeing.

Simplest solution would be to comment that line out in appsettings.json and add https://localhost:44316/signin-oidc as a redirect URI for your application in Azure.

Step 2 in the document referenced.

Let me know if this helps.

v-michaelmi avatar Sep 01 '22 00:09 v-michaelmi

No response. Closing.

Please feel free to re-open if this issue is not resolved.

v-michaelmi avatar Sep 07 '22 17:09 v-michaelmi