Thus, DefaultAuthenticationKeyGeneration uses client_id and scope to create a key and, if it matches the request for the token, it serves the previously generated token. So in your case you can have ios, android and device id for areas.
Here is my code
@Configuration @EnableAuthorizationServer protected static class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter { ..... @Override public void configure(ClientDetailsServiceConfigurer clients) { clients.inMemory() .withClient("my-trusted-client-with-secret") .authorizedGrantTypes("client_credentials") .authorities("ROLE_CLIENT", "ROLE_TRUSTED_CLIENT")
tests
» curl -H "Accept: application/json" my-trusted-client-with-secret: somesecret@localhost :8080/auth/oauth/token -d grant_type=client_credentials -d custid=1 -d siteid=2D -d scope="y" {"access_token":"cust:site1:2D","token_type":"bearer","expires_in":3282,"scope":"y"}% » curl -H "Accept: application/json" my-trusted-client-with-secret: somesecret@localhost :8080/auth/oauth/token -d grant_type=client_credentials -d custid=1 -d siteid=3D -d scope="z" {"access_token":"cust:site1:3D","token_type":"bearer","expires_in":3290,"scope":"z"}% » curl -H "Authorization: Bearer cust:site:3D" http://localhost:8080/dtn-auth/home {"error":"invalid_token","error_description":"Invalid access token: cust:site:3D"}% » curl -H "Authorization: Bearer cust:site1:3D" http://localhost:8080/dtn-auth/home Hello World% » curl -H "Authorization: Bearer cust:site1:2D" http://localhost:8080/dtn-auth/home Hello World%
As you can see, I was able to generate several tokens for the same client_id, and both of these tokens were authenticated to access the resource from the resource server.
source share