강의

멘토링

커뮤니티

Cộng đồng Hỏi & Đáp của Inflearn

Hình ảnh hồ sơ của c50707345634
c50707345634

câu hỏi đã được viết

Phát triển ứng dụng web dựa trên Spring và JPA

Controller Đăng ký thành viên

springSecurity

Viết

·

510

0

이미 질문남기신 분들이 많기에 해당 코드들을 따라서 실행하려고 해 보았으나 스프링 시큐리티 버젼이 올라감에 따라 새롭게 코드를 작성을 해보기 위해 문서를 참고해서 수정을 했습니다만 접속을 하려고 보니

HTTP ERROR 403 에러가 뜨면서 localhost접근이 막히더군요 혹시 고쳐야할 부분이 있을까요?

javaspringspring-bootjpathymeleaf

Câu trả lời 2

0

RequestMatcherDelegatingAuthorizationManager 클래스의 check 메서드에서 breakpoint 를 잡고 디버깅해보시는 것을 추천드립니다.

@Override
public AuthorizationDecision check(Supplier<Authentication> authentication, HttpServletRequest request) {
    if (this.logger.isTraceEnabled()) {
       this.logger.trace(LogMessage.format("Authorizing %s", request));
    }
    for (RequestMatcherEntry<AuthorizationManager<RequestAuthorizationContext>> mapping : this.mappings) {

       RequestMatcher matcher = mapping.getRequestMatcher();
       MatchResult matchResult = matcher.matcher(request);
       if (matchResult.isMatch()) {
          AuthorizationManager<RequestAuthorizationContext> manager = mapping.getEntry();
          if (this.logger.isTraceEnabled()) {
             this.logger.trace(LogMessage.format("Checking authorization on %s using %s", request, manager));
          }
          return manager.check(authentication,
                new RequestAuthorizationContext(request, matchResult.getVariables()));
       }
    }
    if (this.logger.isTraceEnabled()) {
       this.logger.trace(LogMessage.of(() -> "Denying request since did not find matching RequestMatcher"));
    }
    return DENY;
}

spring security 의 authorizeHttpRequests 에 설정한 값들이 RequestMatcherDelegatingAuthorizationManager 클래스의 멤버변수 mappings 에 저장됩니다.

위의 check 메서드에서 mappings 를 순회하며 요청이 유효한지를 체크하게 되는데 403 Access Denied 가 발생하는 이유를 위 과정에서 확인할 수 있을 것으로 생각됩니다.

0

c50707345634님의 프로필 이미지
c50707345634
Người đặt câu hỏi

정확히는 sign-up등의 페이지로 이동시에 막힙니다. 기본적으로 localhost:8080으로 접속하는것 자체는 되는거 같습니다

Hình ảnh hồ sơ của c50707345634
c50707345634

câu hỏi đã được viết

Đặt câu hỏi