Skip to content

Conversation

@ewanharris
Copy link
Member

@ewanharris ewanharris commented May 30, 2025

Description

This PR introduces support for performing a client credentials authentication flow using client assertion (aka private key jwt, jwt ca) as an alternative to the existing client secret authentication method.

As this is an alternative ClientCredentials method I have split the existing configuration out into ClientSecretConfig and introduced a PrivateKeyJWT to go along side this and changed the ClientCredentialsConfig to be union of the two to allow type checking to work correctly.

The client assertion signing is performed using jose and I am using v5 of this library over v6 as the latter is an ESM only package which would have implications for our supported Node.js versions.

An extra, not insignificant change to this is the addition of a customClaims property on the client credentials configuration, this is to allow extra data to be passed to the token exchange for clients that need this.

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

@ewanharris ewanharris requested a review from a team as a code owner May 30, 2025 11:16
@socket-security
Copy link

socket-security bot commented May 30, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedjose@​5.10.010010010090100

View full report

@codecov-commenter
Copy link

codecov-commenter commented May 30, 2025

Codecov Report

Attention: Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.16%. Comparing base (b605f86) to head (1cf2503).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
credentials/credentials.ts 88.88% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #228      +/-   ##
==========================================
- Coverage   88.18%   88.16%   -0.02%     
==========================================
  Files          23       23              
  Lines        1202     1217      +15     
  Branches      211      197      -14     
==========================================
+ Hits         1060     1073      +13     
- Misses         84       86       +2     
  Partials       58       58              

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

🚀 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.

rhamzeh
rhamzeh previously approved these changes Jun 3, 2025
@ewanharris ewanharris force-pushed the feat/support-client_assertion branch from 48b0e9f to 1cf2503 Compare June 3, 2025 15:30
@ewanharris ewanharris requested a review from rhamzeh June 3, 2025 15:30
@ewanharris ewanharris added this pull request to the merge queue Jun 3, 2025
Merged via the queue into main with commit 7303103 Jun 3, 2025
20 checks passed
@ewanharris ewanharris deleted the feat/support-client_assertion branch June 3, 2025 16:20
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.

4 participants