본문 바로가기

분류 전체보기384

role should not start with 'ROLE_' since it is automatically inserted. Got 'ROLE_USER' - spring security에서 hasRole() 사용 시 발생 - 오류내용 : Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalArgumentException: role should not start with 'ROLE_' since it is automatically inserted. Got 'ROLE_USER' 원인 - hasRole() 내부 : rolePrefix는 자동으로 .. 2023. 7. 21.
[SpringSecurity] java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null" 원인 SpringSecurity 5버전 이상부터는 PasswordEncoder를 처리를 하는데, 이때 PasswordEncoder를 처리하기위한 형식으로 pw가 저장되어있지 않기때문이다. - 기본이 bcrypt이다. - SpringSecurity가 로그인 과정에서 어떤 Encoder를 쓸지는 database에 저장된 password의 prefix { Encoder명 }를 보고 결정한다. - 따로 설정을하지않았으니, SpringSecurity가 prefix를 보고 Enocder형식을 정해야 하는데, 이것조처 설정이 되어있지 않아서 에러가 난것 해결 방법 securityconfig 에 빈을 등록한다. @Bean public PasswordEncoder noOpPasswordEncoder(){ return N.. 2023. 7. 20.
Encoded password does not look like BCrypt 원인 데이터베이스에 암호화 되어 있지 않은 임의로 넣은 pw 값이 있었다. @Bean public BCryptPasswordEncoder encodePwd(){ return new BCryptPasswordEncoder(); } 2023. 7. 20.
Caused by: java.lang.IllegalArgumentException: Unrecognized field "PER_NAME" (class com.example.devjob.vo.LoginPersonalVo), not marked as ignorable (4 known properties: "perId", "perEmail", "perPwd", "perName"]) 원인 json 데이터를 받아와서 dto 객체로 맵핑할때 dto 클래스에 선언되지 않은 속성이 json에 있으면 오류가 발생. 해결 방법 1.DTO Class에서 어노테이션 사용 @JsonIgnoreProperties(ignoreUnknown =true) : 선언 필드 외에 모든 요소 제외 dto class 객체에 속성이 없으면 exception 발생하지않고 진행. 아래와 같이 사용. @JsonIgnoreProperties(ignoreUnknown=true) public class CouconApiResponseDTO { private String vv; private String name; } 2.DTO Class에서 어노테이션 사용 jsonIgnoreProperties({"제외하고자하는 특정 필드 NA.. 2023. 7. 20.
상태코드 302 Redirect SpringConfig에서 .permitAll() 옵션을 안줌 2023. 7. 19.
MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled 원인 spring web security 적용 후 css, js 파일 적용이 안되는 문제. 해결 방법 SecurityConfig 파일에서 js, css, image 설정은 보안설정 영향 밖에 있도록 설정해준다. @Bean public WebSecurityCustomizer configure() { return (web) -> web.ignoring().mvcMatchers( "/css/**", "/imgs/**", "/js/**" ); } 2023. 7. 19.