Skip to content

Handle subject in nested claim for JWT auth backends #5467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

Rishav9852Kumar
Copy link
Contributor

@Rishav9852Kumar Rishav9852Kumar commented Jul 11, 2025

Description

This PR abstracts the subject configuration from jwt-backed auth backends to handle a list as config to get sub within nested claims of a JWT payload.

  • Category (Enhancement, New feature, Bug fix, Test fix, Refactoring, Maintenance, Documentation)

Enhancement of #5355

Issues Resolved

Resolves #5430

Supported Nested claims

Standard structure with top-level subject:
{
    "sub": "Leonard McCoy",
    "aud": "TestAudience",
    "iss": "TestIssuer",
    "roles": "role1,role2"
}

Standard structure with top-level subject with nested structures for roles:
{
    "sub": "Leonard McCoy",
    "aud": "TestAudience",
    "iss": "TestIssuer",
    "attributes": {
        "roles": "role1,role2"
    }
}

Nested subject under attributes:
{
    "aud": "TestAudience",
    "iss": "TestIssuer",
    "attributes": {
        "roles": "role1,role2",
        "sub": "Leonard McCoy"
    }
}

Separate nested structures for subject and roles:
{
    "attributes_sub": {
        "sub": "Leonard McCoy"
    },
    "aud": "TestAudience",
    "iss": "TestIssuer",
    "attributes": {
        "roles": "role1,role2"
    }
}

Testing

Unit Tests added

  • testSubjectInNestedClaim
  • testSubjectAndRolesInNestedClaim
Unit Tests Result

Check List

  • New functionality includes testing
  • New functionality has been documented
  • New Roles/Permissions have a corresponding security dashboards plugin PR
  • API changes companion pull request created
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Rishav Kumar and others added 13 commits July 11, 2025 11:39
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
…eClaimName.

Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Copy link

codecov bot commented Jul 23, 2025

Codecov Report

Attention: Patch coverage is 73.52941% with 9 lines in your changes missing coverage. Please review.

Project coverage is 72.72%. Comparing base (a581bc6) to head (d0cfa79).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...h/security/auth/http/jwt/HTTPJwtAuthenticator.java 70.58% 3 Missing and 2 partials ⚠️
...ty/auth/http/jwt/AbstractHTTPJwtAuthenticator.java 76.47% 2 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5467      +/-   ##
==========================================
- Coverage   72.76%   72.72%   -0.05%     
==========================================
  Files         397      397              
  Lines       24591    24613      +22     
  Branches     3741     3746       +5     
==========================================
+ Hits        17894    17899       +5     
- Misses       4867     4881      +14     
- Partials     1830     1833       +3     
Files with missing lines Coverage Δ
...ty/auth/http/jwt/AbstractHTTPJwtAuthenticator.java 62.83% <76.47%> (+1.21%) ⬆️
...h/security/auth/http/jwt/HTTPJwtAuthenticator.java 76.55% <70.58%> (-2.29%) ⬇️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Rishav Kumar added 3 commits July 23, 2025 22:02
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.com>
Signed-off-by: Rishav Kumar <rishavaz@amazon.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.

[FEATURE] Support subject key in a nested claim within JWT
1 participant