<?xml version="1.0" encoding="UTF-8"?>

<web-app>

    <!-- ========================= Error Page list ======================== -->
    <error-page>
        <error-code>400</error-code>
        <location>/error/error.csp</location>
    </error-page>
    <error-page>
        <error-code>401</error-code>
        <location>/error/error.csp</location>
    </error-page>
    <error-page>
        <error-code>403</error-code>
        <location>/error/forbidden.csp</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/error/error.csp</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/error/error.csp</location>
    </error-page>


    <!-- ====================== Security constraints ======================== -->
    <security-constraint>
        <display-name>M/MONIT User Security Constraint</display-name>
        <web-resource-collection>
            <web-resource-name>M/MONIT User Protected Area</web-resource-name>
            <!-- Define the context-relative URL(s) to be protected -->
            <url-pattern>/index.csp</url-pattern>
            <url-pattern>/admin/*</url-pattern>
            <url-pattern>/map/*</url-pattern>
            <url-pattern>/welcome/*</url-pattern>
            <url-pattern>/status/*</url-pattern>
            <url-pattern>/reports/*</url-pattern>
            <url-pattern>/session/*</url-pattern>
            <url-pattern>/service/*</url-pattern>
            <url-pattern>/api/2/admin/*</url-pattern>
            <url-pattern>/api/2/status/*</url-pattern>
            <url-pattern>/api/2/reports/*</url-pattern>
            <url-pattern>/api/2/map/*</url-pattern>
            <url-pattern>/api/2/session/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <!-- Anyone with one of the listed roles may access this
            area. '*' is a wild-card, meaning all roles are allowed -->
            <role-name>*</role-name>
        </auth-constraint>
        <!-- Defines how data should be transported between client and server -->
        <user-data-constraint>
            <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

    <!-- CSRF-protected URLs -->
    <security-constraint>
        <web-resource-collection>
            <csrf-protect>
                <url-pattern>/admin/*</url-pattern>
                <url-pattern>/api/2/admin/*</url-pattern>
            </csrf-protect>
            <!-- If you list http methods, only those methods are protected -->
            <http-method>POST</http-method>
        </web-resource-collection>
        <!-- Anyone with one of the listed roles may access this
        area. '*' is a wild-card, meaning all roles are allowed -->
        <auth-constraint>
            <role-name>*</role-name>
        </auth-constraint>
    </security-constraint>

    <!-- =========================== Login method =========================== -->
    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>M/MONIT</realm-name>
        <form-login-config>
            <form-login-page>
                /login/login.csp
            </form-login-page>
            <form-error-page>
                /login/error.csp
            </form-error-page>
        </form-login-config>
    </login-config>

</web-app>
