Asp.Net Core DefaultAuthorizationService runs twice for JWT tokens
I tried to create a AuthenticationScheme
JWT for tokens.
For my controller, I have an attribute [Authorize(Policy=Owner)]
.
This works, but I noticed in my debug log that this is happening:
Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware: Info: Successfully validated token. Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware: Info: AuthenticationScheme: TrustyBearer successfully authenticated. Microsoft.AspNetCore.Authorization.DefaultAuthorizationService: Information: Authorization was successful for user: af078cae-123b-4fa6-aacb-525dc5a4d5cb. Microsoft.AspNetCore.Authorization.DefaultAuthorizationService: Information: Authorization was successful for user: af078cae-123b-4fa6-aacb-525dc5a4d5cb.
It looks like the JWT middleware validates the token and then validates it again by the schema name. Twice or two different things?
But then I get two more identical messages Authorization was successful for user...
.
This happens even if I disable the policy name attribute and just use [Authorize]
.
I checked and I don't think I did something twice.
This is normal?
TIA
source to share
No one has answered this question yet
Check out similar questions: