Jsp 在基于表单的身份验证中添加另一个角色
我是一个基于表单认证的初学者。到目前为止,我有我的“管理员”用户/角色,它工作得很好,但现在我想添加另一个权限有限的角色。我在网上搜索过,但是教程只有管理员角色。我将在web.xml文件中的何处添加角色 当前Jsp 在基于表单的身份验证中添加另一个角色,jsp,authorization,web.xml,roles,Jsp,Authorization,Web.xml,Roles,我是一个基于表单认证的初学者。到目前为止,我有我的“管理员”用户/角色,它工作得很好,但现在我想添加另一个权限有限的角色。我在网上搜索过,但是教程只有管理员角色。我将在web.xml文件中的何处添加角色 当前web.xml: <security-constraint> <display-name>Security Constraint</display-name> <web-resource-collection>
web.xml
:
<security-constraint>
<display-name>Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/protected/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>manager</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description> An administrator </description>
<role-name>manager</role-name>
</security-role>
安全约束
保护区
/保护/*
删除
得到
邮递
放
经理
没有一个
形式
基于表单的身份验证区域
/login.jsp
/error.jsp
管理员
经理
我是否要添加另一个安全约束和另一个安全角色标记,或者添加到它,或者其他什么?我添加了另一个
标记以指定不同的保护区以及另一个保护区
来指定角色。见下文:
<security-constraint>
<display-name>Admin Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Admin Area</web-resource-name>
<url-pattern>/protected/*</url-pattern>
<url-pattern>/admin/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>manager</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<display-name>Regular User Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/protected/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>employee</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description> An administrator </description>
<role-name>manager</role-name>
</security-role>
<security-role>
<description> A regular user </description>
<role-name>employee</role-name>
</security-role>
管理安全约束
行政区
/保护/*
/管理员/*
删除
得到
邮递
放
经理
没有一个
常规用户安全约束
保护区
/保护/*
得到
邮递
雇员
没有一个
形式
基于表单的身份验证区域
/login.jsp
/error.jsp
管理员
经理
常客
雇员
我又加了一个
标记以指定不同的保护区以及另一个保护区
来指定角色。见下文:
<security-constraint>
<display-name>Admin Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Admin Area</web-resource-name>
<url-pattern>/protected/*</url-pattern>
<url-pattern>/admin/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>manager</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<display-name>Regular User Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>
<url-pattern>/protected/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>employee</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>Form-Based Authentication Area</realm-name>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-role>
<description> An administrator </description>
<role-name>manager</role-name>
</security-role>
<security-role>
<description> A regular user </description>
<role-name>employee</role-name>
</security-role>
管理安全约束
行政区
/保护/*
/管理员/*
删除
得到
邮递
放
经理
没有一个
常规用户安全约束
保护区
/保护/*
得到
邮递
雇员
没有一个
形式
基于表单的身份验证区域
/login.jsp
/error.jsp
管理员
经理
常客
雇员