반응형
250x250
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
- 인터넷프로토콜
- 자바스크립트객체리터럴
- 자바스크립트recude
- 자바스크립트틱택토
- c#
- 콜백함수
- 자바스크립트파라미터
- 인프런강좌
- 객체리터럴
- 비주얼스튜디오
- 자바스크립트
- 고차함수
- 자바스크립트함수
- .NET
- 객체의비교
- EntityFramework
- HTTP
- NPM
- 인프런무료강좌
- sort
- 틱택토구현
- 코딩
- 제로초
- 인프런강의
- slice
- 인프런자바스크립트
- Blazor
- 인프런인강
- 이벤트리스너
- 인프런
Archives
- Today
- Total
샐님은 개발중
[섹션3] 유저 정의와 관리 - InMemoryUserDetailManager를 사용한 유저 설정 본문
Spring Security - udemy
[섹션3] 유저 정의와 관리 - InMemoryUserDetailManager를 사용한 유저 설정
샐님 2024. 8. 16. 08:45728x90
반응형
섹션3 의 목표 : 애플리케이션 메모리 안에 유저를 저장하여 여러 유저를 생성하는 방법을 배우고 데이터베이스와 같은 저장장치에 유저의 정보를 저장하는 방법을 배운다.
package wonCom.EaszBankBackend.config;
import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
import static org.springframework.security.config.Customizer.withDefaults;
@Configuration //이 클래스 안에 특정 설정을 정의 , 시작단계에서 이 클래스 안에 우리가 정의한 모든 bean 을 스캔함.
public class ProjectSecurityConfig {
,,,
@Bean
public InMemoryUserDetailsManager userDetailsService(){
/*Approach 1 where we use withDefaultPasswordEncoder() method while creating the user details*/
/* UserDetails admin = User.withDefaultPasswordEncoder()
.username("admin")
.password("12345")
.authorities("admin")
.build();
UserDetails user = User.withDefaultPasswordEncoder()
.username("user")
.password("12345")
.authorities("read")
.build();
return new InMemoryUserDetailsManager(admin, user);
*/
/*Approach 2 where we use NoOpPasswordEncoder Bean while creating the user details*/
UserDetails admin = User.withUsername("admin")
.password("12345")
.authorities("admin")
.build();
UserDetails user = User.withUsername("user")
.password("12345")
.authorities("read")
.build();
return new InMemoryUserDetailsManager(admin, user);
}
// NoOppasswordEncoder : 운영 환경에서 권장되지 않음.
@Bean
public PasswordEncoder passwordEncoder(){
return NoOpPasswordEncoder.getInstance();
}
}
728x90
반응형
'Spring Security - udemy' 카테고리의 다른 글
[세션5] Authentication Provider(인증 제공자) (0) | 2024.08.21 |
---|---|
[섹션3] 유저 정의와 관리 - JdbcIserDetailsManager를 사용한 유저 설정 (0) | 2024.08.16 |
[섹션3] 유저 정의와 관리 - InMemoryUserDetailManager를 사용한 유저 설정 (0) | 2024.08.14 |
Spring Security 프레임워크의 기본 설정 확인 (0) | 2024.08.14 |
Spring Security 내부 흐름 (0) | 2024.08.14 |