vault: add generic authorizer with jwt auth support#21714
vault: add generic authorizer with jwt auth support#21714prashantkumar1982 merged 1 commit intodevelopfrom
Conversation
|
✅ No conflicts with other open PRs targeting |
There was a problem hiding this comment.
This file is pretty much just a rename of previous request_authorizer.go file
77cda12 to
68f66e2
Compare
CORA - Analysis SkippedReason: The number of code owners (4) is less than the minimum required (5) and/or the number of CODEOWNERS entries with changed files (3) is less than the minimum required (2). |
| if a.orgID != "" { | ||
| return a.orgID | ||
| } | ||
| return a.workflowOwner |
There was a problem hiding this comment.
Aren't we tying all secrets to the org ID? Or is this just for backwards compat and we're planning to remove it?
There was a problem hiding this comment.
This is for the allowlist based auth.
This is on gateway and on vault node before LinkingService.
So we haven't yet mapped workflowOwner to OrgID.
For old auth, workflowOwner is still the owner for the purpose of the request.
Conversion to orgID will happen later in the stack after auth is done.
There was a problem hiding this comment.
For old auth, workflowOwner is still the owner for the purpose of the request.
Isn't that model changing? What happens if wfOwner1 moves from Org X to Org Y - if we don't do that mapping prior, do we prevent wfOwner1 from managing Org X's secrets?
| if a.orgID != "" { | ||
| return a.orgID | ||
| } | ||
| return a.workflowOwner |
There was a problem hiding this comment.
For old auth, workflowOwner is still the owner for the purpose of the request.
Isn't that model changing? What happens if wfOwner1 moves from Org X to Org Y - if we don't do that mapping prior, do we prevent wfOwner1 from managing Org X's secrets?
| if req.Auth == "" { | ||
| return a.authorizeAllowListBasedAuth(ctx, req) | ||
| } | ||
| return a.authorizeJWTBasedAuth(ctx, req) |
There was a problem hiding this comment.
How are we planning to support m2m tokens in the future? They will likely need to have a different prefix. Is it worthwhile making this change now?
| func NewJWTBasedAuth(cfg JWTBasedAuthConfig, limitsFactory limits.Factory, enabled limits.GateLimiter, lggr logger.Logger) (*jwtBasedAuth, error) { | ||
| if enabled == nil { | ||
| enabled = newVaultJWTAuthEnabledLimiter(limitsFactory, lggr) | ||
| func NewJWTBasedAuth(cfg JWTBasedAuthConfig, limitsFactory limits.Factory, lggr logger.Logger, opts ...JWTBasedAuthOption) (*jwtBasedAuth, error) { |
There was a problem hiding this comment.
We'll need to test the JWKS behaviour on the first call. It's generally good practice to hot-load the JWKS in the background even before a request comes through (i.e. on construction time)
There was a problem hiding this comment.
Sounds good, let me do it in a background thread
| ) | ||
|
|
||
| type ErrJobSpecNoRelayer struct { | ||
| type JobSpecNoRelayerError struct { |
There was a problem hiding this comment.
What happened here? Did this need to change?
There was a problem hiding this comment.
I was trying to run the linter locally as it runs in CI, and it complained about this error. So I fixed it. Not sure if CI would've complained about it though. But the fix was simple, so just did it.
Isn't that model changing? What happens if wfOwner1 moves from Org X to Org Y - if we don't do that mapping prior, do we prevent wfOwner1 from managing Org X's secrets? When an incoming request comes in via old auth flow, this authorizer just authenticates if the calling request was authorized via allowlist, and to which workflowOwner key. |
|
@elatoskinas : I don't have more context on m2m tokens. |
Depends on the implementation, but the verification mechanism might change. It's more efficient to pass in the key type e.g. |
|
|
||
| v.eng.GoTick(services.NewTicker(v.refreshInterval), func(ctx context.Context) { | ||
| if err := v.refreshJWKS(ctx); err != nil { | ||
| v.lggr.Warnw("periodic JWKS refresh failed", "error", err) |
There was a problem hiding this comment.
Would strongly suggest tracking metrics in production, incl. latency to fetch JWKS & error rate
5ae8765 to
72f0383
Compare
72f0383 to
45f2fc1
Compare
|
I see you updated files related to
|
|




Summary
This adds the Vault auth abstraction needed for gateway-side JWT support while keeping current behavior unchanged because JWT auth remains disabled.
What changed
Authorizerused by both the Vault gateway handler and the Vault capability gateway handlerAllowListBasedAuthandJWTBasedAuthAuthResultcontract and a sharedRequestReplayGuardJWTBasedAuth, gated internally and failing closed when disabledBehavior