Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 오블완
- 리프레시토큰
- 국제화
- java
- oauth2
- 소셜로그인
- springdataredis
- springsecurity
- AWS
- CI/CD
- 데이터베이스
- docker
- githubactions
- 파이썬
- 백준
- 트랜잭션
- 토이프로젝트
- yaml-resource-bundle
- 스프링부트
- Spring
- 티스토리챌린지
- 메시지
- 재갱신
- 도커
- 액세스토큰
- JIRA
- springsecurityoauth2client
- 프로그래머스
- 스프링시큐리티
- 스프링
Archives
- Today
- Total
땃쥐네
[Spring Security] 스프링부트 시큐리티 의존성 추가로 일어나는 일들 본문
dependencies {
// spring security
implementation("org.springframework.boot:spring-boot-starter-security")
testImplementation("org.springframework.security:spring-security-test")
}
gradle의 경우 buiild.gradle 또는 build.gradle.kts
maven의 경우 pom.xml 파일에
스프링부트 시큐리티 의존성을 추가 해보면 여러가지 일들이 일어난다.
이를 가장 정확히 설명하는 문서는 스프링 시큐리티의 공식 문서의 getting-started - Runtime Expectations 단락에 있다.
여기선 간단하게 당장 개발하면서 체감할 수 있는 내용만 작성할 예정.
Using generated security password: 201aeffe-e657-4543-b787-0a35ea5f1800
This generated password is for development use only. Your security configuration must be updated before running your application in production.
- 서버가 기동되면 스프링 시큐리티의 초기화 작업 및 보안 설정이 이루어진다.
- 별도의 보안 설정, 구현을 하지 않아도 스프링 부트는 기본 필터를 적용하고, 모든 엔드포인트에 보안 기능이 적용된다.
- 모든 요청은 인증이 되어야 자원에 접근이 가능하다.
- 인증 방식으로는 Form 로그인 방식, HttpBasic 로그인 방식이 지원된다.
- 기본 로그인 페이지가 제공된다.
- 기본 계정이 하나 제공된다. (username: user / password : 콘솔에 출력되는 랜덤 문자열)
- 웹 브라우저를 통해 루트 페이지로 접근하면,
/login
으로 리다이렉트 된다. (기본 로그인 페이지)
$ curl -i localhost:8080
HTTP/1.1 401
Set-Cookie: JSESSIONID=0EF030C3ABB26D86ED4981C0E14F8E77; Path=/; HttpOnly
WWW-Authenticate: Basic realm="Realm"
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Frame-Options: DENY
WWW-Authenticate: Basic realm="Realm"
Content-Length: 0
Date: Sun, 09 Jul 2023 09:22:24 GMT
- curl 명령어를 통해 API 요청을 하면, 401 UnAuthorized 응답이 온다.
- 해당 엔드포인트로 들어오는 요청을 다루는 핸들러를 개발하지 않았음에도 말이다
참고자료
'Spring > Spring Security' 카테고리의 다른 글
[Spring Security] 컨트롤러에서 Authentication 파라미터 사용 (0) | 2024.06.12 |
---|---|
[Spring Security] 스프링 시큐리티와 코틀린 DSL (0) | 2024.03.09 |
Comments