Skip to content

Commit

Permalink
Merge pull request #18415 from sberyozkin/oidc_client_expires_in_string
Browse files Browse the repository at this point in the history
Update OidcClient to accept String expires_in values
  • Loading branch information
sberyozkin authored Jul 5, 2021
2 parents f44b4c3 + d233b01 commit 838e9db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ private Tokens emitGrantTokens(HttpResponse<Buffer> resp, boolean refresh) {
JsonObject json = resp.bodyAsJsonObject();
final String accessToken = json.getString(oidcConfig.grant.accessTokenProperty);
final String refreshToken = json.getString(oidcConfig.grant.refreshTokenProperty);
final Object expiresInValue = json.getValue(oidcConfig.grant.expiresInProperty);
Long accessTokenExpiresAt;
Long accessTokenExpiresIn = json.getLong(oidcConfig.grant.expiresInProperty);
if (accessTokenExpiresIn != null) {
if (expiresInValue != null) {
long accessTokenExpiresIn = expiresInValue instanceof Number ? ((Number) expiresInValue).longValue()
: Long.parseLong(expiresInValue.toString());
accessTokenExpiresAt = Instant.now().getEpochSecond() + accessTokenExpiresIn;
} else {
accessTokenExpiresAt = getExpiresJwtClaim(accessToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public Map<String, String> start() {
.aResponse()
.withHeader("Content-Type", MediaType.APPLICATION_JSON)
.withBody(
"{\"accessToken\":\"access_token_n\", \"expiresIn\":4, \"refreshToken\":\"refresh_token_n\"}")));
"{\"accessToken\":\"access_token_n\", \"expiresIn\":\"4\", \"refreshToken\":\"refresh_token_n\"}")));

server.stubFor(WireMock.post("/tokens")
.withRequestBody(matching("grant_type=refresh_token&refresh_token=refresh_token_1"))
Expand Down

0 comments on commit 838e9db

Please sign in to comment.