Skip to content

Commit 7bd53b8

Browse files
committed
Fixing the ValidateIsseur method:
The contract for TokenValidationParameters.IssuerValidator is to throw on an invalid issuer. The recommendation is to throw a SecurityTokenInvalidIssuerExpecption.
1 parent b35a3d8 commit 7bd53b8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

TodoListService/Extensions/AzureAdAuthenticationBuilderExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,21 @@ private string ValidateIssuer(string issuer, SecurityToken securityToken, TokenV
6363
Guid tenantId;
6464
if (uri.Scheme != authorityUri.Scheme || uri.Authority != authorityUri.Authority)
6565
{
66-
return null;
66+
throw new SecurityTokenInvalidIssuerException("Issuer has wrong authority");
6767
}
6868
if (!Guid.TryParse(parts[1], out tenantId))
6969
{
70-
return null;
70+
throw new SecurityTokenInvalidIssuerException("Cannot find the tenant GUID for the issuer");
7171
}
7272
if (parts.Length> 2 && parts[2] != "v2.0")
7373
{
74-
return null;
74+
throw new SecurityTokenInvalidIssuerException("Only accepted protocol versions are AAD v1.0 or V2.0");
7575
}
7676
return issuer;
7777
}
7878
else
7979
{
80-
return null;
80+
throw new SecurityTokenInvalidIssuerException("Unknown issuer");
8181
}
8282
}
8383

0 commit comments

Comments
 (0)