자원 서버 인증 확장 사용자 정보 얻기

1215 단어

    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {

        DefaultAccessTokenConverter defaultAccessTokenConverter=new DefaultAccessTokenConverter();
        defaultAccessTokenConverter.setUserTokenConverter(myUserAuthenticationConverter);


        endpoints

                // 

                .authenticationManager(authenticationManager)

                // 
                .authorizationCodeServices(authorizationCodeServices())
                .reuseRefreshTokens(true)
                // 
                .tokenServices(authorizationServerTokenServices())

                .accessTokenConverter(defaultAccessTokenConverter)
                .allowedTokenEndpointRequestMethods(HttpMethod.POST);


    }

Converter

@Service
public class MyUserAuthenticationConverter extends DefaultUserAuthenticationConverter {


    @Override
    public Map convertUserAuthentication(Authentication authentication) {
        Map response = new LinkedHashMap();
        response.put("user_name", authentication);
        return response;
    }
}

좋은 웹페이지 즐겨찾기