SlideShare a Scribd company logo
Next Generation
Spring Security OAuth 2.0
Spring Security OAuth 2.0 Contribution경험 공유
PaaS 이명현
오늘 이야기할 키워드
• Spring Security OAuth 2.0 로드 맵
• OAuth 2.0 Authorization Code Grant Flow
• Spring OAuth 2.0 support projects 비교
• Contribution 경험 공유
Spring OAuth 2.0 Support,
within the Spring projects portfolio
• spring-security-oauth
https://github.com/spring-projects/spring-security-oauth
• spring-security-oauth2-boot (support for spring boot 1.5.x)
https://github.com/spring-projects/spring-security-oauth2-boot
• spring-cloud-security
https://github.com/spring-cloud/spring-cloud-security
• spring-security
https://github.com/spring-projects/spring-security
• spring-social
https://github.com/spring-projects/spring-social
• spring-social
• 4 Main Projects
• 2 Incubator Projects
• 35 Community Projects
“Why has Spring Security 5 introduced new support into the mix?”
“Which project(s) do I use?”
• OAuth 2.0 지원을 하나의 프로젝트로 통합할 필요가 있다.
• OAuth 2.0 확장 스펙을 지원할 수 있어야 한다.
- OAuth2 Assertions (RFC-7521) , SAML2 Bearer Assertion (RFC-7522) , JWT Bearer Assertion (RFC-7523)
• OpenID Connect 1.0 / JOSE 스펙을 지원한다.
• 커뮤니티 피드백을 기반으로 사용 편의성을 개선한다.
• Documentation 을 자세히 제공할 필요가 있다.
Next Generation OAuth 2.0 Goal
• spring-security-oauth2-client : 5.0.0 (2017.11)
• spring-security-oauth2-jose : 5.0.0 (2017.11)
• spring-security-oauth2-resource-server : 5.1.0 (2018.09 예정)
• spring-security-oauth2-authorization-server: (2019 초 예정)
The Plan Forward
OAuth 2.0 Authorization Code Grant Flow
혹시 OAuth 2.0 Flow 를 모르시는 분들을 위해….
그림. Pivotal Documentation Single Sign-On
https://docs.pivotal.io/p-identity/1-6/configure-apps/web-app.html
그래서 뭐가 다른건데?
* spring-security-oauth
• spring-security-oauth
- OAuth 1.0 support
• spring-security-oauth2
- OAuth 2.0 support
- @EnableOAuth2Client
- @EnableAuthorizationServer
- @EnableResourceServer
• spring-security-jwt
- OAuth 2.0 JWT support
- Jwt, JwtAlgorithms, Sign, Encryption
* spring-security-oauth2-boot (support for spring boot 1.5.x)
+ Spring Boot properties base AutoConfiguration
+ @EnableOAuth2Sso
+ UserInfoTokenService
+ Spring Social support
+ Customizers
- JwtAccessTokenConverterRestTemplateCustomizer
- UserInfoRestTemplateCustomizer
- PrincipalExtractor
- AuthoritiesExtractor
* spring-cloud-security
+ AccessTokenContextRelay
+ OAuth2LoadBalancerClient (UserInfo)
+ OAuth2FeignRequestInterceptor
+ OAuth2TokenRelayFilter (ZuulFilter)
- proxy.auth.routes.{service-name}: oauth2 # OAuth2 인증 후 AccessToken 을 서비스에 전달
- proxy.auth.routes.{service-name}: passthru # Authorization header 를 그대로 서비스에 전달
- proxy.auth.routes.{service-name}: none # Authorization header 를 제거한 후 서비스에 전달
* OAuth2TokenRelayFilter
1. AccessToken
2. Authenticate / Refresh
3. AccessToken
proxy.auth.routes.{service-name}: oauth2
4. User Resource
1. AccessToken
3. Authenticate / Refresh
2. AccessToken
* OAuth2TokenRelayFilter
proxy.auth.routes.{service-name}: passthru
4. User Resource
* spring-social
• social API SDK 제공 (facebook, twitter, linkedin ..)
• 각 social 별 인증 방식 최적화 및 API 구현
• Spring Boot 1.5.x 에서 spring security oauth 와 연동
지원 (SpringSocialTokenServices)
• Projects in the Attic 으로 밀려나면서 업데이트 거의 없
음 (2017.11 이후 커밋 거의 없음)
• spring-social-facebook deprecated 된 버전 지원 중
Next Generation Spring Security OAuth 2.0
spring security 5.x
* spring-security 5.x oauth2 (client)
- multi tenant support
- registration 과 provider 의 설정 분리
* spring-security 5.x oauth2 (client)
- CommonOAuth2Provider
- GOOGLE, GITHUB, FACEBOOK, OKTA
* spring-security 5.x oauth2 (client)
- spring security fluent java config API
- more extensive configuration
* spring-security 5.x oauth2 (client, jose)
- OIDC (OpenID Connect 1.0) support / Okta
- Nimbus JOSE + JWT
- Nimbus OAuth 2.0 SDK
* spring-security 5.x oauth2 (resource-server 진행 중)
- BearerTokenAuthenticationFilter
- BearerTokenAuthenticationToken
- BearerTokenResolver
- JwtAuthenticationToken
- JwtAuthenticationProvider
* spring-security 5.x oauth2
- Spring Boot 2.x OAuth 2.0 기본 모듈로 지정
- Spring Web-Flux Reactive Support
Spring Security 5.x OAuth 2.0 으로 Migration 도전
1. spring-security-oauth 프로젝트는 maintenance mode 로 변경
2. spring-boot 2.x 에서 spring security 5.x oauth2를 기본 모듈로 지원
3. spring-security-oauth 에서 삽질 및 고생을 많이 함..
4. spring security 5.x oauth2 의 인터페이스 설계가 괜찮아 보임
왜?
spring-security-oauth 에 함께 고통 받고 있는 개발자들….
spring-security-oauth 에 고통 받는 이유
1. spring-security 도 어려운데 spring-security-oauth는 더 어려움
2. client, authorization-server, resource-server 의 설정 경계가 모호함
3. 어노테이션 기반의 설정은 기본적인 프로세스만 제공
4. 실제 서비스에서는 다양하고 복잡한 처리가 요구됨
5. 확장 포인트가 적절히 오픈 되어 있지 않다.
6. SSO, Customizer 등은 boot 프로젝트에 위치하고, 충분치 않음.
7. 결국 직접 상속/Override 하여, 재구성 (이럴바엔 직접 구현하는게 나을지도..)
spring security 5.0.0 oauth 2.0
1. client registration, provider 의 설정 구분이 명확함.
2. 확장이 필요한 기능 인터페이스와 Java Config 제공.
3. Redirect 와 Authentication프로세스가 분리 관리됨.
4. 디테일한 포인트에 확장이 아직 제공되지 않음.
5. 아직 구현되지 않은 Spec 이 많음.
6. AuthorizationServer, ResourceServer 는 아직 개발되지 않음.
7. 버그가 심심찮게 나옴
8. 개선했어도 어렵다. (spring security, OAuth 2.0 스펙 본연의 복잡함)
9. Migration 실패
5.1.0 적용 목표로 필요 기능 Contribution 하기
Contribution 1. Java Config NPE bug fix
- Java Config 에서 loginProcissingUrl 설정 시 NPE bug fix
https://github.com/spring-projects/spring-security/pull/5489
Contribution 2. OAuth2AccessToken serialize exception fix
- OAuth2AccessToken 을 serialize 할 때 exception 이 발생하는 bug fix
https://github.com/spring-projects/spring-security/pull/5493
Contribution 3. ClientRegistration scope can be null.
- ClientRegistration 설정 시 scope 이 null 값이 될 수 있도록 수정 (RFC-6749)
https://github.com/spring-projects/spring-security/pull/5495
Contribution 4/5. baseUrl exclude queryString
- RequestUri 기반으로 baseUrl 을 추출할 때 requestUri 에서 queryString 제거
https://github.com/spring-projects/spring-security/pull/5522
https://github.com/spring-projects/spring-security/pull/5559
Contribution 6. Polish Javadoc to remove warning
https://github.com/spring-projects/spring-security/pull/5505
Contribution 7. Authenticated Request Methods (RFC-6750)
https://github.com/spring-projects/spring-security/pull/5501
Contribution 8. spring boot configuration
https://github.com/spring-projects/spring-boot/pull/13865
Issue and Solution : Support X-Forwarded-* Header
https://github.com/spring-projects/spring-security/issues/5535
Issue and Solution : PrincipalExtractor for username
https://github.com/spring-projects/spring-security/issues/5526
Issue and Solution : OAuth2AuthorizationRequestResolver Customizer
https://github.com/spring-projects/spring-security/issues/5525
Reject but apply later :
Refactor OAuth2AuthorizationRequestResolver interface api
https://github.com/spring-projects/spring-security/issues/5554
Reject Apply later
- 5.1.0-SNAPSHOT 기준으로 마이그레이션 성공
- 5.1.0-RELEASE 발표되면, 운영 중인 실 서비스 전환 예정 (2018.09.21예정)
Spring 기반의 OAuth 2.0 구현을 준비한다면…
1. spring-social 은 선택하지 않기를 권장.
2. AuthorizationServer, ResourceServer 는 spring security 5.x 현재 미구현.
3. AuthorizationServer, ResourceServer 까지 구현/안정화되면전환을 권장.
4. spring security 5.1.0 에서 개선이 많이 됐기에, Client 모듈 적용도 괜찮을 듯.
5. GOOGLE, FACEBOOK 로그인은 간편 설정 연동 가능. (CommonOAuth2Provider)
6. 아직 과도기에 미구현 스펙(RFC)이 많기 때문에, Contribution 을 도전해볼 수 있음.
7. 어느것도 학습 비용이 높기 때문에, 직접 구현하는 것도 방법.
Appendix
Appendix. Web-Flux 지원으로 비슷한 코드가 2벌로 존재
- OAuth2AuthorizedClientService
- ReactiveOAuth2AuthorizedClientService
- OAuth2UserService
- ReactiveOAuth2UserService
- ClientRegistrationRepository
- ReactiveClientRegistrationRepository
- OidcUserService
- OidcReactiveOAuth2UserService
- OAuth2AccessTokenResponseClient
- ReactiveOAuth2AccessTokenResponseClient
Appendix. 상속보다 Composition 확장 선호
Appendix. 불변 객체 선호
- DefaultOAuth2AuthorizationRequestResolver
- OAuth2AuthorizationRequest
- OAuth2AuthorizationResponse
- OAuth2AccessTokenResponse
- OAuth2AccessToken
- OAuth2RefreshToken
- Jwt
-OAuth2UserRequest
-OidcUserService
-OidcUserRequest
-DefaultOAuth2User
-DefaultOidcUser
-OidcIdToken
-OidcUserInfo
-OAuth2AuthorizedClient
-OAuth2Error
Appendix. @RegisteredOAuth2AuthorizedClient (5.1.0)
끝

