I have a spring boot application with old spring oauth2 from 2.0
I migrate it to new spring-authorization-server compatible with spring 3.0.
Note: I have resource server and auth server with one spring app.
I i face a problem becouse some endpoints have custom authorization with endpoint.
Like this:
@Autowired
CustomAuthorziationMethod customAuthorziationMethod;
@GetMapping("/authenticate")
public String authenticate(String username, String password) {
customAuthorziationMethod.authenticate(username, password);
}
When i call AuthorizationServerContextHolder.getContext() it’s return null although my resource server and auth server is one aplication.
DefaultOAuth2TokenContext.Builder tokenContextBuilder = DefaultOAuth2TokenContext.builder()
.registeredClient(registeredClient)
.principal(usernamePasswordAuthenticationToken)
.authorizationServerContext(AuthorizationServerContextHolder.getContext())
.authorizedScopes(authorizedScopes)
.authorizationGrantType(customCodeGrantAuthentication.getGrantType())
.authorizationGrant(customCodeGrantAuthentication);
I there any way to keep default endpoint for login like:
@Bean
AuthorizationServerSettings authorizationServerSettings() {
return AuthorizationServerSettings.builder().
tokenEndpoint("/oauth2/token").
build();
}
And have some additional custom endpoints?
I tried translate this endpoint to rest template and call my api but also didn’t work