SHARE
TWEET

Untitled

a guest Jun 25th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import org.springframework.beans.factory.annotation.Value;
  2. import org.springframework.context.annotation.Bean;
  3. import org.springframework.context.annotation.Configuration;
  4. import org.springframework.core.annotation.Order;
  5. import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  6. import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  7. import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  8. import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  9.  
  10. @Configuration
  11. @Order(1)
  12. class SecurityConfig extends WebSecurityConfigurerAdapter {
  13.  
  14.     @Value("${user.oauth.user.username}")
  15.     private String username;
  16.     @Value("${user.oauth.user.password}")
  17.     private String password;
  18.  
  19.     @Override
  20.     protected void configure(HttpSecurity http) throws Exception {
  21.         http.requestMatchers()
  22.                 .antMatchers("/login", "/oauth/authorize")
  23.                 .and()
  24.                 .authorizeRequests()
  25.                 .anyRequest().authenticated()
  26.                 .and()
  27.                 .formLogin().permitAll();
  28.     }
  29.  
  30.     @Override
  31.     protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  32.         auth.inMemoryAuthentication()
  33.                 .withUser(username)
  34.                 .password(passwordEncoder().encode(password))
  35.                 .roles("USER");
  36.     }
  37.  
  38.     @Bean
  39.     public BCryptPasswordEncoder passwordEncoder() {
  40.         return new BCryptPasswordEncoder();
  41.     }
  42. }
  43.      
  44. [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project auth-service: Compilation failure
  45. [ERROR] /home/mcs/auth-service/src/main/java/com/example/authservice/config/SecurityConfig.java:[14,1] cannot access javax.servlet.Filter
  46. [ERROR] class file for javax.servlet.Filter not found
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top