More Related Content

PDF
HAProxy TCP 모드에서 내부 서버로 Source IP 전달 방법
PPTX
라이브 서비스를 위한 게임 서버 구성
PDF
[야생의 땅: 듀랑고] 서버 아키텍처 - SPOF 없는 분산 MMORPG 서버
PDF
.NET最先端技術によるハイパフォーマンスウェブアプリケーション
PDF
Spring Cloud Workshop
PPTX
DeNA の AWS アカウント管理とセキュリティ監査自動化
PDF
Spring Boot の Web アプリケーションを Docker に載せて AWS ECS で動かしている話
PDF
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기
HAProxy TCP 모드에서 내부 서버로 Source IP 전달 방법
라이브 서비스를 위한 게임 서버 구성
[야생의 땅: 듀랑고] 서버 아키텍처 - SPOF 없는 분산 MMORPG 서버
.NET最先端技術によるハイパフォーマンスウェブアプリケーション
Spring Cloud Workshop
DeNA の AWS アカウント管理とセキュリティ監査自動化
Spring Boot の Web アプリケーションを Docker に載せて AWS ECS で動かしている話
[Spring Camp 2018] 11번가 Spring Cloud 기반 MSA로의 전환 : 지난 1년간의 이야기

What's hot (20)

PDF
WebRTCの技術解説 第二版 公開版 本編
PDF
우아한테크세미나-우아한멀티모듈
PDF
GKE に飛んでくるトラフィックを 自由自在に操る力 | 第 10 回 Google Cloud INSIDE Games & Apps Online
PDF
DockerとPodmanの比較
PDF
実運用して分かったRabbit MQの良いところ・気をつけること #jjug
PDF
VMware Cloud on AWS POC HCX デプロイガイド
PDF
Apache Kafka 0.11 の Exactly Once Semantics
PPTX
Web API: The Good Parts 落穂ひろい
PPTX
Prometheus 101
PPTX
RESTful API - Best Practices
PDF
[OPD 2019] Attacking JWT tokens
PDF
게임사를 위한 Amazon GameLift 세션 - 이정훈, AWS 솔루션즈 아키텍트
PDF
NoSQL 위에서 MMORPG 개발하기
PDF
Designing APIs with OpenAPI Spec
PPTX
初心者向けMongoDBのキホン!
PDF
Open Policy Agent
PDF
05. 마이크로서비스 아키텍처 환경에서의 SSO 구축방안
PDF
[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)
PDF
【BS14】Blazor WebAssemblyとJavaScriptのインターオペラビリティ
PDF
Javaのログ出力: 道具と考え方
WebRTCの技術解説 第二版 公開版 本編
우아한테크세미나-우아한멀티모듈
GKE に飛んでくるトラフィックを 自由自在に操る力 | 第 10 回 Google Cloud INSIDE Games & Apps Online
DockerとPodmanの比較
実運用して分かったRabbit MQの良いところ・気をつけること #jjug
VMware Cloud on AWS POC HCX デプロイガイド
Apache Kafka 0.11 の Exactly Once Semantics
Web API: The Good Parts 落穂ひろい
Prometheus 101
RESTful API - Best Practices
[OPD 2019] Attacking JWT tokens
게임사를 위한 Amazon GameLift 세션 - 이정훈, AWS 솔루션즈 아키텍트
NoSQL 위에서 MMORPG 개발하기
Designing APIs with OpenAPI Spec
初心者向けMongoDBのキホン!
Open Policy Agent
05. 마이크로서비스 아키텍처 환경에서의 SSO 구축방안
[야생의 땅: 듀랑고] 서버 아키텍처 Vol. 2 (자막)
【BS14】Blazor WebAssemblyとJavaScriptのインターオペラビリティ
Javaのログ出力: 道具と考え方
Ad

