JAVA&Spring/Settting

SecurityConfig

2023. 6. 27. 14:41
목차
  1. 스프링 부트 2.7  

스프링 부트 2.7  

@Configuration
public class SecurityConfig {

    @Bean
    public SecurityFilterChain securityFilterChain(
            HttpSecurity http,
            OAuth2UserService<OAuth2UserRequest, OAuth2User> oAuth2UserService
    ) throws Exception {
        return http
                .authorizeHttpRequests(auth -> auth
                        .requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
                        .mvcMatchers("/api/**").permitAll()
                        .mvcMatchers(
                                HttpMethod.GET,
                                "/",
                                "/articles",
                                "/articles/search-hashtag"
                        ).permitAll()
                        .anyRequest().authenticated()
                )
                .formLogin(withDefaults())
                .logout(logout -> logout.logoutSuccessUrl("/"))
                .oauth2Login(oAuth -> oAuth
                        .userInfoEndpoint(userInfo -> userInfo
                                .userService(oAuth2UserService)
                        )
                )
                .csrf(csrf -> csrf.ignoringAntMatchers("/api/**"))
                .build();
    }

https://docs.spring.io/spring-security/reference/servlet/oauth2/login/advanced.html#oauth2login-advanced-login-page

 

Advanced Configuration :: Spring Security

By default, the OAuth 2.0 Login Page is auto-generated by the DefaultLoginPageGeneratingFilter. The default login page shows each configured OAuth Client with its ClientRegistration.clientName as a link, which is capable of initiating the Authorization Req

docs.spring.io

https://www.thymeleaf.org/doc/articles/springsecurity.html

 

Thymeleaf + Spring Security integration basics - Thymeleaf

Have you switched to Thymeleaf but your login and error pages are still using JSP? In this article we will see how to configure your Spring application to use Thymeleaf for login and error pages. All the code seen here comes from a working application. You

www.thymeleaf.org

 

저작자표시 (새창열림)

'JAVA&Spring > Settting' 카테고리의 다른 글

Thymeleaf setting decoupledLogic(spring 6.0.9 + thymeleaf4)  (0) 2023.06.20
qusydsl gradle 설정  (0) 2023.05.27
  1. 스프링 부트 2.7  
'JAVA&Spring/Settting' 카테고리의 다른 글
  • Thymeleaf setting decoupledLogic(spring 6.0.9 + thymeleaf4)
  • qusydsl gradle 설정
가끔개발
가끔개발
가끔개발
가끔쓰는개발블로그
가끔개발
전체
오늘
어제
  • 분류 전체보기 (75)
    • 오류모음집 (8)
      • Ohouse버그 (6)
    • 포트폴리오 (14)
      • ohouseClone (12)
    • JAVA&Spring (4)
      • Settting (3)
    • Back-end (4)
    • 알고리즘 문제 (20)
      • 이론 (6)
      • DFS&BFS (2)
      • 이진탐색 (1)
      • 다이나믹 프로그래밍 (0)
      • 프로그래머스 (11)
    • 개발 잡동산이 (0)
    • 취업 준비 (19)
      • 실전 JPA (15)
    • 개발 꿀팁 (6)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • CS
  • 취준생
  • 취준
  • 이것이 코딩 테스트이다
  • 개발자
  • 동빈나
  • 면접
  • 자바
  • intellj
  • programing
  • 신입
  • Spring
  • 기술면접
  • 백엔드
  • java

최근 댓글

최근 글

hELLO · Designed By 정상우.
가끔개발
SecurityConfig
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.