From 888fef5e540049106213a77f062ad6e1b7ceab8e Mon Sep 17 00:00:00 2001 From: Steve Hu Date: Wed, 1 Apr 2020 23:53:35 -0400 Subject: [PATCH] fixes #244 change roles to string in the JWT from array of strings --- .../oauth/token/handler/Oauth2TokenPostHandler.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/token/src/main/java/com/networknt/oauth/token/handler/Oauth2TokenPostHandler.java b/token/src/main/java/com/networknt/oauth/token/handler/Oauth2TokenPostHandler.java index 67a2f7f3..e2e6749f 100644 --- a/token/src/main/java/com/networknt/oauth/token/handler/Oauth2TokenPostHandler.java +++ b/token/src/main/java/com/networknt/oauth/token/handler/Oauth2TokenPostHandler.java @@ -583,7 +583,7 @@ private JwtClaims mockCcClaims(String clientId, String scopeString, Map formMap) { + private JwtClaims mockAcClaims(String clientId, String scopeString, String userId, String userType, String roles, String csrf, Map formMap) { JwtClaims claims = JwtIssuer.getDefaultJwtClaims(); claims.setClaim("user_id", userId); claims.setClaim("user_type", userType); @@ -593,9 +593,8 @@ private JwtClaims mockAcClaims(String clientId, String scopeString, String userI List scope = Arrays.asList(scopeString.split("\\s+")); claims.setStringListClaim("scope", scope); // multi-valued claims work too and will end up as a JSON array } - if(roleString != null && roleString.trim().length() > 0) { - List roles = Arrays.asList(roleString.split("\\s+")); - claims.setStringListClaim("roles", roles); // multi-valued claims work too and will end up as a JSON array + if(roles != null && roles.trim().length() > 0) { + claims.setClaim("roles", roles); } if(formMap != null) {