package com.spring.security.spring.security.inmemoryauthentication.config;
import org.springframework.context.annotation.Configuration;
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.password.NoOpPasswordEncoder;
@Configuration
public class ProjectSecurityConfig extends WebSecurityConfigurerAdapter {
/**
*
* contact: Not Secure
* notice: Not Secure
* balance: Secure
* Card: Secure
* Loan: Secure
* Account: Secure
*
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/v1/accounts/**").authenticated()
.antMatchers("/v1/balance").authenticated()
.antMatchers("/v1/loan").authenticated()
.antMatchers("/v1/card").authenticated()
.antMatchers("/v1/contact").permitAll()
.antMatchers("/v1/notice").permitAll()
.and().formLogin()
.and().httpBasic();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("admin").password("12345").authorities("admin")
.and().withUser("user").password("12345").authorities("read")
.and().passwordEncoder(NoOpPasswordEncoder.getInstance());
}
}