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

Validate JWT supported algorithms against supported set if not provided in config #161

Merged
merged 3 commits into from
Mar 15, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion path_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,21 @@ func (b *jwtAuthBackend) pathLogin(ctx context.Context, req *logical.Request, d
return logical.ErrorResponse("error configuring token validator: %s", err.Error()), nil
}

// Validate JWT supported algorithms if they've been provided. Otherwise,
// ensure that the signing algorithm is a member of the supported set.
signingAlgorithms := toAlg(config.JWTSupportedAlgs)
if len(signingAlgorithms) == 0 {
austingebauer marked this conversation as resolved.
Show resolved Hide resolved
signingAlgorithms = []jwt.Alg{
jwt.RS256, jwt.RS384, jwt.RS512, jwt.ES256, jwt.ES384,
jwt.ES512, jwt.PS256, jwt.PS384, jwt.PS512, jwt.EdDSA}
austingebauer marked this conversation as resolved.
Show resolved Hide resolved
}

// Set expected claims values to assert on the JWT
expected := jwt.Expected{
Issuer: config.BoundIssuer,
Subject: role.BoundSubject,
Audiences: role.BoundAudiences,
SigningAlgorithms: toAlg(config.JWTSupportedAlgs),
SigningAlgorithms: signingAlgorithms,
NotBeforeLeeway: role.NotBeforeLeeway,
ExpirationLeeway: role.ExpirationLeeway,
ClockSkewLeeway: role.ClockSkewLeeway,
Expand Down