๐Ÿฅ•
TIL
  • [TIL] Studying tech / computer science knowledge
  • KeyMap
  • ์•Œ๊ณ ๋ฆฌ์ฆ˜
    • ๋ณต์žก๋„ ๊ณ„์‚ฐ ( Computational Complexity )
    • DisjointSet-unionFind
    • Bellman-ford Algorithm
    • Dijkstra's Algorithm
    • DP ( Dynamic Programming , ๋™์  ๊ณ„ํš๋ฒ• )
    • ํ”Œ๋กœ์ด๋“œ-์›Œ์…œ ์•Œ๊ณ ๋ฆฌ์ฆ˜ (Floyd-Warshall algorithm)
    • Kruskal's Algorithm
    • ์ตœ์žฅ ์ฆ๊ฐ€ ์ˆ˜์—ด (Longes Increasing Subsequence)
    • Prim's Algorithm
    • ์ •๋ ฌ
    • ์‹œ๊ฐ„๋ณต์žก๋„ ์™€ ๊ณต๊ฐ„๋ณต์žก๋„ ( Time Complexity & Space Complexity )
    • Topological Sort (์œ„์ƒ ์ •๋ ฌ)
  • ์ฑ… ์ฝ๊ณ ๋‚œ ํ›„ ์š”์•ฝ
    • ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋Œ€ํšŒ์—์„œ ๋ฐฐ์šฐ๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œํ•ด๊ฒฐ ์ „๋žต
    • cleancode
    • ๋„๋ฉ”์ธ ์ฃผ๋„ ์„ค๊ณ„๋กœ ์‹œ์ž‘ํ•˜๋Š” ๋งˆ์ดํฌ๋กœ์„œ๋น„์Šค ๊ฐœ๋ฐœ
    • ์˜ค๋ธŒ์ ํŠธ
  • CDC
    • debzium
    • kafka
  • ๊ฐœ๋ฐœ ์ƒ์‹
    • asciidoctor
    • ์ปดํŒŒ์ผ๋Ÿฌ
    • ELK ์Šคํƒ
    • ์—”๋””์•ˆ
    • git
    • Gitmoji
    • ํ…Œ์ŠคํŠธ ์ข…๋ฅ˜
    • ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ ํ”„๋ ˆ์ž„์›Œํฌ
    • ์ •๊ทœ ํ‘œํ˜„์‹
    • REST API
    • ๋™๊ธฐ์™€ ๋น„๋™๊ธฐ / Blocking๊ณผ NonBlocking
    • Transaction Script์™€ Domain Model
    • ๋””์ž์ธ ํŒจํ„ด
      • ํ–‰๋™ ํŒจํ„ด
      • ๊ฐ์ฒด ์ƒ์„ฑ ํŒจํ„ด
        • ์ถ”์ƒ ํŒฉํ† ๋ฆฌ ํŒจํ„ด
        • ๋นŒ๋” ํŒจํ„ด
        • ํŒฉํ† ๋ฆฌ ๋ฉ”์„œ๋“œ ํŒจํ„ด
        • [์ƒ์„ฑ ํŒจํ„ด] ํ”„๋กœํ†  ํƒ€์ž… (Prototype Parttern)
        • ์‹ฑ๊ธ€ํ†ค
      • ๊ตฌ์กฐ ํŒจํ„ด
        • ์–ด๋Œ‘ํ„ฐ ํŒจํ„ด
        • ๋ธŒ๋ฆฟ์ง€ ํŒจํ„ด
        • ์ปดํฌ์ง“(Composite) ํŒจํ„ด
        • ๋ฐ์ฝ”๋ ˆ์ดํ„ฐ
        • ํ”„๋ก์‹œ
    • refactoring
      • ์ค‘๋ณต ์ฝ”๋“œ
      • ์ „์—ญ ๋ฐ์ดํ„ฐ
      • ๊ธด ํ•จ์ˆ˜
      • ๊ธด ๋งค๊ฐœ๋ณ€์ˆ˜ ๋ชฉ๋ก
      • ๊ฐ€๋ณ€ ๋ฐ์ดํ„ฐ
      • ์ดํ•ดํ•˜๊ธฐ ํž˜๋“  ์ด๋ฆ„
  • ์ž๋ฃŒ๊ตฌ์กฐ
    • AVL Tree
    • Splay Tree
    • aaTree
    • array-list
    • ์ž๋ฃŒ๊ตฌ์กฐ ์‹œ๊ฐ„/๊ณต๊ฐ„ ๋ณต์žก๋„
    • ๊ทธ๋ž˜ํ”„
    • ํž™
    • Red Black Tree
    • stack-queue
    • ํŠธ๋ฆฌ ( Tree )
  • DevOps
    • MSA
    • Kubernetes
      • AccessingAPI
      • controller
      • dashboard
      • kubernetes
      • object
      • pod
      • service
      • volume
  • Java
    • ์–ด๋…ธํ…Œ์ด์…˜
    • ์ œ์–ด๋ฌธ
    • ๋ฐ์ดํ„ฐ ํƒ€์ž…
    • Enum
    • jvm
    • ์—ฐ์‚ฐ์ž
    • thread
    • Java8
      • CompletableFuture
      • Date/Time
      • ์–ด๋…ธํ…Œ์ด์…˜๊ณผ ๋ฉ”ํƒ€์ŠคํŽ˜์ด์Šค
      • ์ธํ„ฐํŽ˜์ด์Šค
      • ๋žŒ๋‹ค์‹
      • Optional
      • ์ŠคํŠธ๋ฆผ
  • JavaScript
    • moduleProject
    • webpack-babel
    • ์ฝ”์–ด ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ
      • array
      • ํ•จ์ˆ˜ ๋ฐ”์ธ๋”ฉ
      • ๋ฐ์ฝ”๋ ˆ์ดํ„ฐ์™€ ํฌ์›Œ๋”ฉ
      • Class
      • ๋น„๊ต ์—ฐ์‚ฐ์ž
      • Date ๋‚ด์žฅ ๊ฐ์ฒด
      • destructuring-assignment
      • function
      • ํ•จ์ˆ˜์˜ prototype ํ”„๋กœํผํ‹ฐ
      • ๊ฐ€๋น„์ง€ ์ปฌ๋ ‰์…˜ ( Garbage Collection )
      • JSON (JavaScript Object Notation)
      • map-set
      • ๋‚ด์žฅ ํ”„๋กœํ† ํƒ€์ž…
      • new์—ฐ์‚ฐ์ž์™€ ์ƒ์„ฑ์ž ํ•จ์ˆ˜
      • ๊ฐ์ฒด
      • Object.keys, values, entries
      • ์˜ต์…”๋„ ์ฒด์ด๋‹ '?.'
      • ํ”„๋กœํผํ‹ฐ ํ”Œ๋ž˜๊ทธ
      • ํ”„๋กœํผํ‹ฐ ์ข…๋ฅ˜
      • ํ”„๋กœํ†  ํƒ€์ž…
      • ํ˜ธ์ถœ ์Šค์ผ€์ค„๋ง ( scheduling a call )
      • scope
      • this
      • type-conversions
      • type
      • ํ•จ์ˆ˜์˜ ์ž๋ฃŒํ˜•
      • var_let_const
  • Linux
    • ๊ธฐ๋ณธ ๋ช…๋ น์–ด
    • ํŒŒ์ผ ์ข…๋ฅ˜
    • ๋ฆฌ๋ˆ…์Šค
  • ๋„คํŠธ์›Œํฌ
    • ์‘์šฉ ๊ณ„์ธต ( Application Layer )
    • ์˜ค๋ฅ˜ ๊ฒ€์ถœ๊ณผ ์˜ค๋ฅ˜ ์ •์ •
    • Http
    • Http Header
    • ์ปดํ“จํ„ฐ ๋„คํŠธ์›Œํฌ๋ž€
    • ๋„คํŠธ์›Œํฌ ๊ณ„์ธต
    • ๋„คํŠธ์›Œํฌ ์ œ์–ด ์˜์—ญ
    • ์ „์†ก ๊ณ„์ธต ( Transport Layer )
  • PHP
    • Facade
    • composer
    • scopeResolutionOperator
    • Laravel
      • SocialProvider
      • architecture
      • blade
      • controller
      • db
      • dbArchitecture
      • debug
      • eloquent
      • email
      • event
      • exceptionHandling
      • middleware
      • model
      • modelFactory
      • pagingLoading
      • queryBuilder
      • route
      • scout
      • seeding
      • tntsearch
      • validate
      • view
  • React
    • Next.js
    • React ๋ž€?
  • Spring
    • Controller
    • ์š”์ฒญ์ด ๋“ค์–ด์™”์„๋•Œ ์Šคํ”„๋ง์ด ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ• ( ๋‚ด๋ถ€๊ตฌ์กฐ )
    • ConfigurationProperties
    • Entity / DTO / VO
    • Maven
    • Repository์™€ DAO
    • ์Šคํ”„๋ง ๋นˆ
    • Spring Framework
    • MVC ํŒจํ„ด
    • ๋„๋ฉ”์ธ ์ž…๋ ฅ๊ฐ’ ๊ฒ€์ฆ
    • Spring Cloud
      • Spring Cloud
      • Eureka
    • Spring Data
      • JPA
      • JPA ์–ด๋…ธํ…Œ์ด์…˜
      • ์—”ํ‹ฐํ‹ฐ ๋น„๊ต
      • ๋ณตํ•ฉ ํ‚ค์™€ ์‹๋ณ„ ๊ด€๊ณ„ ๋งคํ•‘
      • JPA ์˜ˆ์™ธ์ฒ˜๋ฆฌ
      • ๊ฐ์ฒด์ง€ํ–ฅ ์ฟผ๋ฆฌ
      • EntityManagerFactory์™€ EntityManager
      • JPA ์ตœ์ ํ™”
      • ํ”„๋ก์‹œ์™€ ์—ฐ๊ด€๊ด€๊ณ„ ๋งตํ•‘
      • ์—ฐ๊ด€๊ด€๊ณ„
      • ์ƒ์†๊ด€๊ณ„ ๋งตํ•‘
      • ํŠธ๋žœ์žญ์…˜ ๋ฒ”์œ„์™€ ์˜์†์„ฑ ์ปจํ…์ŠคํŠธ
      • ๋ฐ์ดํ„ฐ ํƒ€์ž…
      • MySQL ์—ฐ๊ฒฐ
      • Pageable
    • Spring Project๋“ค๊ณผ library
      • Custom Serialize
      • Elasticsearch Index API
      • Spring HATEOAS
      • lombok (๋กฌ๋ณต)
      • Model Mapper
      • Object Mapper
      • Representation Model
      • Spring REST Docs
      • Spring Boot
    • Spring Security
      • Spring Security
      • Authentication
      • Authentication Filter
      • Authorization Filter
      • Filter Chain
      • SecurityContext
      • Spring OAuth2.0
    • Spring Test
      • AssertJ
      • Junit5
      • JunitParams
      • Mock Object
  • DataBase
    • ALIAS
    • CONCAT
    • CTE
    • Group By
    • HAVING
    • IFNULL
    • ์ธ๋ฑ์Šค
    • JOIN
    • ORDER BY
    • ROLLUP
    • SELECT
    • SELECT DISTINCT
    • SQL
    • WHERE
  • Web ์ƒ์‹
    • OAuth
    • WAS
    • HTTPํ†ต์‹  ๊ธฐ๋ฐ˜ ์ธ์ฆ
    • ๋ธŒ๋ผ์šฐ์ €
    • CSR ๊ณผ SSR
    • HTTPS
    • Web
