Guest User

Untitled

a guest
Apr 1st, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. @Override
  2. protected void configure(HttpSecurity http) throws Exception {
  3. http
  4. .csrf()
  5. .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
  6. .and()
  7. .addFilterBefore(corsFilter, CsrfFilter.class)
  8. .exceptionHandling()
  9. .authenticationEntryPoint(problemSupport)
  10. .accessDeniedHandler(problemSupport)
  11. .and()
  12. .rememberMe()
  13. .rememberMeServices(rememberMeServices)
  14. .rememberMeParameter("remember-me")
  15. .key(jHipsterProperties.getSecurity().getRememberMe().getKey())
  16. .and()
  17. .formLogin()
  18. .loginProcessingUrl("/api/authentication")
  19. .successHandler(ajaxAuthenticationSuccessHandler())
  20. .failureHandler(ajaxAuthenticationFailureHandler())
  21. .usernameParameter("j_username")
  22. .passwordParameter("j_password")
  23. .permitAll()
  24. .and()
  25. .logout()
  26. .logoutUrl("/api/logout")
  27. .logoutSuccessHandler(ajaxLogoutSuccessHandler())
  28. .permitAll()
  29. .and()
  30. .headers()
  31. .frameOptions()
  32. .disable()
  33. .and()
  34. .authorizeRequests()
  35. .antMatchers("/api/register").permitAll()
  36. .antMatchers("/api/activate").permitAll()
  37. .antMatchers("/api/authenticate").permitAll()
  38. .antMatchers("/api/account/reset-password/init").permitAll()
  39. .antMatchers("/api/account/reset-password/finish").permitAll()
  40. .antMatchers("/api/profile-info").permitAll()
  41. .antMatchers(org.springframework.http.HttpMethod.OPTIONS, "/api/**").permitAll()
  42. .antMatchers("/api/**").authenticated()
  43. .antMatchers("/api/**").fullyAuthenticated()
  44. .antMatchers("/management/health").permitAll()
  45. .antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
  46. .antMatchers("/v2/api-docs/**").permitAll()
  47. .antMatchers("/swagger-resources/configuration/ui").permitAll()
  48. .antMatchers("/swagger-ui/index.html").hasAuthority(AuthoritiesConstants.ADMIN);
  49.  
  50. }
  51.  
  52. login(credentials): Observable<any> {
  53. const data = 'j_username=' + encodeURIComponent(credentials.username) +
  54. '&j_password=' + encodeURIComponent(credentials.password) +
  55. '&remember-me=' + credentials.rememberMe + '&submit=Login';
  56. const headers = new Headers ({
  57. 'Content-Type': 'application/x-www-form-urlencoded'
  58. });
  59.  
  60. return this.http.post(SERVER_API_URL + 'api/authentication', data, { headers });
  61. }
  62.  
  63. cors:
  64. allowed-origins: "*"
  65. allowed-methods: "*"
  66. allowed-headers: "*"
  67. exposed-headers: "Link,X-Total-Count"
  68. allow-credentials: true
  69. max-age: 1800
Add Comment
Please, Sign In to add comment