Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.core.annotation.Order;
- import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
- import org.springframework.security.config.annotation.web.builders.HttpSecurity;
- import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
- import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
- @Configuration
- @Order(1)
- class SecurityConfig extends WebSecurityConfigurerAdapter {
- @Value("${user.oauth.user.username}")
- private String username;
- @Value("${user.oauth.user.password}")
- private String password;
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.requestMatchers()
- .antMatchers("/login", "/oauth/authorize")
- .and()
- .authorizeRequests()
- .anyRequest().authenticated()
- .and()
- .formLogin().permitAll();
- }
- @Override
- protected void configure(AuthenticationManagerBuilder auth) throws Exception {
- auth.inMemoryAuthentication()
- .withUser(username)
- .password(passwordEncoder().encode(password))
- .roles("USER");
- }
- @Bean
- public BCryptPasswordEncoder passwordEncoder() {
- return new BCryptPasswordEncoder();
- }
- }
- [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project auth-service: Compilation failure
- [ERROR] /home/mcs/auth-service/src/main/java/com/example/authservice/config/SecurityConfig.java:[14,1] cannot access javax.servlet.Filter
- [ERROR] class file for javax.servlet.Filter not found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement