Skip to content

vmuser: support JWT auth#1944

Merged
AndrewChubatiuk merged 2 commits intomasterfrom
vmauth-oidc-support
Mar 17, 2026
Merged

vmuser: support JWT auth#1944
AndrewChubatiuk merged 2 commits intomasterfrom
vmauth-oidc-support

Conversation

@AndrewChubatiuk
Copy link
Contributor

@AndrewChubatiuk AndrewChubatiuk commented Mar 9, 2026

related issue #591
related issue VictoriaMetrics/VictoriaMetrics#9439


Summary by cubic

Adds JWT auth to VMUser for vmauth, with OIDC issuer support and claim-based routing. Verification supports inline public keys, Secret refs (merged at build), or skip-verify for testing, with validation enforcing exactly one mechanism.

  • New Features
    • New VMUserSpec.jwt: skipVerify, publicKeys, publicKeyRefs, matchClaims, and oidc.issuer.
    • Validation: only one of username, bearerToken, or jwt; and exactly one of jwt.{skipVerify | publicKeys/publicKeyRefs | oidc}; oidc.issuer is required when oidc is set.
    • Config: emits jwt.skip_verify, jwt.public_keys, jwt.match_claims, and jwt.oidc.issuer; publicKeyRefs are resolved into publicKeys.
    • CRD schema, deepcopy, docs, and changelog updated; tests added for skip-verify, Secret refs, claim routing, and OIDC.

Written for commit 45b87cc. Summary will update on new commits.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/CHANGELOG.md">

<violation number="1" location="docs/CHANGELOG.md:23">
P1: Custom agent: **Changelog Review Agent**

Changelog entry is missing the required user-centric before/after explanation and reference link(s), so it doesn’t follow the mandated changelog structure.</violation>
</file>

<file name="internal/controller/operator/factory/vmauth/vmusers_config.go">

<violation number="1" location="internal/controller/operator/factory/vmauth/vmusers_config.go:193">
P2: JWT branch always returns false, so secret updates (e.g., changed `name`) are dropped and never persisted.</violation>
</file>

<file name="api/operator/v1beta1/vmuser_types.go">

<violation number="1" location="api/operator/v1beta1/vmuser_types.go:339">
P1: Validate JWT config requires either `skipVerify=true` or at least one public key/public key ref. Right now `spec.jwt: {}` passes validation and can produce an empty `jwt` section.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@AndrewChubatiuk AndrewChubatiuk force-pushed the vmauth-oidc-support branch 2 times, most recently from f801044 to 4c14d2c Compare March 9, 2026 09:47
return fmt.Errorf("exactly one spec.jwt.{skipVerify,publicKeys|publicKeyRefs,oidc} JWT verification mechanism is expected, got: [%s]", strings.Join(jwtVerification, ","))
}
}
if len(authMechanisms) > 1 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't have a check for this before, but what if its zero? Is it treated as unauthenticated user?

Copy link
Contributor Author

@AndrewChubatiuk AndrewChubatiuk Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check was added as with this PR more auth mechanisms are supported
if there are more than 1 auth mechanism set vmauth fails during configuration validation. if there're no auth mechanisms VMUser is treated as basic auth user

Signed-off-by: Vadim Rutkovsky <vadim@vrutkovs.eu>
@AndrewChubatiuk AndrewChubatiuk merged commit e827856 into master Mar 17, 2026
6 checks passed
@AndrewChubatiuk AndrewChubatiuk deleted the vmauth-oidc-support branch March 17, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants