当前位置: 首页 > 知识库问答 >
问题:

使用Elytron的WIldfly和JavaEE安全配置

尉迟禄
2023-03-14

我试图更加熟悉Wildfly的安全配置,但在理解standalone.xml等服务器端配置和web.xml和jboss-web.xml等应用程序端配置中的选项之间的关系时遇到了一些问题。

我对这个基于Wildfly servlet安全示例的配置有几个问题。我已经尝试了,它的工作,但有几件事对我来说不清楚。

    null
# 1. Add the JDBC security realm creation
/subsystem=elytron/jdbc-realm=servlet-security-jdbc-realm:add(\
principal-query=[\
{sql="SELECT PASSWORD FROM USERS WHERE USERNAME = ?", data-source="MySQLDS", clear-password-mapper={password-index=1}},\
{sql="SELECT R.NAME, 'Roles' FROM USERS_ROLES UR INNER JOIN ROLES R ON R.ID = UR.ROLE_ID INNER JOIN USERS U ON U.ID = UR.USER_ID WHERE U.USERNAME = ?", data-source="MySQLDS", attribute-mapping=[{index=1, to=roles}]}])

# 2. Add a simple role decoder for the "roles" attribute mapping
/subsystem=elytron/simple-role-decoder=from-roles-attribute:add(attribute=roles)

# 3. Configure the servlet-security-quickstart security domain
/subsystem=elytron/security-domain=servlet-security-quickstart-sd:add(\
default-realm=servlet-security-jdbc-realm, \
realms=[{realm=servlet-security-jdbc-realm, role-decoder=from-roles-attribute}], \
permission-mapper=default-permission-mapper)

# 4. Configure the HTTP Authentication Factory
/subsystem=elytron/http-authentication-factory=servlet-security-quickstart-http-auth:add(\
http-server-mechanism-factory=global,\
security-domain=servlet-security-quickstart-sd,\
mechanism-configurations=[{mechanism-name=BASIC,mechanism-realm-configurations=[{realm-name=RealmUsersRoles}]}])

# 5. Configure Undertow's application security domain
/subsystem=undertow/application-security-domain=servlet-security-quickstart:add(\
http-authentication-factory=servlet-security-quickstart-http-auth)

web.xml

<?xml version="1.0"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">

    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>RealmUsersRoles</realm-name>
    </login-config>
</web-app>

jboss-web.xml

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <security-domain>servlet-security-quickstart</security-domain>
</jboss-web>

这里有一个Wildfly示例的链接,我将其用作基础https://github.com/Wildfly/quickstart/tree/master/servlet-security

共有1个答案

薛烨霖
2023-03-14
  1. 您需要在服务器配置中配置身份验证的基本类型,而不需要在web.xml
  2. 中配置 <理>境界的名称并不重要。当您获得 401 unauthorized( www-authenticate标头)时,它就会显示在浏览器中。如果在 web.xml中配置了ream名称,则使用该名称,否则使用服务器配置中的名称。
 类似资料:
  • 我试图变得更熟悉WildFly安全配置,并有一些问题与理解之间的关系选项在服务器端配置像和应用程序端配置像和。 我有几个关于这个配置的问题,它是基于Wildfly servlet安全示例的。我已经试用过了,它很有效,但是有几件事对我来说还不清楚。 我如何看待身份验证的基本类型是在服务器端的身份验证工厂和web中定义的。应用程序端的xml。哪一个有优先权。必须申报两次吗 “RealmUsersRol

  • 我试图在Wildfly25上的Elytron上配置LDAPS,我不知道我错过了什么。

  • 我正在努力将Wildfly 12/14 Elytron Ldap身份验证机制引入到我的两个webapps应用程序中。 虽然我已经通过jboss-cli.sh按照Wildfly文档中的步骤成功地部署了DirContext、LdapRealm、SecurityDomain等,但是当我在“web-inf/jboss-web.xml”中添加标记并启动容器时,我会得到以下错误: 注意:即使将“standal

  • 直到现在(遗留),身份验证工作所需的全部工作就是在subsystems->Security中创建一个具有正确名称的安全域(“referencesapplicationdomain”)。 我的web.xml: 我的jboss-web.xml: 我遵循Wildfly Elytron文档使用JBoss-CLI创建了安全域和http工厂。 当我签入jboss-cli时,我看到安全域已经创建。 然而,当我尝

  • WildFly中安全域和安全域的主要区别是什么? 独立的。xml 和

  • 在这里,我已经设置了默认的安全域 以下是我在web.xml中的配置: 以下是AIS.Properties中的配置: UserBean登录功能: 它给了我以下例外: