Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oauth 2.0 - Single resource server but multiple client applications

Greeting,

I wanted to ask if following is a valid use case for Oauth 2.0:

  1. Authorization server (separate)
  2. Single (or multiple) resource servers
  3. Multiple client applications accessing same resource server.

Diagram for scenario in question

If this is a valid use case, how can we configure multiple clients with Authorization server. Not able to configure using application.properties ( application.yml).

security.oauth2.client.client-id=dummy
security.oauth2.client.client-secret=password

or

security:
  oauth2:
    resource:
      token-info-uri: http://localhost:8080/oauth/check_token
    client:
      client-id: dummy
      client-secret: password

What is the correct configuration for multiple client application in such scenarios?

like image 351
Parik Avatar asked Oct 29 '25 12:10

Parik


1 Answers

so if you have multiple client, you can register client detail in AuthorizationServer by extend AuthorizationServerConfigurerAdapter

the following is the example how you register client detail in memory:

@EnableAuthorizationServer
@Configuration
public class AuthServerConfig extends AuthorizationServerConfigurerAdapter {
    private final AuthenticationManager authenticationManager;

    @Autowired
    public AuthServerConfig(AuthenticationManager authenticationManager) {
        this.authenticationManager = authenticationManager;
    }

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory()
                .withClient("egen")
                .secret("{noop}egensecret")
                .authorizedGrantTypes("authorization_code","refresh_token","password")
                .scopes("food_read","food_write")
            .and()
                .withClient("oauthclient")
                .secret("{noop}oauthclient-secret")
                .authorizedGrantTypes("client_credentials", "refresh_token")
                .authorities("ROLE_USER", "ROLE_OPERATOR")
                .scopes("food_read");
    }
///more code
}

for more detail, you can take a look at my github repo:

https://github.com/Dovchiproeng/spring-cloud-security-oauth2-poc/blob/master/spring-cloud-secure-auth-server/src/main/java/com/egen/springcloudsecureauthserver/config/AuthServerConfig.java

like image 176
Chi Dov Avatar answered Oct 31 '25 02:10

Chi Dov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!