Spring Security

    로그인 실패시 Failure Handler

    securityConfig.java private final AuthenticationFailureHandler customAuthFailureHandler; @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.authorizeRequests() .antMatchers("/","/user/**","/image/**","/subscribe/**","/comment/**","/api/**").authenticated() .anyRequest().permitAll() .and() .formLogin()//위에있는 url말고 다른곳에 들어갈 경우 loginPage로 redirect시킴..

    aAuth2 client를 통해 facebook 로그인하기

    1 . 환경설정 POM.XML 을 다음과 같이 설정해줍니다. org.springframework.boot spring-boot-starter-oauth2-client application.yml에 다음과 같이 설정한다. oauth2: client: registration: facebook: client-id: facebook에서 받은 id client-secret: facebook에서 받은 시크릿키 scope: - public_profile # 회사마다 다름 - email 2. SecurtyConfig.java @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.authoriz..

    Spring Security CSRF

    CSRF Cross site Request forgery로 사이즈간 위조 요청인데, 즉 정상적인 사용자가 의도치 않은 위조요청을 보내는 것을 의미한다. 예를 들어 A라는 도메인에서, 인증된 사용자 H가 위조된 request를 포함한 link, email을 사용하였을 경우(클릭, 또는 사이트 방문만으로도), A 도메인에서는 이 사용자가 일반 유저인지, 악용된 공격인지 구분할 수가 없다. CSRF protection은 spring security에서 default로 설정된다. 즉, protection을 통해 GET요청을 제외한 상태를 변화시킬 수 있는 POST, PUT, DELETE 요청으로부터 보호한다. csrf protection을 적용하였을 때, html에서 다음과 같은 csrf 토큰이 포함되어야 요청..