Spring Security 권한 처리를 해볼게요.. 회원 데이터를 몇 개 더 넣고..각 회원 별로 권한을test1 = ROLE_USERtest2 = ROLE_MANAGERtest3 = ROLE_ADMIN이렇게 부여했습니다.이 상황이면, 이렇게 접근이 가능합니다. 여기서, 스프링 시큐리티 설정 파일에서 @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true) EnableGlobalMethodSecurity 어노테이션을 통해 securedEnabled, prePostEnabled 두 개를 활성화시켜주고 @Secured("ROLE_ADMIN") @GetMapping("info") public @ResponseBo..
Spring Security 로그인 처리를 해볼게요.. 먼저. 시큐리티 설정 메서드에서 @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.authorizeRequests() .antMatchers("/user/**") .authenticated() .antMatchers("/manager/**").access("hasRole('ROLE_ADMIN') or hasRole('ROLE_MANAGER')") .antMatchers("/adm..
회원가입 처리와 동시에 비밀번호를 암호화시켜서 DB에 저장까지 해볼게요.. 먼저, 로그인 페이지와 회원가입 페이지를 만들어줬습니다.. 로그인 페이지 ID : PW : 회원가입 하러가기회원가입 페이지 ID : PW : Email : 로그인 하러가기 그리고 user 모델을 생성해 줍니다.. package com.cos.security1.model;import lombok.Data;import org.hibernate.annotations.CreationTimestamp;import javax.persistence...
해당 프로젝트는 로그인, 회원가입에 따라 회원별 권한을 부여합니다..비회원, 유저, 매니저, 어드민 총 4개의 계층으로 나누어져 있습니다.. 현재까지의 구조는 다음과 같습니다.. dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' im..