diff --git a/vault/request_handling.go b/vault/request_handling.go index 8647bee52da8..399f2acaf7c7 100644 --- a/vault/request_handling.go +++ b/vault/request_handling.go @@ -1203,6 +1203,7 @@ func (c *Core) handleRequest(ctx context.Context, req *logical.Request) (retResp NamespaceID: ns.ID, } + // Check for request role in context to role based quotas var role string if reqRole := ctx.Value(logical.CtxKeyRequestRole{}); reqRole != nil { role = reqRole.(string) @@ -1402,7 +1403,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) diff --git a/vault/wrapping.go b/vault/wrapping.go index 850d5ad063e6..4fbbd875eb41 100644 --- a/vault/wrapping.go +++ b/vault/wrapping.go @@ -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)