Repository navigation
perf(oidc): remove get user by ID from jwt profile grant - #8580
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thanks for your contribution @muhlemmer! 🎉Please make sure you tick the following checkboxes before marking this Pull Request (PR) as ready for review:
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8580 +/- ##
===========================================
+ Coverage 47.63% 63.87% +16.24%
===========================================
Files 1424 1492 +68
Lines 118060 120681 +2621
===========================================
+ Hits 56237 77091 +20854
+ Misses 58798 39369 -19429
- Partials 3025 4221 +1196
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
Local load test on |
|
On this branch That's a 2.6x improvement. Note that at this stage k6, zitadel and postgres are competing for resources on my system. A load test in a deployment might give better numbers. |
|
just saw the benchmarks great job 🥳 |
|
Oh wow, great job! |
# Which Problems Are Solved Calls with tokens issued through JWT Profile or Client Credentials Grants were no longer possible and threw a "could not read projectid by clientid (AUTH-GHpw2)" error. ZITADEL checks the allowed origins of an application and load its projectID into the context on any API call. Tokens from service accounts did not contain any clientID and therefore never did that check. But due to a change in #8580, were the service user id was set as client_id in the OIDC session to fix the introspection response (#8590). # How the Problems Are Solved - Check if the project and origin were retrieved and only then check the origins # Additional Changes None. # Additional Context - closes #8676 - relates to #8580 (released on 2.62.0) - relates to #8590
# Which Problems Are Solved Calls with tokens issued through JWT Profile or Client Credentials Grants were no longer possible and threw a "could not read projectid by clientid (AUTH-GHpw2)" error. ZITADEL checks the allowed origins of an application and load its projectID into the context on any API call. Tokens from service accounts did not contain any clientID and therefore never did that check. But due to a change in #8580, were the service user id was set as client_id in the OIDC session to fix the introspection response (#8590). # How the Problems Are Solved - Check if the project and origin were retrieved and only then check the origins # Additional Changes None. # Additional Context - closes #8676 - relates to #8580 (released on 2.62.0) - relates to #8590 (cherry picked from commit c347e75)
# Which Problems Are Solved Calls with tokens issued through JWT Profile or Client Credentials Grants were no longer possible and threw a "could not read projectid by clientid (AUTH-GHpw2)" error. ZITADEL checks the allowed origins of an application and load its projectID into the context on any API call. Tokens from service accounts did not contain any clientID and therefore never did that check. But due to a change in #8580, were the service user id was set as client_id in the OIDC session to fix the introspection response (#8590). # How the Problems Are Solved - Check if the project and origin were retrieved and only then check the origins # Additional Changes None. # Additional Context - closes #8676 - relates to #8580 (released on 2.62.0) - relates to #8590 (cherry picked from commit c347e75)
…8704) # Which Problems Are Solved Calls with tokens issued through JWT Profile or Client Credentials Grants were no longer possible and threw a "could not read projectid by clientid (AUTH-GHpw2)" error. ZITADEL checks the allowed origins of an application and load its projectID into the context on any API call. Tokens from service accounts did not contain any clientID and therefore never did that check. But due to a change in zitadel#8580, were the service user id was set as client_id in the OIDC session to fix the introspection response (zitadel#8590). # How the Problems Are Solved - Check if the project and origin were retrieved and only then check the origins # Additional Changes None. # Additional Context - closes zitadel#8676 - relates to zitadel#8580 (released on 2.62.0) - relates to zitadel#8590 (cherry picked from commit dd1b2a6)
Which Problems Are Solved
Improve performance by removing a GetUserByID call. The call also executed a Trigger on projections, which significantly impacted concurrent requests.
How the Problems Are Solved
Token creation needs information from the user, such as the resource owner and access token type.
For client credentials this is solved in a single search. By getting the user by username (
client_id), the user details and secret were obtained in a single query. After that verification and token creation can proceed. For JWT profile it is a bit more complex. We didn't know anything about the user until after JWT verification.The verification did a query for the AuthN key and after that we did a GetUserByID to get remaining details.
This change uses a joined query when the OIDC library calls the
GetKeyByIDAndClientIDmethod on the token storage. The found user details are set to the verifieer object and returned after verification is completed.It is safe because the
jwtProfileKeyStorageis a single-use object as a wrapper aroundquery.Queries.This way getting the public key and user details are obtained in a single query.
Additional Changes
client_idfield with machine's username.Additional Context