Spring Security

JinjuLog·2021년 2월 25일
3

Spring Framework

목록 보기
6/8
post-thumbnail

Spring Security

Spring Security는 Spring 기반의 애플리케이션의 보안(인증과 권한, 인가)을 담당하는 스프링 하위 프레임워크이다.

시큐리티 태그 라이브러리

	<dependency>
	  <groupId>org.springframework.security</groupId>
	  <artifactId>spring-security-taglibs</artifactId>
	</dependency>
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-security</artifactId>
	</dependency>
    
    

시큐리티를 사용한 로그인 로직

시큐리티 ▶ 로그인 요청 ▶ 시큐리티가 가로채서 로그인 진행 후 완료 ▶ 유저 정보를 시큐리티 세션에 저장 (유저정보 IoC, type : userDetails) ▶ 해쉬 암호화 ▶ 로그인

Spring Security 로직

정리해본 Spring Security 로직

코드

Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(user.getUsername(), user.getPassword()));
// authentication 객체에 세션 저장
SecurityContextHolder.getContext().setAuthentication(authentication);

0개의 댓글