-
Notifications
You must be signed in to change notification settings - Fork 0
Implement access token context encoding framework #3
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
base: feature-token-context-baseline
Are you sure you want to change the base?
Implement access token context encoding framework #3
Conversation
closes #37118 Signed-off-by: mposolda <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 3/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant TokenEndpoint
participant OAuth2GrantType
participant OAuth2GrantTypeBase
participant TokenManager
participant TokenContextEncoder
participant AccessTokenContext
Client->>TokenEndpoint: Token Request (grant_type=...)
TokenEndpoint->>OAuth2GrantType: process(Context)
Note over OAuth2GrantType: Context extracts grant_type<br/>from form params
OAuth2GrantType->>OAuth2GrantTypeBase: createTokenResponse()
OAuth2GrantTypeBase->>OAuth2GrantTypeBase: Set grant_type in<br/>ClientSessionContext
OAuth2GrantTypeBase->>TokenManager: createClientAccessToken()
TokenManager->>TokenManager: initToken()
TokenManager->>TokenContextEncoder: getTokenContextFromClientSessionContext()
TokenContextEncoder->>TokenContextEncoder: Extract session type<br/>(online/offline/transient)
TokenContextEncoder->>TokenContextEncoder: Extract token type<br/>(regular/lightweight)
TokenContextEncoder->>TokenContextEncoder: Extract grant type<br/>from ClientSessionContext
TokenContextEncoder->>AccessTokenContext: new AccessTokenContext(...)
AccessTokenContext-->>TokenContextEncoder: context
TokenContextEncoder-->>TokenManager: AccessTokenContext
TokenManager->>TokenContextEncoder: encodeTokenId(context)
TokenContextEncoder->>TokenContextEncoder: Format: {sessionType}{tokenType}{grantShortcut}:{rawId}<br/>Example: onrtac:1234
TokenContextEncoder-->>TokenManager: encodedTokenId
TokenManager->>TokenManager: token.id(encodedTokenId)
TokenManager-->>OAuth2GrantTypeBase: AccessToken
OAuth2GrantTypeBase-->>Client: Token Response with encoded ID
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
28 files reviewed, 1 comment
| Objects.requireNonNull(sessionType, "Null sessionType not allowed"); | ||
| Objects.requireNonNull(tokenType, "Null tokenType not allowed"); | ||
| Objects.requireNonNull(grantType, "Null grantType not allowed"); | ||
| Objects.requireNonNull(grantType, "Null rawTokenId not allowed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: copy-paste error - validates grantType twice instead of validating rawTokenId
| Objects.requireNonNull(grantType, "Null rawTokenId not allowed"); | |
| Objects.requireNonNull(rawTokenId, "Null rawTokenId not allowed"); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: services/src/main/java/org/keycloak/protocol/oidc/encode/AccessTokenContext.java
Line: 73:73
Comment:
**logic:** copy-paste error - validates `grantType` twice instead of validating `rawTokenId`
```suggestion
Objects.requireNonNull(rawTokenId, "Null rawTokenId not allowed");
```
How can I resolve this? If you propose a fix, please make it concise.
Test 8
Replicated from ai-code-review-evaluation/keycloak-greptile#8