Azure-docs: Missing information for JWT Bearer token validation

Created on 27 May 2020  Â·  8Comments  Â·  Source: MicrosoftDocs/azure-docs

When setting up JWT Bearer token validation, I came across a behavior that I could not find documented anywhere.

Environment:

.NET Core 3 Web API

Expected Behavior:

Only issuers listed as ValidIssuers are allowed to access the API.

Example usage

services
    .AddAuthentication()
    .AddJwtBearer(options =>
    {
        options.Audience = /* clientID */;
        options.Authority = /* authority */;

        options.TokenValidationParameters = new TokenValidationParameters
        {
            ValidIssuers = new[] { /* list of valid issuers */ },
            ValidateIssuer = true,
            ValidAudiences = new[] { /* list of valid audiences */},
            ValidateAudience = true,
            ValidateLifetime = true,
            ValidateIssuerSigningKey = true,
        };
    });

Relevant docs:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.identitymodel.tokens.tokenvalidationparameters.validissuers?view=azure-dotnet

Observed Behavior:

An additional validator is included in the ValidIssuers list in the JWTBearerHandler implementation. Thus, the list of ValidIssuers that I provided is not the final list of ValidIssuers that is used for the comparison.

Relevant source code:

https://github.com/dotnet/aspnetcore/blob/master/src/Security/Authentication/JwtBearer/src/JwtBearerHandler.cs#L95


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri1 active-directorsvc assigned-to-author develosubsvc product-question triaged

All 8 comments

@ccowden, Thank you for sharing this finding. This is something that I see missing in our documentation. Allow us some time to figure out how we can update our docs with this information.

@hpsin, It would be great if you can check on this thread and update the document accordingly.

This is a library question, not a protocols question. @jmprieur would be the appropriate contact here.

@souravmishra-msft : this can be the union of Issuer and ValidIssuer.

Fixed by https://github.com/MicrosoftDocs/azure-docs-pr/pull/122459
should be online soon

please-close

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bdcoder2 picture bdcoder2  Â·  3Comments

AronT-TLV picture AronT-TLV  Â·  3Comments

varma31 picture varma31  Â·  3Comments

jharbieh picture jharbieh  Â·  3Comments

paulmarshall picture paulmarshall  Â·  3Comments