Skip to content

Add the latest recommended passing tokens approach #35482

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 14 commits into from
May 30, 2025

Conversation

@guardrex guardrex self-assigned this May 16, 2025
@guardrex guardrex force-pushed the guardrex/blazor-passing-tokens branch from e1f1442 to d653a02 Compare May 16, 2025 18:39
@guardrex guardrex requested a review from halter73 May 19, 2025 18:01
@guardrex guardrex marked this pull request as ready for review May 19, 2025 18:22
var claimsIdentity = new ClaimsIdentity(context.Principal?.Identity,
[new Claim("AccessToken", accessToken ?? "No Access Token!")]);
context.Principal = new ClaimsPrincipal(claimsIdentity);
context.Properties.Items.Remove("access_token");

This comment was marked as resolved.

This comment was marked as resolved.

if (user is not null)
{
var accessToken =
user.Claims.First(c => c.Type == "AccessToken")?.Value;

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

@guardrex guardrex marked this pull request as draft May 29, 2025 23:53
@guardrex guardrex marked this pull request as ready for review May 30, 2025 19:48
@guardrex
Copy link
Collaborator Author

@halter73 ... This is a good improvement thus far. The latest updates come directly from our discussions. I'd like to go ahead and get this live now, and I'll probably perform some touch-ups to it next week. Then, I hope you'll look at the two main sections that cover this subject in the live articles within the next couple of weeks. I'll send you the live article links.

WRT a CircuitHandler approach, I tried again today and ran into trouble again. I couldn't get it work. I even think that I should check our guidance at ...

https://learn.microsoft.com/en-us/aspnet/core/blazor/security/additional-scenarios?view=aspnetcore-9.0#access-authenticationstateprovider-in-outgoing-request-middleware

... to confirm that it still works as we describe because I tried using a similar approach to that in one of my efforts and it didn't even look like that was working properly. I'll check on it soon.

@guardrex guardrex merged commit 6e0f3bb into main May 30, 2025
3 checks passed
@guardrex guardrex deleted the guardrex/blazor-passing-tokens branch May 30, 2025 19:59
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.

Update section on passing tokens in Blazor Web Apps
2 participants