Powered by GitBook
On this page
  • ๊ตฌ์กฐ
  • ๊ณผ์ •
  • UsernamePasswordAuthenticationFilter
  • Authentication
  • AuthenticaitonManager
  • AuthenticationProvider
  • UserDetails
  1. Spring
  2. Spring Security

Authentication

์ธ์ฆ ์ •๋ณด๋กœ ์‚ฌ์šฉ์ž์˜ ์ธ์ฆ์ •๋ณด๋ฅผ ์ €์žฅํ•˜๋Š” ํ† ํฐ๊ฐ™์€ ๊ฐœ๋…

์ธ์ฆ์‹œ id/password๋ฅผ ๋‹ด๊ณ  ์ธ์ฆ ๊ฒ€์ฆ์„ ์œ„ํ•ด ์ด๋ฅผ ์ „๋‹ฌ/์‚ฌ์šฉํ•œ๋‹ค.

์ธ์ฆ ํ›„์—๋Š” ์ตœ์ข… ๊ฒฐ๊ณผ(์ธ์ฆ ์ฃผ์ฒด/๊ฐ์ฒด/๋น„๋ฐ€๋ฒˆํ˜ธ/๊ถŒํ•œ์ •๋ณด ๋“ฑ)๋ฅผ ๋‹ด๊ณ  SecurityContext์— ์ €์žฅ๋˜์–ด ์ „์—ญ์œผ๋กœ ์ฐธ์กฐ ๊ฐ€๋Šฅํ•˜๋‹ค.

