2.5. 配置 Web 应用程序
配置完安全域后,必须将 Web 应用配置为使用这些安全域,才能启用 Kerberos 身份验证。旦对应用进行了更改,便可将它部署到 JBoss EAP 实例,并开始使用 Kerberos 进行身份验证。
必须进行以下更新:
配置
web.xml以使用 SPNEGO 身份验证方法。web.xml文件应包含以下内容:-
带有
<,其中包含一个web-resource-collection> 的 <security-constraint><url-pattern>,它映射到安全区域的 URL 模式。另外,<security-constraint>也可以包含<auth-constraint> 来替代允许的角色。 -
如果在
<auth-constraint>中指定了任何角色,这些角色应在<security-role>中定义。 包含
<,其 确切 值为auth-method> 的 <login-config>SPNEGO。重要<auth-method>元素需要一个以逗号分隔的特定值列表。要使SPNEGO身份验证被正确配置,SPNEGO必须出现在<auth-method>元素中,应首先出现。在将 FORM 登录添加为 Fallback 中讨论合并其他身份验证类型。<security-constraint>和<security-role>元素可让管理员根据 URL 模式和角色设置受限或不受限制的区域。这允许保护或不受保护的资源。示例:
web.xml文件<web-app> <display-name>App1</display-name> <description>App1</description> <!-- Define a security constraint that requires the Admin role to access resources --> <security-constraint> <display-name>Security Constraint on Conversation</display-name> <web-resource-collection> <web-resource-name>exampleWebApp</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>Admin</role-name> </auth-constraint> </security-constraint> <!-- Define the Login Configuration for this Application --> <login-config> <auth-method>SPNEGO</auth-method> <realm-name>SPNEGO</realm-name> </login-config> <!-- Security roles referenced by this web application --> <security-role> <description>Role required to log in to the Application</description> <role-name>Admin</role-name> </security-role> </web-app>
-
带有
配置
jboss-web.xml以使用配置的安全域。jboss-web.xml文件应具有以下内容:-
<security-domain>,用于指定用于身份验证和授权的安全域。 (可选)
<jacc-star-role-allow>,可在web.xml中的 role-name 元素中使用星号字符来匹配多个角色名称。示例:
jboss-web.xml文件<jboss-web> <security-domain>app-spnego</security-domain> <jacc-star-role-allow>true</jacc-star-role-allow> </jboss-web>
-
将 JBoss Negotiation 依赖项添加到传统
安全子系统的部署中。重要如果您使用
elytron子系统,您可以跳过这一步。使用 SPNEGO 和 JBoss Negotiation 的 Web 应用程序需要在
jboss-deployment-structure.xml中定义依赖关系,以便能够找到 JBoss Negotiation 类。由于 JBoss EAP 提供了所有必要的 JBoss 协商和相关类,应用只需将其声明为使用它们的依赖项即可。使用
jboss-deployment-structure.xml 进行Declare 依赖项<jboss-deployment-structure> <deployment> <dependencies> <module name="org.jboss.security.negotiation"/> </dependencies> </deployment> </jboss-deployment-structure>另外,也可以在
META-INF/MANIFEST.MF文件中定义这个依赖项:使用
META-INF/MANIFEST.MF进行依赖Manifest-Version: 1.0 Dependencies: org.jboss.security.negotiation