Skip to content

Update RazorPages, MVC, WebApi templates to use Identity.Web #24167

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 6 commits into from
Jul 25, 2020

Conversation

JunTaoLuo
Copy link
Contributor

Fixes #24024
Fixes #22726

ported from #24065

fyi @jmprieur

@JunTaoLuo JunTaoLuo requested review from dougbu and a team as code owners July 21, 2020 18:33
@JunTaoLuo JunTaoLuo added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jul 21, 2020
Copy link
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

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

I filed AzureAD/microsoft-identity-web#346 for an AzureAd migration guide, but we'll also need a docs issue for the AspNetCore migration guide that links to theirs.

services.AddTokenAcquisition(true);
services.AddSingleton<GraphServiceClient, GraphServiceClient>(serviceProvider =>
{
var tokenAquisitionService = serviceProvider.GetService<ITokenAcquisition>();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

#24065 (comment) This probably needs to be GetRequiredService if you expect this to not be null.


namespace Company.WebApplication1
{
public interface IDownstreamWebApi
Copy link
Contributor Author

Choose a reason for hiding this comment

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

#24065 (comment) Is there a specific reason why we need an interface here?

@@ -6,3 +6,8 @@
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>
@* #if(GenerateApiOrGraph)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI this doesn't work. The generated templates just has this section verbatim.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried fixing this with 3b093a8. It's working as intended but doesn't seem like the right syntax.

@JunTaoLuo
Copy link
Contributor Author

@jmprieur and @jennyf19 were able to verify that {mvc, webapp, webapi} x {IndividualB2C + API, SingleOrg + Api, SingleOrg + Graph} all works so this is ready to be merged.

}
else
{
apiResult = $"Error calling the API '{apiUrl}'";
Copy link
Member

Choose a reason for hiding this comment

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

Later: Add logging

Comment on lines +76 to +77
.AddMicrosoftWebAppCallsWebApi(Configuration,
"AzureAd")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.AddMicrosoftWebAppCallsWebApi(Configuration,
"AzureAd")
.AddMicrosoftWebAppCallsWebApi(Configuration, "AzureAd")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll address this in the Blazor templates PR, this appears in several places IIRC.

@satishrabari
Copy link

Hi, Would you please help me with the following things?
I am using Microsoft Identity Platform.
I want to redirect to account/logincallback URL after successful login.
Where I put the redirect URL for this?

I want to configure using startup.cs because I want to save user info in DB and add custom claims in the claim principle.
Is it possible?
I don't have a login URL on my web.

following is my Startup.cs
`

        services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
            .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAd"));

        services.AddControllersWithViews(options =>
        {
            var policy = new AuthorizationPolicyBuilder()
                .RequireAuthenticatedUser()
                .Build();
            options.Filters.Add(new AuthorizeFilter(policy));
        });
        services.AddRazorPages()
             .AddMicrosoftIdentityUI();

`

@ghost
Copy link

ghost commented Jul 12, 2021

Hi @satishrabari. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants