This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| back-end:spring:security [2021/04/26 12:31] – created ledyx | back-end:spring:security [2021/04/29 15:23] (current) – [WebSecurityConfigurerAdapter] configure() 설명 추가 ledyx | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| = Spring Security = | = Spring Security = | ||
| - | [[https:// | + | SpringBoot 기준으로 서술 |
| {{tag> | {{tag> | ||
| - | == 기본 개념 == | + | == Overview == |
| + | |||
| + | * Authentication : 인증. “유효한 사용자인가? | ||
| + | * Authorization : 허가(권한 부여). 유효한 사용자가 이 작업을 할 수 있는가? | ||
| + | |||
| + | === Documents === | ||
| + | |||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | == Authentication == | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | * 모두 Interface | ||
| + | |||
| + | < | ||
| + | classDiagram | ||
| + | class AuthenticationManager { | ||
| + | authenticate(Authentication authentication) Authentication | ||
| + | } | ||
| + | |||
| + | class AuthenticationProvider { | ||
| + | authenticate(Authentication authentication) Authentication | ||
| + | supports(Class~? | ||
| + | } | ||
| + | |||
| + | class UserDetailsService { | ||
| + | loadUserByUsername(String username) UserDetails | ||
| + | } | ||
| + | |||
| + | class UserDetails { | ||
| + | getAuthorities() Collection~? | ||
| + | getPassword() String | ||
| + | isAccountNonExpired() boolean | ||
| + | isAccountNonLocked() boolean | ||
| + | isCredentialsNonExpired() boolean | ||
| + | isEnabled() boolean | ||
| + | } | ||
| + | |||
| + | AuthenticationManager --> AuthenticationProvider : authRequest | ||
| + | AuthenticationProvider <..> UserDetailsService : 서비스 주입 후 authenticate()에서 사용자 정보를 꺼내어 사용 | ||
| + | UserDetailsService -- UserDetails | ||
| + | </ | ||
| + | |||
| + | === AuthenticationManager === | ||
| + | |||
| + | * [[https:// | ||
| + | * 기본 | ||
| + | * [[https:// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | === AuthenticationProvider | ||
| + | |||
| + | * [[https:// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | === UserDetailsService | ||
| + | |||
| + | " | ||
| + | |||
| + | {{: | ||
| + | |||
| + | 또 다른 사용자 정보를 담는 Bean을 만들기보다 이를 상속해서 사용하는게 일을 덜 할 수 있으리라 판단된다. | ||
| + | |||
| + | 마음에 드는 구현체가 없다면 이 Interface를 상속받아서 재정의. | ||
| + | |||
| + | 자식 Interface인 [[https:// | ||
| + | |||
| + | |||
| + | ---- | ||
| + | |||
| + | |||
| + | === WebSecurityConfigurerAdapter === | ||
| + | |||
| + | 전역적인(globally) authentication이 필요할 때 사용. | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | * **protected void configure(AuthenticationManagerBuilder auth)** | ||
| + | * Used by the default implementation of authenticationManager() to attempt to obtain an AuthenticationManager. | ||
| + | * **protected void configure(HttpSecurity http)** | ||
| + | * Override this method to configure the HttpSecurity. | ||
| + | * **void configure(WebSecurity web)** | ||
| + | * Override this method to configure WebSecurity. | ||
| + | |||
| + | {{: | ||
| + | |||
| + | * WebSecurityConfigurerAdapter, | ||
| + | * WebSecurity : final class | ||
| + | |||
| + | < | ||
| + | classDiagram | ||
| + | class SecurityConfigurer~O, | ||
| + | init(B builder) | ||
| + | configure(B builder) | ||
| + | } | ||
| + | |||
| + | class WebSecurityConfigurer~T extends SecurityBuilder<Filter>~ | ||
| + | |||
| + | class SecurityBuilder~O~ { | ||
| + | build() O | ||
| + | } | ||
| + | |||
| + | class AbstractSecurityBuilder~O~ | ||
| + | |||
| + | class AbstractConfiguredSecurityBuilder~O, | ||
| + | |||
| + | class WebSecurity | ||
| + | |||
| + | SecurityConfigurer <|-- WebSecurityConfigurer : <Filter, | ||
| + | WebSecurityConfigurer | ||
| + | |||
| + | SecurityBuilder <|-- AbstractSecurityBuilder | ||
| + | AbstractSecurityBuilder <|-- AbstractConfiguredSecurityBuilder | ||
| + | AbstractConfiguredSecurityBuilder <|-- WebSecurity : <Filter, WebSecurity> | ||
| + | |||
| + | Aware <|-- ApplicationContextAware | ||
| + | SecurityBuilder <|-- WebSecurity : <Filter> | ||
| + | ApplicationContextAware <|-- WebSecurity | ||
| + | </ | ||
| + | |||
| + | |||
| + | == Authorization == | ||
| + | |||
| + | [[https:// | ||
| + | |||
| + | |||
| + | == Protection Against Exploits | ||
| + | |||
| + | [[https:// | ||
| - | * Authentication : 인증. " | ||
| - | * Authorization : 허가(권한 부여). 유효한 사용자가 이 작업을 __할 수 있는가__? | ||