Secrets: Add namespace matches checks to authorizer and secure value client (#109651)

* Decrypt: Add namespace matches to authorizer

* SecureValueClient: Add namespace matches when auth checking
This commit is contained in:
Matheus Macabu
2025-08-14 11:50:56 +02:00
committed by GitHub
parent a38a5e0301
commit dfae5e5b4d
7 changed files with 145 additions and 103 deletions
@@ -265,8 +265,17 @@ func (c *secureValueClient) mapError(err error, name string) error {
}
func (c *secureValueClient) checkAccess(ctx context.Context, name, verb string) error {
authInfo, ok := claims.AuthInfoFrom(ctx)
if !ok {
return apierrors.NewUnauthorized("missing auth info in context")
}
gr := secretv1beta1.SecureValuesResourceInfo.GroupResource()
if !claims.NamespaceMatches(authInfo.GetNamespace(), c.namespace) {
return apierrors.NewForbidden(gr, name, fmt.Errorf("namespace mismatch: %s != %s", authInfo.GetNamespace(), c.namespace))
}
decision, reason, err := c.access.Authorize(ctx, authorizer.AttributesRecord{
Verb: verb,
Namespace: c.namespace,