gpt4 book ai didi

java - Spring安全/授权级别

转载 作者:行者123 更新时间:2023-12-01 13:57:24 24 4
gpt4 key购买 nike

我在我的 Web 应用程序中使用 Spring security,并且使用 2 个标准授权级别“ROLE_USER”和“ROLE_ADMIN”。我是否可以添加另一个级别?

最佳答案

只需将它们添加到您的拦截 URL 标记中即可。例如我有以下配置:

<security:http auto-config="false" use-expressions="true" access-denied-page="/denied.do"
entry-point-ref="authenticationEntryPoint">
<security:intercept-url pattern="/index.do" access="hasAnyRole('PROGRAM_VIEW', 'PROGRAM_ADMIN')"/>
<security:intercept-url pattern="/**" access="hasAnyRole('PROGRAM_VIEW', 'PROGRAM_ADMIN)"/>

<security:custom-filter ref="authenticationFilter" position="FORM_LOGIN_FILTER"/>

<security:logout invalidate-session="true" logout-success-url="/" logout-url="/logout.do"/>
</security:http>

我的其他角色是 PROGRAM_VIEW 和 PROGRAM_ADMIN(我没有使用 ROLE_ADMIN 和 ROLE_USER)。

这些附加角色来自数据库。

关于java - Spring安全/授权级别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19557641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com