Similar to [네이버오픈소스세미나] Next Generation Spring Security OAuth2.0 - 이명현 (20)

PPTX
Spring one참석기 ksug
PDF
Meetup tools for-cloud_native_apps_meetup20180510-vs
PDF
[개방형 클라우드 플랫폼 오픈세미나 오픈클라우드 Pub] 3.open shift 분석
PDF
How to contribute at OpenStack
PDF
소셜 네트워크 앱 개발
PDF
Spring Boot 기초 코드랩 (2019-10-26)
PDF
Private PaaS with Docker, spring cloud and mesos
PPTX
2022.08 멘토링 자료.pptx
PDF
DevOps - CI/CD 알아보기
PPTX
Atlassian JIRA Plugin 및 REST API를 이용한 기능 확장
PDF
Deview 2013 :: Backend PaaS, CloudFoundry 뽀개기
PPTX
Spring Project와 최신 Pivotal Cloud Foundry 업데이트
PDF
Internship backend
PDF
텔레그램을 이용한 양방향 모니터링 시스템 구축
PPTX
Pivotal Cloud Foundry(PCF) 2.0 and Pivotal Container Service ( PKS ) 신혜원
PPTX
[MeetUp][3rd] Prometheus 와 함께하는 모니터링 및 시각화
PDF
okspring3x
PPTX
Cms All 091103
PPTX
Open standard open cloud engine (3)
PPTX
Spring boot DI
Spring one참석기 ksug
Meetup tools for-cloud_native_apps_meetup20180510-vs
[개방형 클라우드 플랫폼 오픈세미나 오픈클라우드 Pub] 3.open shift 분석
How to contribute at OpenStack
소셜 네트워크 앱 개발
Spring Boot 기초 코드랩 (2019-10-26)
Private PaaS with Docker, spring cloud and mesos
2022.08 멘토링 자료.pptx
DevOps - CI/CD 알아보기
Atlassian JIRA Plugin 및 REST API를 이용한 기능 확장
Deview 2013 :: Backend PaaS, CloudFoundry 뽀개기
Spring Project와 최신 Pivotal Cloud Foundry 업데이트
Internship backend
텔레그램을 이용한 양방향 모니터링 시스템 구축
Pivotal Cloud Foundry(PCF) 2.0 and Pivotal Container Service ( PKS ) 신혜원
[MeetUp][3rd] Prometheus 와 함께하는 모니터링 및 시각화
okspring3x
Cms All 091103
Open standard open cloud engine (3)
Spring boot DI
Ad

