스터디-Spring

[스프링 시큐리티] FilterSecurityIntercepter

일태우 2022. 1. 17. 21:47
반응형

AccessDecisionManager를 사용하여 Access Control 또는 예외 처리하는 필터, 대부분의 경우 FilterChainProxy에 제일 마지막 필터로 들어있다.

 

Authorization(인가)를 시도한다 이때 accessDecisionManage.decide메서드를 호출하는데, AccessDeniedException이 발생하면 그전 단계인 ExceptionTranslationFilter에서 예외를 처리한다.

	private void attemptAuthorization(Object object, Collection<ConfigAttribute> attributes,
			Authentication authenticated) {
		try {
			this.accessDecisionManager.decide(authenticated, object, attributes);
		}
		catch (AccessDeniedException ex) {
			if (this.logger.isTraceEnabled()) {
				this.logger.trace(LogMessage.format("Failed to authorize %s with attributes %s using %s", object,
						attributes, this.accessDecisionManager));
			}
			else if (this.logger.isDebugEnabled()) {
				this.logger.debug(LogMessage.format("Failed to authorize %s with attributes %s", object, attributes));
			}
			publishEvent(new AuthorizationFailureEvent(object, attributes, authenticated, ex));
			throw ex;
		}
	}
  • authenticated: 인증된 객체
  • object: 접근할려는 객체(주로 페이지)
  • attributes(ConfigAttribute): 접근 객체에 대한 접근 제어 속성들(permitAll, authenticated 등)
반응형