• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

springSecurity

24.03.16 17:17 작성 조회수 140

0

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

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

답변 2

·

답변을 작성해보세요.

0

예컨데님의 프로필

예컨데

2024.03.23

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

최정식님의 프로필

최정식

질문자

2024.03.16

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