More from NAVER Engineering (20)

PDF
React vac pattern
PDF
디자인 시스템에 직방 ZUIX
PDF
진화하는 디자인 시스템(걸음마 편)
PDF
서비스 운영을 위한 디자인시스템 프로젝트
PDF
BPL(Banksalad Product Language) 무야호
PDF
이번 생에 디자인 시스템은 처음이라
PDF
날고 있는 여러 비행기 넘나 들며 정비하기
PDF
쏘카프레임 구축 배경과 과정
PDF
플랫폼 디자이너 없이 디자인 시스템을 구축하는 프로덕트 디자이너의 우당탕탕 고통 연대기
PDF
200820 NAVER TECH CONCERT 15_Code Review is Horse(코드리뷰는 말이야)(feat.Latte)
PDF
200819 NAVER TECH CONCERT 03_화려한 코루틴이 내 앱을 감싸네! 코루틴으로 작성해보는 깔끔한 비동기 코드
PDF
200819 NAVER TECH CONCERT 10_맥북에서도 아이맥프로에서 빌드하는 것처럼 빌드 속도 빠르게 하기
PDF
200819 NAVER TECH CONCERT 08_성능을 고민하는 슬기로운 개발자 생활
PDF
200819 NAVER TECH CONCERT 05_모르면 손해보는 Android 디버깅/분석 꿀팁 대방출
PDF
200819 NAVER TECH CONCERT 09_Case.xcodeproj - 좋은 동료로 거듭나기 위한 노하우
PDF
200820 NAVER TECH CONCERT 14_야 너두 할 수 있어. 비전공자, COBOL 개발자를 거쳐 네이버에서 FE 개발하게 된...
PDF
200820 NAVER TECH CONCERT 13_네이버에서 오픈 소스 개발을 통해 성장하는 방법
PDF
200820 NAVER TECH CONCERT 12_상반기 네이버 인턴을 돌아보며
PDF
200820 NAVER TECH CONCERT 11_빠르게 성장하는 슈퍼루키로 거듭나기
PDF
200819 NAVER TECH CONCERT 07_신입 iOS 개발자 개발업무 적응기
React vac pattern
디자인 시스템에 직방 ZUIX
진화하는 디자인 시스템(걸음마 편)
서비스 운영을 위한 디자인시스템 프로젝트
BPL(Banksalad Product Language) 무야호
이번 생에 디자인 시스템은 처음이라
날고 있는 여러 비행기 넘나 들며 정비하기
쏘카프레임 구축 배경과 과정
플랫폼 디자이너 없이 디자인 시스템을 구축하는 프로덕트 디자이너의 우당탕탕 고통 연대기
200820 NAVER TECH CONCERT 15_Code Review is Horse(코드리뷰는 말이야)(feat.Latte)
200819 NAVER TECH CONCERT 03_화려한 코루틴이 내 앱을 감싸네! 코루틴으로 작성해보는 깔끔한 비동기 코드
200819 NAVER TECH CONCERT 10_맥북에서도 아이맥프로에서 빌드하는 것처럼 빌드 속도 빠르게 하기
200819 NAVER TECH CONCERT 08_성능을 고민하는 슬기로운 개발자 생활
200819 NAVER TECH CONCERT 05_모르면 손해보는 Android 디버깅/분석 꿀팁 대방출
200819 NAVER TECH CONCERT 09_Case.xcodeproj - 좋은 동료로 거듭나기 위한 노하우
200820 NAVER TECH CONCERT 14_야 너두 할 수 있어. 비전공자, COBOL 개발자를 거쳐 네이버에서 FE 개발하게 된...
200820 NAVER TECH CONCERT 13_네이버에서 오픈 소스 개발을 통해 성장하는 방법
200820 NAVER TECH CONCERT 12_상반기 네이버 인턴을 돌아보며
200820 NAVER TECH CONCERT 11_빠르게 성장하는 슈퍼루키로 거듭나기
200819 NAVER TECH CONCERT 07_신입 iOS 개발자 개발업무 적응기

