Program/JSP

JSP에서 Servlet 이외의 URL 접급 차단법

Mr콩랑 2010. 3. 5. 19:43
반응형

web.xml에서 JSP페이지에 보안설정을 하는 방법
web.xml에 *.jsp 패턴의 모든 URL에 대해서 누구도 실행을 할 수 없게 설정해줄 수 있습니다. 아래 처럼 세팅하면 됩니다.

<security-constraint>

  <display-name>JSP Protection</display-name>

  <web-resource-collection>

    <web-resource-name>SecureJSPPages</web-resource-name>

      <url-pattern>*.jsp</url-pattern>

  </web-resource-collection>

  <auth-constraint>

    <role-name>nobody</role-name>

  </auth-constraint>

</security-constraint>

 

<security-role>

<description>

Nobody should be in this role so JSP files are protected

from direct access.

</description>

<role-name>nobody</role-name>

</security-role>

 

어떤 의도를 가진 사용자가 JSP 페이지를 URL로 직접 접근하게 되면 서버는 HTTP 응답코드 401번(Unauthorized) 페이지를 보여줍니다.좀더 우아하게 처리하려면 401번 응답 페이지를 예쁘게 만들어서 등록하면 되겠죠.

<!-- 접근 권한없음 : UNAUTHORIZED-->

<error-page>

  <error-code>401</error-code>

  <location>/error/unauthorized.html</location>

</error-page>


 

반응형