/oauth/token端点的java自定义配置
我使用spring-security-oauth2。 我想自定义配置/oauth/token端点。 注册一个新客户后,我需要使用这个客户的登录名和密码,为他创建一个令牌并返回这个令牌。 我可以自定义配置这个/oauth/token端点吗? 如果我收到有关此端点的错误信息(不正确的登录或密码),是否可以返回自定义错误? 我可以在这里输入客户id和客户机密,而不在前端输入吗
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
@Autowired
private DataSource dataSource;
@Autowired
private TokenStore tokenStore;
@Autowired
private JwtAccessTokenConverter jwtTokenEnhancer;
@Autowired
private UserApprovalHandler userApprovalHandler;
@Autowired
private AuthenticationManager authenticationManager;
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients.jdbc(dataSource);
}
@Override
public void configure(AuthorizationServerSecurityConfigurer security) {
security.checkTokenAccess("isAuthenticated()");
}
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(tokenStore).tokenEnhancer(jwtTokenEnhancer).userApprovalHandler(userApprovalHandler)
.authenticationManager(authenticationManager);
}
}
共 (0) 个答案