Skip to content
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

SPA authentication and authorization doc #31010

Merged
merged 7 commits into from
Nov 14, 2023
Merged

Conversation

tdykstra
Copy link
Contributor

@tdykstra tdykstra commented Nov 13, 2023

Fixes #30066
Fixes #29363

The diff is not useful, the .NET 8 content is in effect a new doc.

Use this internal review link for the new .NET 8 content.


Internal previews

📄 File 🔗 Preview link
aspnetcore/security/authentication/identity-api-authorization.md Authentication and authorization for SPAs

draft

draft

draft

draft

draft

draft

draft
Copy link
Member

@JeremyLikness JeremyLikness left a comment

Choose a reason for hiding this comment

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

Few changes. @tdykstra I will also have a sample for tokens with comments right after lunch so we can complete that section.

Copy link
Collaborator

@guardrex guardrex left a comment

Choose a reason for hiding this comment

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

Passing recommendation to go with AppUser. I thought there was a time that we were trying to drop "My"-named things, but that just might be my imagination😄.

@tdykstra
Copy link
Contributor Author

@guardrex I'm following the pattern in the simplified code supplied by Jeremy that uses IdentityUser directly.

@tdykstra tdykstra changed the title WIP: SPA authentication and authorization doc SPA authentication and authorization doc Nov 14, 2023
@tdykstra tdykstra marked this pull request as ready for review November 14, 2023 00:09
Comment on lines -408 to +239
AddApiAuthorization<ApplicationUser, ApplicationDbContext>(options =>
{
options.Clients.AddSPA(
"My SPA", spa =>
spa.WithRedirectUri("http://www.example.com/authentication/login-callback")
.WithLogoutRedirectUri(
"http://www.example.com/authentication/logout-callback"));

options.ApiResources.AddApiResource("MyExternalApi", resource =>
resource.WithScopes("a", "b", "c"));
});
```
## See also

## Additional resources
For more information, see the following resources:
Copy link
Contributor

Choose a reason for hiding this comment

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

## Additional resources is shorter.

Copy link
Member

@JeremyLikness JeremyLikness left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@tdykstra tdykstra merged commit aa39ea9 into dotnet:main Nov 14, 2023
2 checks passed
@tdykstra tdykstra deleted the spaauthnet8 branch November 14, 2023 02:45
@guardrex
Copy link
Collaborator

guardrex commented Nov 14, 2023

@tdykstra ... Very good. I currently left it the original way that @JeremyLikness had it for the Blazor sample (but with AppUser), but I think that's a good approach to go with IdentityUser. I'll make a long-range tracking note to update that sample+article, but @JeremyLikness can let me know if switching over to IdentityUser for that sample app isn't the best choice for some reason. I won't get to that for a little while. I'll probably be swamped with higher priority work all the way to the ⛄ EOY holidays.

@JeremyLikness
Copy link
Member

Using IdentityUser is preferred unless we're showing how to customize the user.

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.

.NET 8: Support for tokens in lieu of cookies for Identity sign on .NET 8: MapIdentityApi<TUser>()
4 participants