๊ตฌ์กฐ

  1. principal : ์ธ์ฆ ์ฃผ์ฒด(id๋‚˜ User๊ฐ์ฒด์™€ ๊ฐ™์ด ์‚ฌ์šฉ์ž๋ฅผ ์‹๋ณ„)

  2. credentials : ๋น„๋ฐ€๋ฒˆํ˜ธ

  3. authorities : ๊ถŒํ•œ, ์—ญํ• 

  4. details : ๋ถ€๊ฐ€ ์ •๋ณด

  5. Authenticated : ์ธ์ฆ ์—ฌ๋ถ€(T/F)

๊ณผ์ •

  1. Id/Pw๋ฅผ ์„œ๋ฒ„์— ์ „๋‹ฌ

  2. UsernamePasswordAuthenticationFilter์—์„œ ์ด๋ฅผ ํ•„ํ„ฐ๋ง

  3. ์š”์ฒญํ•œ Id/PW๋ฅผ ๋‹ด์€ Authentication ๊ฐ์ฒด ์ƒ์„ฑ

  4. AuthenticationManager์—๊ฒŒ ์ด ์ธ์ฆ ๊ฐ์ฒด ์ „๋‹ฌ(์ˆ˜์‹ )

  5. Manager๋Š” ์ ํ•ฉํ•œ ์ธ์ฆ๊ฐ์ฒด Provider์—๊ฒŒ ์ธ์ฆ๊ฐ์ฒด ์ „๋‹ฌ

  6. Provider๋Š” ์š”์ฒญ ์ •๋ณด๋ฅผ ์ด์šฉํ•ด ์ธ์ฆ๊ณผ์ • ์ˆ˜ํ–‰

  7. ์ธ์ฆ์ด ์„ฑ๊ณตํ•œ๋‹ค๋ฉด ๊ถŒํ•œ๊ณผ ์ธ์ฆ ์—ฌ๋ถ€๋ฅผ ์…‹ํŒ…ํ•œ ์ธ์ฆ๊ฐ์ฒด๋ฅผ SecurityContext์— ์ €์žฅ

