Skip to content

Commit

Permalink
Merge pull request #38218 from stephan-strate/test-oidc-server/jwt-to…
Browse files Browse the repository at this point in the history
…ken-subject

Make subject configurable in OidcWiremockTestResource
  • Loading branch information
sberyozkin authored Jan 16, 2024
2 parents f41b7a0 + 2508e60 commit 1a1bce7
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,15 @@ private void defineCodeFlowAuthorizationMockEncryptedTokenStub() {
}

public static String getEncryptedIdToken(String userName, Set<String> groups) {
return getEncryptedIdToken(userName, groups, "123456");
}

public static String getEncryptedIdToken(String userName, Set<String> groups, String sub) {
return Jwt.preferredUserName(userName)
.groups(groups)
.issuer(TOKEN_ISSUER)
.audience(TOKEN_AUDIENCE)
.subject("123456")
.subject(sub)
.jws()
.keyId("1")
.innerSign("privateKey.jwk").encrypt("publicKey.jwk");
Expand Down Expand Up @@ -368,26 +372,23 @@ public static String getIdToken(String userName, Set<String> groups) {
}

public static String generateJwtToken(String userName, Set<String> groups) {
return generateJwtToken(userName, groups, "123456");
}

public static String generateJwtToken(String userName, Set<String> groups, String sub) {
return Jwt.preferredUserName(userName)
.groups(groups)
.issuer(TOKEN_ISSUER)
.audience(TOKEN_AUDIENCE)
.claim("sid", "session-id")
.subject("123456")
.subject(sub)
.jws()
.keyId("1")
.sign("privateKey.jwk");
}

public static String getLogoutToken() {
return Jwt.issuer(TOKEN_ISSUER)
.audience(TOKEN_AUDIENCE)
.subject("123456")
.claim("events", createEventsClaim())
.claim("sid", "session-id")
.jws()
.keyId("1")
.sign("privateKey.jwk");
return getLogoutToken("123456");
}

public static String getLogoutToken(String sub) {
Expand Down

0 comments on commit 1a1bce7

Please sign in to comment.