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

Missing Controller

Open karayakar opened this issue 3 years ago • 3 comments

active-directory-aspnetcore-webapp-openidconnect-v2/1-WebApp-OIDC/1-5-B2C/Controllers/

Project missing Account controller. <li class="navbar-btn"> <form method="get" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="EditProfile"> <button type="submit" class="btn btn-primary" style="margin-right:5px">Edit Profile</button> </form> </li> <li class="navbar-btn"> <form method="get" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut"> <button type="submit" class="btn btn-primary">Sign Out</button> </form> </li>

karayakar avatar Aug 25 '21 10:08 karayakar

@karayakar what problem are you seeing? what are your repro steps? the account controller is in Microsoft.Identity.Web.UI: https://github.com/AzureAD/microsoft-identity-web/blob/master/src/Microsoft.Identity.Web.UI/Areas/MicrosoftIdentity/Controllers/AccountController.cs

jmprieur avatar Aug 25 '21 15:08 jmprieur

I cannot repro this, @karayakar Please provide repro steps

jmprieur avatar Oct 05 '21 02:10 jmprieur

Thank you @jmprieur and @dzielin. The issue is in my AD which I didn't setup AD B2C. I have ended up using MSAL to solve issue using AzureAD. Thank you.

` var tokenProvider = new MsalTokenProvider(new MsalTokenProviderOptions { ScopePlaceholderMappings = new Dictionary<string, string> { { OpsArcResearch.Common.Constants.Placeholders.WebApiAppIdUri, Configuration["App:WebApi:AppIdUri"] } }, CallbackPath = Configuration["AzureAd:CallbackPath"] ?? string.Empty, ClientId = Configuration["AzureAd:ClientId"], ClientSecret = Configuration["AzureAd:ClientSecret"], TenantId = Configuration["AzureAd:TenantId"] }); services.AddSingleton<MsalTokenProvider>(tokenProvider);

        // Don't map any standard OpenID Connect claims to Microsoft-specific claims.
        // See https://leastprivilege.com/2017/11/15/missing-claims-in-the-asp-net-core-2-openid-connect-handler/.
        JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

        // Add Azure AD authentication using OpenID Connect.
        services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
            .AddAzureAD(options => Configuration.Bind("AzureAd", options));
        services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
        {
            options.ClaimActions.Clear();
            options.Authority += "/v2.0";
            options.TokenValidationParameters.ValidAudiences = new[]
               {
                    Configuration["AzureAd:ClientId"], $"api://{Configuration["AzureAd:ClientId"]}",

                };

            options.TokenValidationParameters.ValidIssuers = new[]
            {
                $"https://sts.windows.net/{Configuration["AzureAd:TenantId"]}/",
                $"https://login.microsoftonline.com/{Configuration["AzureAd:TenantId"]}/v2.0",`

...................

karayakar avatar Oct 07 '21 09:10 karayakar