Skip to content

Commit

Permalink
Remove unnecessary call to DetermineRoleFromLoginRequest (#22603)
Browse files Browse the repository at this point in the history
* remove unnecessary call to DetermineRoleFromLoginRequest

* add more context to comment
  • Loading branch information
elliesterner committed Aug 29, 2023
1 parent 9cd0d91 commit 9b78fd6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions vault/request_handling.go
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,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 @@ -1488,7 +1488,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 @@ -327,8 +327,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

0 comments on commit 9b78fd6

Please sign in to comment.