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

the "/logout" handler in the document does nothing. #33599

Open
BigSquareHasNoEdge opened this issue Sep 12, 2024 · 0 comments
Open

the "/logout" handler in the document does nothing. #33599

BigSquareHasNoEdge opened this issue Sep 12, 2024 · 0 comments

Comments

@BigSquareHasNoEdge
Copy link

Description

Hello.

I have followed the example codes and found the "/logout" does nothing.

api.MapGet("/secret", 
    (ClaimsPrincipal user) =>
        Results.Text($"{user.Identity?.Name ?? "unknown user"}, I am your father.")
    )
    .RequireIdentityTokenAuthorization();  // policy based Auth

// ...

api.MapPost("/logout",
    async ([FromBody]object empty, SignInManager<ApplicationUser> signInManager) => 
    {
        if(empty is not null)
        {
            await signInManager.SignOutAsync();
            return Results.Ok();
        }

        return Results.BadRequest();
    })
    .RequireIdentityTokenAuthorization(); // policy base auth.

after POST to logout, GET secret with the access token still worked, while I didn't expected it would.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity-api-authorization?view=aspnetcore-8.0#use-the-post-refresh-endpoint

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/security/authentication/identity-api-authorization.md

Document ID

137d4b94-7b26-3911-b22d-42c754a95fc1

Article author

@tdykstra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants