Spring authorization and resource on same server

Viewed 1078

I am new to spring environment and i'm just learning oauth2. Is there a way to make the authorization server also a resource server? I am looking at this new project https://github.com/spring-projects/spring-authorization-server

Some steps or examples would be appreciated. The first problem i encountered when trying to implement this so was that the provider for the resource server was not up already. Thank you!

3 Answers

The OpenID Connect 1.0 UserInfo Endpoint is an example of using both roles (Authorization Server, Resource Server) in the same server. This is due to the fact that the access token obtained from the authorization server is used directly to authenticate a request for the UserInfo endpoint. As an aside, I'm curious what your use case is for doing this.

Take a look at this config for the UserInfo endpoint tests, which demonstrates how to do this. The main thing that makes this work is exposing a JwtDecoder as an @Bean and omitting the issuer-uri property from your Spring Boot application's configuration.

Oauth is just a standardized flow to grant access to resources. There is no problem in implementing in the same server. But as the application scales out, this approach is not very good.

After trying for a long time, I finally integrated the two on the same server, and made a simple page using angular as the front end.

Unfortunately, my English is not very good, so most of the words are in Chinese.

Here is the GitHub address: https://github.com/qq253498229/spring-boot-oauth2-example

Related