Skip to content

Conversation

crenshaw-dev
Copy link
Member

@crenshaw-dev crenshaw-dev commented May 29, 2025

#20683 introduced a new ArgoClaims struct to hold JWT information, specifically information about federated claims.

The struct enforces a particular JWT format. One problematic expectation is that the groups claim be represented as an array rather than as a string (see #22973).

The struct isn't necessary to accomplish the key task (retrieving information from the federated_claims claim).

I've reverted the parts of #20683 that relied on the new struct. Instead, I use a new utility function to pull info from federated_claims and fall back to sub when necessary.

We can consider cherry-picking a smaller change (possibly just dropping the Groups field from the ArgoClaims struct. But I think introducing the struct was an error, and we should favor a simpler implementation going forward.

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
@crenshaw-dev crenshaw-dev requested a review from a team as a code owner May 29, 2025 14:55
Copy link

bunnyshell bot commented May 29, 2025

❌ Preview Environment deleted from Bunnyshell

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

Copy link

codecov bot commented May 29, 2025

Codecov Report

❌ Patch coverage is 84.12698% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.09%. Comparing base (b8051c6) to head (ecd7f6f).
⚠️ Report is 418 commits behind head on master.

Files with missing lines Patch % Lines
cmd/argocd/commands/project_role.go 0.00% 5 Missing ⚠️
server/server.go 80.00% 2 Missing ⚠️
util/session/sessionmanager.go 86.66% 2 Missing ⚠️
cmd/argocd/commands/login.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #23202      +/-   ##
==========================================
+ Coverage   60.01%   60.09%   +0.07%     
==========================================
  Files         343      342       -1     
  Lines       57890    57845      -45     
==========================================
+ Hits        34744    34763      +19     
+ Misses      20362    20315      -47     
+ Partials     2784     2767      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@crenshaw-dev crenshaw-dev requested a review from Copilot May 29, 2025 15:41
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR reverts the previous use of the ArgoClaims struct for extracting JWT claims and replaces it with a simpler approach that directly works with jwt.MapClaims. The changes are focused on:

  • Removing the claimsutil.MapClaimsToArgoClaims conversion in favor of using the new utility function claimsutil.GetUserIdentifier.
  • Updating various modules (session, server, rbac, and CLI commands) to work directly with jwt.MapClaims.
  • Simplifying test cases by no longer relying on the ArgoClaims struct.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
util/session/sessionmanager_test.go Removed dependency on ArgoClaims conversion in tests.
util/session/sessionmanager.go Dropped ArgoClaims in favor of jwt.RegisteredClaims and GetUserIdentifier.
util/rbac/rbac.go Replaced MapClaimsToArgoClaims with GetUserIdentifier for clarity.
util/claims/claims.go Removed the ArgoClaims and FederatedClaims structs; consolidated GetUserIdentifier.
server/server.go Updated claims retrieval logic to work directly with jwt.MapClaims.
server/rbacpolicy/rbacpolicy.go Updated to use claimsutil.GetUserIdentifier.
cmd/argocd/commands/project_role.go Updated token parsing and claims extraction logic.
cmd/argocd/commands/login_test.go Modified tests to use jwt.MapClaims directly.
cmd/argocd/commands/login.go Simplified userDisplayName to use jwtutil.StringField and GetUserIdentifier.

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Copy link
Contributor

@aali309 aali309 left a comment

Choose a reason for hiding this comment

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

LGTM!

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Copy link
Member

@agaudreault agaudreault left a comment

Choose a reason for hiding this comment

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

Removing ArgoClaims type so we dont have an additional type until we want to refactor the claims to use our own type instead of a mix of MapClaims/RegisteredClaims with utility methods #21715

@crenshaw-dev crenshaw-dev enabled auto-merge (squash) May 29, 2025 18:53
@crenshaw-dev crenshaw-dev merged commit 7fda067 into argoproj:master May 29, 2025
27 checks passed
chansuke pushed a commit to chansuke/argo-cd that referenced this pull request Jun 4, 2025
…rgoproj#23202)

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
dsuhinin pushed a commit to dsuhinin/argo-cd that referenced this pull request Jun 16, 2025
…rgoproj#23202)

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: dsuhinin <suhinin.dmitriy@gmail.com>
dsuhinin pushed a commit to dsuhinin/argo-cd that referenced this pull request Jun 16, 2025
…rgoproj#23202)

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: dsuhinin <suhinin.dmitriy@gmail.com>
enneitex pushed a commit to enneitex/argo-cd that referenced this pull request Aug 24, 2025
…rgoproj#23202)

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: enneitex <etienne.divet@gmail.com>
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.

3 participants