UsernamePasswordAuthenticationFilter

์‚ฌ์šฉ์ž ์ธ์ฆ ์š”์ฒญ์„ Authentication ์ธํ„ฐํŽ˜์ด์Šค๋กœ ์ถ”์ƒํ™”ํ•˜๊ณ , AuthenticationManager๋ฅผ ํ˜ธ์ถœํ•œ๋‹ค.

Authentication

์‹ค์ œ ์‚ฌ์šฉ์ž ์ธ์ฆ ์ •๋ณด๋ฅผ ์˜๋ฏธํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค

  • Principal : ์‚ฌ์šฉ์ž๋ฅผ ๊ตฌ๋ถ„(์ผ์ข…์˜ id) -> ์ ‘๊ทผ ์ฃผ์ฒด

  • Credentials : ์ ‘๊ทผ ์ฃผ์ฒด์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ

  • Authorities : ์‚ฌ์šฉ์ž์˜ ROLE

getPricipal()(์ธ์ฆ ์•„์ด๋””), getCredentials()(์ธ์ฆ ๋น„๋ฐ€๋ฒˆํ˜ธ), getAuthorities()(์‚ฌ์šฉ์ž ๊ถŒํ•œ๋ชฉ๋ก), getDetails()(๋ถ€๊ฐ€์ •๋ณด), isAuthenticated()(์ธ์ฆ์—ฌ๋ถ€)์™€ ๊ฐ™์€ ๋ฉ”์„œ๋“œ ์ œ๊ณต

UsernamePasswordAuthenticationToken authentication= new UsernamePasswordAuthenticationToken(username, password);

AuthenticaitonManager

์‚ฌ์šฉ์ž ์•„์ด๋””/๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ธ์ฆํ•˜๊ธฐ ์œ„ํ•ด ์ ์ ˆํ•œ AuthenticationProvider ์ฐพ์•„ ์ฒ˜๋ฆฌ๋ฅผ ์œ„์ž„ํ•œ๋‹ค. ๊ตฌํ˜„๊ฐ์ฒด๋กœ ProviderManager๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

(๊ธฐ๋ณธ ProviderMansger์—์„œ Form์ธ์ฆ(DaoAuthenticationProvider)์€ , RememberMe์ธ์ฆ(RememberMeAuthenticationProvider)์„ ์ œ๊ณต )

๊ธฐ๋ณธ์ ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” Provider๊ฐ€ ์—†๋Š” JWT, OAuth์™€ ๊ฐ™์€ ๋ณ„๋„์˜ ์ธ์ฆ์„ ์ถ”๊ฐ€ ํ•˜๊ณ ์ž ํ•˜๋ฉด ๋ถ€๋ชจProviderManager๋ฅผ ํƒ์ƒ‰ํ•ด์„œ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” provider๋ฅผ ์ฐพ๋Š”๋‹ค.

