Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl http://localhost:9999/uaa/oauth/token -d grant_type=client_credentials -d username=user -d password=thepassword
- Error: "Full authentication is required to access this resource"
- (I assume this is because it is trying to do the basic authentication? How do I avoid that and use just credentials?)
- @Configuration
- @EnableAuthorizationServer
- public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
- @Autowired
- private AuthenticationManager authenticationManager;
- @Bean
- @ConfigurationProperties(prefix = "spring.datasource_oauth")
- public DataSource oauthDataSource() {
- return DataSourceBuilder.create().build();
- }
- @Bean
- public JdbcClientDetailsService clientDetailsService() {
- return new JdbcClientDetailsService(oauthDataSource());
- }
- @Bean
- public TokenStore tokenStore() {
- return new JdbcTokenStore(oauthDataSource());
- }
- @Bean
- public ApprovalStore approvalStore() {
- return new JdbcApprovalStore(oauthDataSource());
- }
- @Bean
- public AuthorizationCodeServices authorizationCodeServices() {
- return new JdbcAuthorizationCodeServices(oauthDataSource());
- }
- @Override
- public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
- clients.withClientDetails(clientDetailsService());
- }
- @Override
- public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
- //oauthServer.allowFormAuthenticationForClients();
- }
- @Override
- public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
- endpoints
- .approvalStore(approvalStore())
- .authorizationCodeServices(authorizationCodeServices())
- .authenticationManager(authenticationManager)
- .tokenStore(tokenStore());
- }
- }
- @Configuration
- @EnableWebSecurity
- @EnableGlobalMethodSecurity(prePostEnabled = true)
- public class SecurityConfig extends WebSecurityConfigurerAdapter {
- @Autowired
- UserDetailsService userDetailsService;
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http
- .httpBasic().disable()
- .anonymous().disable()
- .authorizeRequests().anyRequest().authenticated();
- }
- @Autowired
- public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
- auth.authenticationProvider(authProvider());
- }
- @Bean
- public DaoAuthenticationProvider authProvider() {
- DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
- authProvider.setUserDetailsService(userDetailsService);
- authProvider.setPasswordEncoder(new EncryptionConfig());
- return authProvider;
- }
- }
- "Full authentication is required to access this resource"
- (I assume this is because it is trying to do the basic authentication? How do I avoid that and use just credentials?)
Add Comment
Please, Sign In to add comment