SecurityConfiguration.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the dreamlu.net developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: Chill 庄骞 (smallchill@163.com)
  16. */
  17. package org.springblade.auth.config;
  18. import lombok.AllArgsConstructor;
  19. import lombok.SneakyThrows;
  20. import org.springblade.auth.support.BladePasswordEncoderFactories;
  21. import org.springframework.context.annotation.Bean;
  22. import org.springframework.context.annotation.Configuration;
  23. import org.springframework.security.authentication.AuthenticationManager;
  24. import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  25. import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  26. import org.springframework.security.crypto.password.PasswordEncoder;
  27. /**
  28. * Security配置
  29. *
  30. * @author Chill
  31. */
  32. @Configuration
  33. @AllArgsConstructor
  34. public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
  35. @Bean
  36. @Override
  37. @SneakyThrows
  38. public AuthenticationManager authenticationManagerBean() {
  39. return super.authenticationManagerBean();
  40. }
  41. @Bean
  42. public PasswordEncoder passwordEncoder() {
  43. return BladePasswordEncoderFactories.createDelegatingPasswordEncoder();
  44. }
  45. @Override
  46. @SneakyThrows
  47. protected void configure(HttpSecurity http) {
  48. http.httpBasic().and().csrf().disable().authorizeRequests().anyRequest().fullyAuthenticated();
  49. }
  50. }