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 |
Tags
- 도커설치하는법
- 스프링부트팔로우취소
- 우분투도커설치
- 스프링구독
- centos도커설치
- dockerinstall
- 파이썬sort
- springboot_exception_handler
- 스프링부트팔로잉
- 출처 문어박사
- 스프링부트사진올리기
- 스프링부트구독취소
- 서버에도커설치
- 출처 코딩셰프
- vm도커설치하는법
- 스프링부트서버에사진전송
- 인스타클론
- 스프링사진
- 출처 노마드코더
- 스프링익셉션처리
- 출처 따배도
- 스프링부트api
- 스프링부트중복예외처리
- 스프링이미지업로드
- 스프링사진업로드
- 스프링부트
- 멀티폼
- 출처 메타코딩
- WAS웹서버
- ssh도커설치
Archives
- Today
- Total
MakerHyeon
[SpringBoot] Security 권한 부분 설정 본문
[SpringBoot] Security 권한 부분 설정
1. 권한 업데이트
# MySQL
update user set role = 'ROLE_MANAGE' where id = 2;
update user set role = 'ROLE_ADMIN' where id = 3;
2. SecurityConfig @EnableGlobalMethodSecurity 어노테이션 붙여주기
// Secure,preAuthorize annotation 활성화
@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)
public class SecurityConfig {
...
3. 메소드별 권한 설정
// IndexController.java
@Secured("ROLE_ADMIN") // 메소드에 권한걸기
@GetMapping("/info")
public @ResponseBody String info(){
return "개인정보";
}
//메소드 실행직전실행됨.여러 ROLE걸기
@PreAuthorize("hasRole('ROLE_MANAGER') or hasRole('ROLE_ADMIN')")
@GetMapping("/data")
public @ResponseBody String data(){
return "데이터정보";
}
'SpringBoot > Security' 카테고리의 다른 글
[SpringSecurity] Form Login 인증 (0) | 2023.04.03 |
---|---|
[SpringBoot] Security 네이버 로그인 (0) | 2023.01.23 |
[SpringBoot] Security 페이스북 로그인 (security facebook login) (0) | 2023.01.23 |
[SpringBoot] Security 구글 로그인 (0) | 2023.01.21 |
[SpringBoot] Security 회원가입과 로그인 (0) | 2023.01.20 |
Comments