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

Backport of Remove unnecessary call to DetermineRoleFromLoginRequest into release/1.13.x #22622

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions vault/request_handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ func (c *Core) handleRequest(ctx context.Context, req *logical.Request) (retResp
NamespaceID: ns.ID,
}

// Check for request role
// Check for request role in context to role based quotas
var role string
if reqRole := ctx.Value(logical.CtxKeyRequestRole{}); reqRole != nil {
role = reqRole.(string)
Expand Down Expand Up @@ -1471,7 +1471,7 @@ func (c *Core) handleLoginRequest(ctx context.Context, req *logical.Request) (re
return
}

// Check for request role
// Check for request role in context to role based quotas
var role string
if reqRole := ctx.Value(logical.CtxKeyRequestRole{}); reqRole != nil {
role = reqRole.(string)
Expand Down
8 changes: 7 additions & 1 deletion vault/wrapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,14 @@ DONELISTHANDLING:
},
}

// Check for request role in context to role based quotas
var role string
if reqRole := ctx.Value(logical.CtxKeyRequestRole{}); reqRole != nil {
role = reqRole.(string)
}

// Register the wrapped token with the expiration manager
if err := c.expiration.RegisterAuth(ctx, &te, wAuth, c.DetermineRoleFromLoginRequest(req.MountPoint, req.Data, ctx)); err != nil {
if err := c.expiration.RegisterAuth(ctx, &te, wAuth, role); err != nil {
// Revoke since it's not yet being tracked for expiration
c.tokenStore.revokeOrphan(ctx, te.ID)
c.logger.Error("failed to register cubbyhole wrapping token lease", "request_path", req.Path, "error", err)
Expand Down