Guest User

Untitled

a guest
Nov 26th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. curl http://localhost:9999/uaa/oauth/token -d grant_type=client_credentials -d username=user -d password=thepassword
  2.  
  3. Error: "Full authentication is required to access this resource"
  4.  
  5. (I assume this is because it is trying to do the basic authentication? How do I avoid that and use just credentials?)
  6.  
  7. @Configuration
  8. @EnableAuthorizationServer
  9. public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
  10.  
  11. @Autowired
  12. private AuthenticationManager authenticationManager;
  13.  
  14. @Bean
  15. @ConfigurationProperties(prefix = "spring.datasource_oauth")
  16. public DataSource oauthDataSource() {
  17. return DataSourceBuilder.create().build();
  18. }
  19.  
  20. @Bean
  21. public JdbcClientDetailsService clientDetailsService() {
  22. return new JdbcClientDetailsService(oauthDataSource());
  23. }
  24.  
  25. @Bean
  26. public TokenStore tokenStore() {
  27. return new JdbcTokenStore(oauthDataSource());
  28. }
  29.  
  30. @Bean
  31. public ApprovalStore approvalStore() {
  32. return new JdbcApprovalStore(oauthDataSource());
  33. }
  34.  
  35. @Bean
  36. public AuthorizationCodeServices authorizationCodeServices() {
  37. return new JdbcAuthorizationCodeServices(oauthDataSource());
  38. }
  39.  
  40. @Override
  41. public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
  42. clients.withClientDetails(clientDetailsService());
  43. }
  44.  
  45. @Override
  46. public void configure(AuthorizationServerSecurityConfigurer oauthServer) throws Exception {
  47. //oauthServer.allowFormAuthenticationForClients();
  48. }
  49.  
  50. @Override
  51. public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
  52. endpoints
  53. .approvalStore(approvalStore())
  54. .authorizationCodeServices(authorizationCodeServices())
  55. .authenticationManager(authenticationManager)
  56. .tokenStore(tokenStore());
  57. }
  58. }
  59.  
  60. @Configuration
  61. @EnableWebSecurity
  62. @EnableGlobalMethodSecurity(prePostEnabled = true)
  63. public class SecurityConfig extends WebSecurityConfigurerAdapter {
  64.  
  65. @Autowired
  66. UserDetailsService userDetailsService;
  67.  
  68. @Override
  69. protected void configure(HttpSecurity http) throws Exception {
  70. http
  71. .httpBasic().disable()
  72. .anonymous().disable()
  73. .authorizeRequests().anyRequest().authenticated();
  74. }
  75.  
  76. @Autowired
  77. public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
  78. auth.authenticationProvider(authProvider());
  79. }
  80.  
  81. @Bean
  82. public DaoAuthenticationProvider authProvider() {
  83. DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
  84. authProvider.setUserDetailsService(userDetailsService);
  85. authProvider.setPasswordEncoder(new EncryptionConfig());
  86. return authProvider;
  87. }
  88. }
  89.  
  90. "Full authentication is required to access this resource"
  91.  
  92. (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