Skip to content

Commit 22beabd

Browse files
authored
change audience warning text since audiences wont be required in Vault 1.21 (#330)
1 parent 7b485b8 commit 22beabd

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

path_login.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (b *kubeAuthBackend) pathLogin(ctx context.Context, req *logical.Request, d
162162
return nil, logical.ErrUnrecoverable
163163
}
164164

165-
sa, err := b.parseAndValidateJWT(ctx, client, jwtStr, role, roleName, config)
165+
sa, err := b.parseAndValidateJWT(ctx, client, jwtStr, role, config)
166166
if err != nil {
167167
if err == jose.ErrCryptoFailure || strings.Contains(err.Error(), "verifying token signature") {
168168
b.Logger().Debug(`login unauthorized`, "err", err)
@@ -298,7 +298,7 @@ func (b *kubeAuthBackend) aliasLookahead(ctx context.Context, req *logical.Reque
298298
return nil, logical.ErrUnrecoverable
299299
}
300300

301-
sa, err := b.parseAndValidateJWT(ctx, client, jwtStr, role, roleName, config)
301+
sa, err := b.parseAndValidateJWT(ctx, client, jwtStr, role, config)
302302
if err != nil {
303303
return nil, err
304304
}
@@ -334,7 +334,7 @@ func (keySet DontVerifySignature) VerifySignature(_ context.Context, token strin
334334

335335
// parseAndValidateJWT is used to parse, validate and lookup the JWT token.
336336
func (b *kubeAuthBackend) parseAndValidateJWT(ctx context.Context, client *http.Client, jwtStr string,
337-
role *roleStorageEntry, roleName string, config *kubeConfig,
337+
role *roleStorageEntry, config *kubeConfig,
338338
) (*serviceAccount, error) {
339339
expected := capjwt.Expected{
340340
SigningAlgorithms: allowedSigningAlgsCap,
@@ -350,12 +350,8 @@ func (b *kubeAuthBackend) parseAndValidateJWT(ctx context.Context, client *http.
350350
}
351351
}
352352

353-
// Roles will need to specify an audience in Vault v1.21+.
354-
// Log a warning if the role does not specify one.
355-
if strings.TrimSpace(role.Audience) == "" {
356-
b.Logger().Warn("A role without an audience was used to authenticate into Vault. "+
357-
"Vault v1.21+ will require roles to have an audience.", "role_name", roleName)
358-
} else {
353+
// validate the audience if the role expects it
354+
if role.Audience != "" {
359355
expected.Audiences = []string{role.Audience}
360356
}
361357

path_role.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,20 +339,18 @@ func (b *kubeAuthBackend) pathRoleCreateUpdate(ctx context.Context, req *logical
339339
return logical.ErrorResponse("can not mix %q with values", "*"), nil
340340
}
341341

342-
// audiences will be required in kubernetes roles in a future Vault version
343342
if audience, ok := data.GetOk("audience"); ok {
344343
role.Audience = audience.(string)
345344
}
346345

347-
// Vault 1.21+ will require an audience to be set on a role for security reasons.
348-
// Log a warning if the role does not specify an audience.
346+
// Warn if audience is not set
349347
if strings.TrimSpace(role.Audience) == "" {
350348
if resp == nil {
351349
resp = &logical.Response{}
352350
}
353351

354-
b.Logger().Warn("This role does not have an audience. In Vault v1.21+, specifying an audience on roles will be required.", "role_name", roleName)
355-
resp.AddWarning(fmt.Sprintf("Role %s does not have an audience. In Vault v1.21+, specifying an audience on roles will be required.", roleName))
352+
b.Logger().Warn("This role does not have an audience configured. While audiences are not required, consider specifying one if your use case would benefit from additional JWT claim verification.", "role_name", roleName)
353+
resp.AddWarning(fmt.Sprintf("Role %s does not have an audience configured. While audiences are not required, consider specifying one if your use case would benefit from additional JWT claim verification.", roleName))
356354
}
357355

358356
if source, ok := data.GetOk("alias_name_source"); ok {

0 commit comments

Comments
 (0)