Ограничить доступ к определенным URL для определенных ролей в весенней безопасности - PullRequest
0 голосов
/ 16 мая 2018
<security:http entry-point-ref="casEntryPoint" use-expressions="true">

    <security:intercept-url pattern="/**" access="hasAnyRole(All roles)" />
    <security:intercept-url pattern="/unauthorized" access="hasRole('ROLE_UNAUTHORIZED')"  />
    <security:intercept-url pattern="/unauthorized" access="!hasAuthority('ROLE_SUPER_ADMIN')" />

</security:http>

Я хочу ограничить URL-адреса для определенных ролей.

<security:intercept-url pattern="/unauthorized" access="!hasAuthority('ROLE_SUPER_ADMIN')" />

Я пробовал, но не работает.

См. Изображение, я вошел в систему как администратор, но я могу получить доступ к / неавторизованным с панели URL.

enter image description here

1 Ответ

0 голосов
/ 16 мая 2018

Пример кода

<security:http auto-config='true' use-expressions="true">

    <security:intercept-url pattern="/unauthorized" access="hasAnyRole('ROLE_UNAUTHORIZED')"  />

    <!-- permitAll is last in order. -->
    <security:intercept-url pattern="/**" access="permitAll" />


</security:http>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...