Configuring the Authorization Server

The following OAuth2AuthorizationServerConfigurer will configure all the necessary filters required to run an Authorization Server:

@Configuration
@EnableAuthorizationServer
public class OAuth2AuthorizationServerConfigurer extends AuthorizationServerConfigurerAdapter {

@Autowired
private AuthenticationManager authenticationManagerBean;

@Override
public void configure(ClientDetailsServiceConfigurer clients)
throws Exception {
clients.inMemory().withClient("angularjsapp").secret("
{noop}angularjs123"
).authorizedGrantTypes("password").
scopes("read,write");
}

@Override
public void configure(AuthorizationServerEndpointsConfigurer
endpoints) throws Exception {
endpoints.authenticationManager(authenticationManagerBean);
}
}

The preceding configuration class extends from AuthorizationServerConfigurerAdapter and is annotated with @EnableAuthorizationServer to set up all the necessary filters. Also, in the configure(ClientDetailsServiceConfigurer clients) method, it configures in-memory OAuth2 client credentials for accessing the protected /oauth/token endpoint, and in the configure(AuthorizationServerEndpointsConfigurer endpoints) method, it configures AuthenticationManager, which is injected.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.110.183