Skip to content
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

feat: add id-token to password grant token response #610

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ internal class PasswordGrantHandler(
val scope: String? = tokenRequest.scope?.toString()
val passwordGrantTokenCallback = PasswordGrantTokenCallback(oAuth2TokenCallback)
val accessToken: SignedJWT = tokenProvider.accessToken(tokenRequest, issuerUrl, passwordGrantTokenCallback)
val idToken: SignedJWT = tokenProvider.idToken(tokenRequest, issuerUrl, passwordGrantTokenCallback, null)

return OAuth2TokenResponse(
tokenType = "Bearer",
accessToken = accessToken.serialize(),
idToken = idToken.serialize(),
expiresIn = accessToken.expiresIn(),
scope = scope,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class PasswordGrantIntegrationTest {
response.accessToken should verifyWith(issuerId, this)
response.accessToken.subject shouldBe "foo"
response.accessToken.audience shouldContainExactly listOf("scope1")
response.idToken.shouldNotBeNull()
response.idToken should verifyWith(issuerId, this)
response.idToken.subject shouldBe "foo"
response.idToken.audience shouldContainExactly listOf("client")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ infix fun ParsedTokenResponse.shouldBeValidFor(type: GrantType) {
idToken shouldNotBe null
refreshToken shouldNotBe null
}
TOKEN_EXCHANGE, JWT_BEARER, CLIENT_CREDENTIALS, PASSWORD -> {
TOKEN_EXCHANGE, JWT_BEARER, CLIENT_CREDENTIALS -> {
idToken shouldBe null
refreshToken shouldBe null
}
PASSWORD -> {
idToken shouldNotBe null
refreshToken shouldBe null
}
}
}
}
Expand Down