[네이버오픈소스세미나] Next Generation Spring Security OAuth2.0 - 이명현

  • 1. Next Generation Spring Security OAuth 2.0 Spring Security OAuth 2.0 Contribution경험 공유 PaaS 이명현
  • 2. 오늘 이야기할 키워드 • Spring Security OAuth 2.0 로드 맵 • OAuth 2.0 Authorization Code Grant Flow • Spring OAuth 2.0 support projects 비교 • Contribution 경험 공유
  • 3. Spring OAuth 2.0 Support, within the Spring projects portfolio
  • 4. • spring-security-oauth https://github.com/spring-projects/spring-security-oauth • spring-security-oauth2-boot (support for spring boot 1.5.x) https://github.com/spring-projects/spring-security-oauth2-boot • spring-cloud-security https://github.com/spring-cloud/spring-cloud-security • spring-security https://github.com/spring-projects/spring-security • spring-social https://github.com/spring-projects/spring-social
  • 5. • spring-social • 4 Main Projects • 2 Incubator Projects • 35 Community Projects
  • 6. “Why has Spring Security 5 introduced new support into the mix?” “Which project(s) do I use?”
  • 7. • OAuth 2.0 지원을 하나의 프로젝트로 통합할 필요가 있다. • OAuth 2.0 확장 스펙을 지원할 수 있어야 한다. - OAuth2 Assertions (RFC-7521) , SAML2 Bearer Assertion (RFC-7522) , JWT Bearer Assertion (RFC-7523) • OpenID Connect 1.0 / JOSE 스펙을 지원한다. • 커뮤니티 피드백을 기반으로 사용 편의성을 개선한다. • Documentation 을 자세히 제공할 필요가 있다. Next Generation OAuth 2.0 Goal
  • 8. • spring-security-oauth2-client : 5.0.0 (2017.11) • spring-security-oauth2-jose : 5.0.0 (2017.11) • spring-security-oauth2-resource-server : 5.1.0 (2018.09 예정) • spring-security-oauth2-authorization-server: (2019 초 예정) The Plan Forward
  • 9. OAuth 2.0 Authorization Code Grant Flow 혹시 OAuth 2.0 Flow 를 모르시는 분들을 위해….
  • 10. 그림. Pivotal Documentation Single Sign-On https://docs.pivotal.io/p-identity/1-6/configure-apps/web-app.html
  • 12. * spring-security-oauth • spring-security-oauth - OAuth 1.0 support • spring-security-oauth2 - OAuth 2.0 support - @EnableOAuth2Client - @EnableAuthorizationServer - @EnableResourceServer • spring-security-jwt - OAuth 2.0 JWT support - Jwt, JwtAlgorithms, Sign, Encryption
  • 13. * spring-security-oauth2-boot (support for spring boot 1.5.x) + Spring Boot properties base AutoConfiguration + @EnableOAuth2Sso + UserInfoTokenService + Spring Social support + Customizers - JwtAccessTokenConverterRestTemplateCustomizer - UserInfoRestTemplateCustomizer - PrincipalExtractor - AuthoritiesExtractor
  • 14. * spring-cloud-security + AccessTokenContextRelay + OAuth2LoadBalancerClient (UserInfo) + OAuth2FeignRequestInterceptor + OAuth2TokenRelayFilter (ZuulFilter) - proxy.auth.routes.{service-name}: oauth2 # OAuth2 인증 후 AccessToken 을 서비스에 전달 - proxy.auth.routes.{service-name}: passthru # Authorization header 를 그대로 서비스에 전달 - proxy.auth.routes.{service-name}: none # Authorization header 를 제거한 후 서비스에 전달
  • 15. * OAuth2TokenRelayFilter 1. AccessToken 2. Authenticate / Refresh 3. AccessToken proxy.auth.routes.{service-name}: oauth2 4. User Resource
  • 16. 1. AccessToken 3. Authenticate / Refresh 2. AccessToken * OAuth2TokenRelayFilter proxy.auth.routes.{service-name}: passthru 4. User Resource
  • 17. * spring-social • social API SDK 제공 (facebook, twitter, linkedin ..) • 각 social 별 인증 방식 최적화 및 API 구현 • Spring Boot 1.5.x 에서 spring security oauth 와 연동 지원 (SpringSocialTokenServices) • Projects in the Attic 으로 밀려나면서 업데이트 거의 없 음 (2017.11 이후 커밋 거의 없음) • spring-social-facebook deprecated 된 버전 지원 중
  • 18. Next Generation Spring Security OAuth 2.0 spring security 5.x
  • 19. * spring-security 5.x oauth2 (client) - multi tenant support - registration 과 provider 의 설정 분리
  • 20. * spring-security 5.x oauth2 (client) - CommonOAuth2Provider - GOOGLE, GITHUB, FACEBOOK, OKTA
  • 21. * spring-security 5.x oauth2 (client) - spring security fluent java config API - more extensive configuration
  • 22. * spring-security 5.x oauth2 (client, jose) - OIDC (OpenID Connect 1.0) support / Okta - Nimbus JOSE + JWT - Nimbus OAuth 2.0 SDK
  • 23. * spring-security 5.x oauth2 (resource-server 진행 중) - BearerTokenAuthenticationFilter - BearerTokenAuthenticationToken - BearerTokenResolver - JwtAuthenticationToken - JwtAuthenticationProvider
  • 24. * spring-security 5.x oauth2 - Spring Boot 2.x OAuth 2.0 기본 모듈로 지정 - Spring Web-Flux Reactive Support
  • 25. Spring Security 5.x OAuth 2.0 으로 Migration 도전
  • 26. 1. spring-security-oauth 프로젝트는 maintenance mode 로 변경 2. spring-boot 2.x 에서 spring security 5.x oauth2를 기본 모듈로 지원 3. spring-security-oauth 에서 삽질 및 고생을 많이 함.. 4. spring security 5.x oauth2 의 인터페이스 설계가 괜찮아 보임 왜?
  • 27. spring-security-oauth 에 함께 고통 받고 있는 개발자들….
  • 28. spring-security-oauth 에 고통 받는 이유 1. spring-security 도 어려운데 spring-security-oauth는 더 어려움 2. client, authorization-server, resource-server 의 설정 경계가 모호함 3. 어노테이션 기반의 설정은 기본적인 프로세스만 제공 4. 실제 서비스에서는 다양하고 복잡한 처리가 요구됨 5. 확장 포인트가 적절히 오픈 되어 있지 않다. 6. SSO, Customizer 등은 boot 프로젝트에 위치하고, 충분치 않음. 7. 결국 직접 상속/Override 하여, 재구성 (이럴바엔 직접 구현하는게 나을지도..)
  • 29. spring security 5.0.0 oauth 2.0 1. client registration, provider 의 설정 구분이 명확함. 2. 확장이 필요한 기능 인터페이스와 Java Config 제공. 3. Redirect 와 Authentication프로세스가 분리 관리됨. 4. 디테일한 포인트에 확장이 아직 제공되지 않음. 5. 아직 구현되지 않은 Spec 이 많음. 6. AuthorizationServer, ResourceServer 는 아직 개발되지 않음. 7. 버그가 심심찮게 나옴 8. 개선했어도 어렵다. (spring security, OAuth 2.0 스펙 본연의 복잡함) 9. Migration 실패
  • 30. 5.1.0 적용 목표로 필요 기능 Contribution 하기
  • 31. Contribution 1. Java Config NPE bug fix - Java Config 에서 loginProcissingUrl 설정 시 NPE bug fix https://github.com/spring-projects/spring-security/pull/5489
  • 32. Contribution 2. OAuth2AccessToken serialize exception fix - OAuth2AccessToken 을 serialize 할 때 exception 이 발생하는 bug fix https://github.com/spring-projects/spring-security/pull/5493
  • 33. Contribution 3. ClientRegistration scope can be null. - ClientRegistration 설정 시 scope 이 null 값이 될 수 있도록 수정 (RFC-6749) https://github.com/spring-projects/spring-security/pull/5495
  • 34. Contribution 4/5. baseUrl exclude queryString - RequestUri 기반으로 baseUrl 을 추출할 때 requestUri 에서 queryString 제거 https://github.com/spring-projects/spring-security/pull/5522 https://github.com/spring-projects/spring-security/pull/5559
  • 35. Contribution 6. Polish Javadoc to remove warning https://github.com/spring-projects/spring-security/pull/5505
  • 36. Contribution 7. Authenticated Request Methods (RFC-6750) https://github.com/spring-projects/spring-security/pull/5501
  • 37. Contribution 8. spring boot configuration https://github.com/spring-projects/spring-boot/pull/13865
  • 38. Issue and Solution : Support X-Forwarded-* Header https://github.com/spring-projects/spring-security/issues/5535
  • 39. Issue and Solution : PrincipalExtractor for username https://github.com/spring-projects/spring-security/issues/5526
  • 40. Issue and Solution : OAuth2AuthorizationRequestResolver Customizer https://github.com/spring-projects/spring-security/issues/5525
  • 41. Reject but apply later : Refactor OAuth2AuthorizationRequestResolver interface api https://github.com/spring-projects/spring-security/issues/5554 Reject Apply later
  • 42. - 5.1.0-SNAPSHOT 기준으로 마이그레이션 성공 - 5.1.0-RELEASE 발표되면, 운영 중인 실 서비스 전환 예정 (2018.09.21예정)
  • 43. Spring 기반의 OAuth 2.0 구현을 준비한다면… 1. spring-social 은 선택하지 않기를 권장. 2. AuthorizationServer, ResourceServer 는 spring security 5.x 현재 미구현. 3. AuthorizationServer, ResourceServer 까지 구현/안정화되면전환을 권장. 4. spring security 5.1.0 에서 개선이 많이 됐기에, Client 모듈 적용도 괜찮을 듯. 5. GOOGLE, FACEBOOK 로그인은 간편 설정 연동 가능. (CommonOAuth2Provider) 6. 아직 과도기에 미구현 스펙(RFC)이 많기 때문에, Contribution 을 도전해볼 수 있음. 7. 어느것도 학습 비용이 높기 때문에, 직접 구현하는 것도 방법.
  • 45. Appendix. Web-Flux 지원으로 비슷한 코드가 2벌로 존재 - OAuth2AuthorizedClientService - ReactiveOAuth2AuthorizedClientService - OAuth2UserService - ReactiveOAuth2UserService - ClientRegistrationRepository - ReactiveClientRegistrationRepository - OidcUserService - OidcReactiveOAuth2UserService - OAuth2AccessTokenResponseClient - ReactiveOAuth2AccessTokenResponseClient
  • 47. Appendix. 불변 객체 선호 - DefaultOAuth2AuthorizationRequestResolver - OAuth2AuthorizationRequest - OAuth2AuthorizationResponse - OAuth2AccessTokenResponse - OAuth2AccessToken - OAuth2RefreshToken - Jwt -OAuth2UserRequest -OidcUserService -OidcUserRequest -DefaultOAuth2User -DefaultOidcUser -OidcIdToken -OidcUserInfo -OAuth2AuthorizedClient -OAuth2Error
  • 49.