#I844NY 消除Session与Authentication来回嵌套

This commit is contained in:
MaxKey
2023-09-26 14:17:45 +08:00
parent b111a52ccc
commit ef4bfb86f0
16 changed files with 28 additions and 28 deletions

View File

@@ -50,7 +50,7 @@ public class OAuth2UserDetailsService implements UserDetailsService {
SignPrincipal principal = new SignPrincipal(userInfo);
Session onlineTicket = new Session(onlineTickitId);
//set OnlineTicket
principal.setSession(onlineTicket);
principal.setSessionId(onlineTicket.getId());
ArrayList<GrantedAuthority> grantedAuthoritys = loginRepository.grantAuthority(userInfo);
principal.setAuthenticated(true);

View File

@@ -66,7 +66,7 @@ public class OAuthDefaultUserInfoAdapter extends AbstractAuthorizeAdapter {
beanMap.put("state", userInfo.getWorkRegion());
beanMap.put("gender", userInfo.getGender());
beanMap.put("institution", userInfo.getInstId());
beanMap.put(WebConstants.ONLINE_TICKET_NAME, principal.getSession().getFormattedId());
beanMap.put(WebConstants.ONLINE_TICKET_NAME, principal.getSessionId());
String info= JsonUtils.toString(beanMap);

View File

@@ -123,7 +123,7 @@ public class UserInfoOIDCEndpoint {
String userJson = "";
Builder jwtClaimsSetBuilder= new JWTClaimsSet.Builder();
SignPrincipal authentication = (SignPrincipal)oAuth2Authentication.getUserAuthentication().getPrincipal();
SignPrincipal oauthPrincipal = (SignPrincipal)oAuth2Authentication.getUserAuthentication().getPrincipal();
String subject = AbstractAuthorizeAdapter.getValueByUserAttr(userInfo, clientDetails.getSubject());
_logger.debug("userId : {} , username : {} , displayName : {} , subject : {}" ,
@@ -134,7 +134,7 @@ public class UserInfoOIDCEndpoint {
jwtClaimsSetBuilder.claim("sub", subject);
jwtClaimsSetBuilder.claim("institution", userInfo.getInstId());
jwtClaimsSetBuilder.claim(WebConstants.ONLINE_TICKET_NAME, authentication.getSession().getFormattedId());
jwtClaimsSetBuilder.claim(WebConstants.ONLINE_TICKET_NAME, oauthPrincipal.getSessionId());
if(scopes.contains("profile")){
jwtClaimsSetBuilder.claim("userId", userInfo.getId());