我有一个使用 jdbcRealm 进行身份验证/授权的小型 Web 应用程序。仅当我将用户名放入 glassfish-web.xml 时,授权才有效
<glassfish-web-app error-url="">
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
<security-role-mapping>
<role-name>connexion</role-name>
<principal-name>test</principal-name>
<group-name>connexion</group-name>
</security-role-mapping>
</glassfish-web-app>
web.xml
<!--other stuff-->
<security-constraint>
<web-resource-collection>
<web-resource-name>secure</web-resource-name>
<url-pattern>/Downloader</url-pattern>
<url-pattern>/start.html</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>connexion</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<realm-name>my_realm</realm-name>
<form-login-config>
<form-login-page>/login.html</form-login-page>
<form-error-page>/error.html</form-error-page>
</form-login-config>
</login-config>
<security-role>
<role-name>connexion</role-name>
</security-role>
<!--other stuff-->
如果我从 glassfish-web 中删除主体,我会收到 403 error access denied 。是否有任何解决方案可以避免在 xml 文件中添加主体?谢谢。