-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Update blazor templates with Microsoft.Identity.Web APIs #24268
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
Update blazor templates with Microsoft.Identity.Web APIs #24268
Conversation
I feel a little uneasy with these templates changes since it looks like they were based off of 3.1 blazor templates. There were some minor changes between 3.1 and 5.0 it seems so we'll need to test the functionality a little more thoroughly. |
...tes/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/.template.config/dotnetcli.host.json
Outdated
Show resolved
Hide resolved
...Templates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/.template.config/template.json
Outdated
Show resolved
Hide resolved
...Templates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/.template.config/template.json
Outdated
Show resolved
Hide resolved
...mplates/content/ComponentsWebAssembly-CSharp/Server/Controllers/WeatherForecastController.cs
Show resolved
Hide resolved
...ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Startup.cs
Show resolved
Hide resolved
...ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Startup.cs
Outdated
Show resolved
Hide resolved
@JunTaoLuo : in src\ProjectTemplates\Web.ProjectTemplates\content\WebApi-CSharp\Startup.cs, we need to replace
|
Also before we can merge this fix, we'll also need to update to 0.2.1-preview. |
|
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/CallWebApi.razor
Outdated
Show resolved
Hide resolved
...ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/ShowProfile.razor
Show resolved
Hide resolved
...ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Startup.cs
Outdated
Show resolved
Hide resolved
...ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Startup.cs
Outdated
Show resolved
Hide resolved
When were the 5.0 one added? I took these last week? |
...ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/ShowProfile.razor
Outdated
Show resolved
Hide resolved
...ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/ShowProfile.razor
Outdated
Show resolved
Hide resolved
....ProjectTemplates/content/BlazorServerWeb-CSharp/Services/MicrosoftGraphServiceExtensions.cs
Show resolved
Hide resolved
@jmprieur @jennyf19 the 5.0 templates are what's in this repo: https://github.com/dotnet/aspnetcore/tree/master/src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp. But I've already highlighted the differences I saw between 3.1 and 5.0 templates via comments and resovled the known differences I found. As long as we test the functionality of the template changes, I think we're okay.
Yea I couldn't figure out what the correct syntax was. If I had Also can you respond to #24268 (comment) and #24268 (comment) when you have the chance? |
75cbf5a
to
da83f7c
Compare
@JunTaoLuo did you update your IdentityWebTemplates repository? (and which branch) so that I can test more? |
A few updates: I was able to run the BlazorServer-SingleOrg-Api template and was able to sign in: However I didn't see instructions for BlazorServer-SingleOrg-Graph or BlazorServer-IndividualB2C-Api at https://microsofteur-my.sharepoint.com/:w:/r/personal/jmprieur_microsoft_com/_layouts/15/guestaccess.aspx?e=4%3AeYZCMo&at=9&share=ETED-1idfGBOjNo_L8aatSwBNE1mZE9ju9sap6K5r_wzcQ so I didn't verify those scenarios. As for the BlazorWasm templates. apart from one bug I found, I figured out that the templates generated are conditional on whether it's called on the command line or VS. I fiddled with the logic and generated what I assume are the templates we would want to test but I'm still running into the |
FYI I updated the templates at https://github.com/JunTaoLuo/IdentityWebTemplates. |
services.AddMicrosoftWebApiAuthentication(Configuration, "AzureAd") | ||
#if (GenerateApiOrGraph) | ||
.AddMicrosoftWebApiCallsWebApi(Configuration, | ||
"AzureAd") | ||
.AddInMemoryTokenCaches(); | ||
|
||
#else | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to put services.AddMicrosoftWebApiAuthentication(Configuration, "AzureAd")
inside the if and use services.AddMicrosoftWebApiAuthentication(Configuration, "AzureAd");
on the else.
Otherwise you generate
services.AddMicrosoftWebApiAuthentication(Configuration, "AzureAd")
;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what you are saying. There are two #if, which one are you referring to. Also, I think the idea is to have just
services.AddMicrosoftWebApiAuthentication(Configuration, "AzureAd")
;
if OrganizationAuth is configured but no API or Graph is configured? This is what's being done in the other templates. Is that wrong? cc @jmprieur
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's impossible for me to determine the correctness of all these templates/combinations.
I'm signing-off based on the idea that the changes look reasonable (without taking into account the feedback provided offline) and that you have done due diligence verifying the scenarios manually.
Feel free to merge once all tests are passing and you are confident that the different combinations work, and we'll address any bug if needed post preview8.
Thanks for all your hard work to get this into preview8! It's much appreciated!
@JunTaoLuo : I've updated https://microsofteur-my.sharepoint.com/:w:/r/personal/jmprieur_microsoft_com/_layouts/15/guestaccess.aspx?e=4%3AeYZCMo&at=9&share=ETED-1idfGBOjNo_L8aatSwBNE1mZE9ju9sap6K5r_wzcQ for BlazorServer-SingleOrg-Graph The ComponentsWebAssembly-CSharp template is missing changes in 3 files: In
|
@jmprieur it turns out that to test the BlazorWasm templates, you'll need to install the preview 7 SDK: https://dotnet.microsoft.com/download/dotnet/5.0. I was able to run the server project with it installed. Also the 5.0.0-dev package versions should be changed to 5.0.0-preview.7.20365.19. |
Hello human! Please make sure you've included the Shiproom Template in a comment or (preferably) the PR description. Also, make sure this PR is not marked as a draft and is ready-to-merge. |
Description
Merging template changes from https://github.com/AzureAD/microsoft-identity-web/tree/master/ProjectTemplates/templates.
We are updating our Blazor Server and Blazor WASM templates to use Microsoft.Identity.Web APIs. The work presented here is similar to #24167 which updated our Mvc, RazorPages and Web API templates.
Customer Impact
Current Blazor Server and Blazor WASM templates use obsoleted v1 AAD APIs. This change replaces their use in blazor templates with APIs from Microsoft.Identity.Web.
Regression?
No
Risk (see taxonomy)
Low. These are changes to templates only. The generated templates are verified manually (for functionality) and via unit tests (to ensure generated templates restores and builds).
Link the PR to the original issue and/or the PR to master.
Tracking issue: #22726