2016-11-01 7 views
0

나는 권한이있는 사람들 만 입력 할 수있는 웹 사이트가 있습니다. 누군가 권한이 없으면 web.xml에서 403 오류 페이지로 리디렉션합니다.'403 Forbidden'을 반환 할 때 web.xml 권한을 로컬 js/css 파일에 처리하는 방법은 무엇입니까?

그러나 내 응용 프로그램과 오류 페이지 모두 일부 외부 js 및 css 파일 (예 : 부트 스트랩)을 사용합니다. 논리적으로 403 오류 페이지는 오류 페이지 html을 제외한 모든 것에 대한 사용 권한이 금지되어 있으므로 이러한 js/css 파일에 액세스 할 수 없습니다.

이 문제를 어떻게 해결해야합니까? 내 라이브러리 폴더를 공개적으로 노출해야합니까? 그렇다면 특정 폴더에 대한 보안 규칙을 어떻게 재정의 할 수 있습니까?

나는 documentation here을 조사했지만이 시나리오는 언급되어 있지 않습니다. 나는 "/ libraries"에 보안 제한을 추가해야한다고 생각하고, HTTP 메소드에 필요한 역할을 어떻게 든 재정의해야합니까?

내 web.xml 파일의 잠재적 관련 부분 :

<error-page> 
     <error-code>403</error-code> 
     <location>/errorPages/forbidden.jsp</location> 
    </error-page> 

    <security-role> 
    <role-name>myRole</role-name> 
    </security-role> 

    <security-constraint> 
    <display-name>MySecurityConstraint</display-name> 
    <web-resource-collection> 
     <web-resource-name>WebResource</web-resource-name> 
     <url-pattern>/*</url-pattern> 
     <http-method>GET</http-method> 
     <http-method>DELETE</http-method> 
     <http-method>PUT</http-method> 
     <http-method>HEAD</http-method> 
     <http-method>OPTIONS</http-method> 
     <http-method>POST</http-method>  
    </web-resource-collection> 
    <auth-constraint> 
     <role-name>myRole</role-name> 
    </auth-constraint> 
    <user-data-constraint> 
     <transport-guarantee>NONE</transport-guarantee> 
    </user-data-constraint> 
    </security-constraint> 

답변

1

당신은 간단한 상세한 경로로 추가 보안 제약 조건을 추가 할 수 있고 인증-제약없이

<security-constraint> 
    <display-name>NoSecurityConstraint</display-name> 
    <web-resource-collection> 
     <web-resource-name>WebResource</web-resource-name> 
     <url-pattern>/library/*</url-pattern> 
     <http-method>GET</http-method> 
     <http-method>DELETE</http-method> 
     <http-method>PUT</http-method> 
     <http-method>HEAD</http-method> 
     <http-method>OPTIONS</http-method> 
     <http-method>POST</http-method>  
    </web-resource-collection> 
    </security-constraint> 

내가이 해결할 수있는 문제를 바랍니다 너의 문제