spring ๋ณด์•ˆ ์ธ์ฆ ํ”„๋กœ์„ธ์Šค์˜ ํ•ต์‹ฌ์œผ๋กœ ๋ฐฉ๋ฒ•์„ ์ •์˜ํ•˜๋Š” api

public interface AuthenticationManager {
    Authentication authenticate(Authentication authentication) throwsAuthenticationException;
}

์ปค์Šคํ…€ provider๋ฅผ ๋งŒ๋“ค์—ˆ๋‹ค๋ฉด ๋“ฑ๋กํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค

@Autowired
public void configureAuthentication(AuthenticationManagerBuilder builder, JwtAuthenticationProvider jwtAuthenticationProvider) {
    builder.authenticationProvider(jwtAuthenticationProvider);
}

AuthenticationProvider

์‹ค์งˆ์ ์œผ๋กœ ์‚ฌ์šฉ์ž ์ธ์ฆ์„ ์ฒ˜๋ฆฌํ•˜๊ณ , ์ธ์ฆ ๊ฒฐ๊ณผ๋ฅผ Authentication ์ธํ„ฐํŽ˜์ด์Šค๋กœ ๋ฐ˜ํ™˜ํ•œ๋‹ค.

์ปค์Šคํ…€ provider๋ฅผ ๋งŒ๋“ค๊ณ ์ž ํ•œ๋‹ค๋ฉด ์ด๋ฅผ implementsํ•˜์—ฌ ๊ตฌํ˜„

authenticate()์—์„œ ์‹ค์ œ ์ธ์ฆ์„ ์ฒ˜๋ฆฌํ•˜๊ณ  supports()๋Š” AuthenticationManager์—์„œ ์š”์ฒญ์ธ์ฆ๊ฐ์ฒด์— ์ ํ•ฉํ•จ Provider๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•œ ๋ฉ”์„œ๋“œ์ด๋‹ค.

public interface AuthenticationProvider {
    Authentication authenticate(Authentication authentication) throws AuthenticationException;
    boolean supports(Class<?> authentication);
}

UserDetails

์‚ฌ์šฉ์ž์˜ ์ •๋ณด๋ฅผ ๋‹ด๋Š” ์ธํ„ฐํŽ˜์ด์Šค๋กœ VO์—ญํ• 

  • getAuthorities() : ๊ณ„์ •์ด ๊ฐ–๊ณ ์žˆ๋Š” ๊ถŒํ•œ ๋ชฉ๋ก์„ ๋ฆฌํ„ด

  • getPassword() : ๊ณ„์ •์˜ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋ฆฌํ„ด

  • getUsername() : ๊ณ„์ •์˜ ์ด๋ฆ„์„ ๋ฆฌํ„ด

  • isAccountNonExpired() : ๊ณ„์ •์ด ๋งŒ๋ฃŒ๋˜์ง€ ์•Š์•˜๋Š” ์ง€ ๋ฆฌํ„ด (true: ๋งŒ๋ฃŒ์•ˆ๋จ)

  • isAccountNonLocked() : ๊ณ„์ •์ด ์ž ๊ฒจ์žˆ์ง€ ์•Š์•˜๋Š” ์ง€ ๋ฆฌํ„ด (true: ์ž ๊ธฐ์ง€ ์•Š์Œ)

  • isCredentialNonExpired() : ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ๋งŒ๋ฃŒ๋˜์ง€ ์•Š์•˜๋Š” ์ง€ ๋ฆฌํ„ด (true: ๋งŒ๋ฃŒ์•ˆ๋จ)

  • isEnabled() : ๊ณ„์ •์ด ํ™œ์„ฑํ™”(์‚ฌ์šฉ๊ฐ€๋Šฅ)์ธ ์ง€ ๋ฆฌํ„ด (true: ํ™œ์„ฑํ™”)

  • UserDetailsService : DAO๋กœ ์‚ฌ์šฉ๋˜๋ฉฐ ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ๋กœ๋“œํ•˜๊ธฐ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋กœ UserDetails๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ํ•˜๋‚˜์˜ ๋ฉ”์„œ๋“œ๋ฅผ ๊ฐ–๊ณ ์žˆ๋‹ค.

PreviousSpring SecurityNextAuthentication Filter

Last updated 3 years ago