第 2 章 保护服务器及其管理接口的用户


2.1. 使用 Elytron 进行用户身份验证

2.1.1. 默认配置

默认情况下,JBoss EAP 管理接口受传统核心管理身份验证的保护。

示例:默认配置

/core-service=management/management-interface=http-interface:read-resource()
{
    "outcome" => "success",
    "result" => {
        "allowed-origins" => undefined,
        "console-enabled" => true,
        "http-authentication-factory" => undefined,
        "http-upgrade" => {"enabled" => true},
        "http-upgrade-enabled" => true,
        "sasl-protocol" => "remote",
        "secure-socket-binding" => undefined,
        "security-realm" => "ManagementRealm",
        "server-name" => undefined,
        "socket-binding" => "management-http",
        "ssl-context" => undefined
    }
Copy to Clipboard Toggle word wrap

JBoss EAP 在 elytron 子系统中提供 management-http-authentication 和 management-sasl -authentication,以确保管理接口的安全。

更新 JBoss EAP 以使用默认的 Elytron 组件:

  1. http-authentication-factory 设置为使用 management-http-authentication:

    /core-service=management/management-interface=http-interface:write-attribute(name=http-authentication-factory, value=management-http-authentication)
    Copy to Clipboard Toggle word wrap
  2. sasl-authentication-factory 设置为使用 management-sasl-authentication:

    /core-service=management/management-interface=http-interface:write-attribute(name=http-upgrade.sasl-authentication-factory, value=management-sasl-authentication)
    Copy to Clipboard Toggle word wrap
  3. 未定义 安全域

    /core-service=management/management-interface=http-interface:undefine-attribute(name=security-realm)
    Copy to Clipboard Toggle word wrap
  4. 重新载入 JBoss EAP 以使更改生效:
reload
Copy to Clipboard Toggle word wrap

管理接口现在使用 elytron 子系统提供的默认组件进行保护。

2.1.1.1. 默认 Elytron HTTP 身份验证配置

当您通过 http 访问管理界面时,例如使用基于 Web 的管理控制台时,JBoss EAP 将使用 management-http-authentication http- authentication-factory。

/subsystem=elytron/http-authentication-factory=management-http-authentication:read-resource()
{
    "outcome" => "success",
    "result" => {
        "http-server-mechanism-factory" => "global",
        "mechanism-configurations" => [{
            "mechanism-name" => "DIGEST",
            "mechanism-realm-configurations" => [{"realm-name" => "ManagementRealm"}]
        }],
        "security-domain" => "ManagementDomain"
    }
}
Copy to Clipboard Toggle word wrap

management-http-authentication http-authentication-factory 配置为使用 ManagementDomain 安全域。

/subsystem=elytron/security-domain=ManagementDomain:read-resource()
{
    "outcome" => "success",
    "result" => {
        "default-realm" => "ManagementRealm",
        "permission-mapper" => "default-permission-mapper",
        "post-realm-principal-transformer" => undefined,
        "pre-realm-principal-transformer" => undefined,
        "principal-decoder" => undefined,
        "realm-mapper" => undefined,
        "realms" => [
            {
                "realm" => "ManagementRealm",
                "role-decoder" => "groups-to-roles"
            },
            {
                "realm" => "local",
                "role-mapper" => "super-user-mapper"
            }
        ],
        "role-mapper" => undefined,
        "trusted-security-domains" => undefined
    }
}
Copy to Clipboard Toggle word wrap

ManagementDomain 安全域由 ManagementRealm Elytron 安全域提供支持,这是一个基于属性的域。

重要

基于属性的域仅在服务器启动时读取。在服务器启动后添加的任何用户(手动或使用 add-user 脚本)将需要重新加载服务器。此重新加载通过从管理 CLI 运行 reload 命令来完成。

reload
Copy to Clipboard Toggle word wrap
/subsystem=elytron/properties-realm=ManagementRealm:read-resource()
{
    "outcome" => "success",
    "result" => {
        "groups-attribute" => "groups",
        "groups-properties" => {
            "path" => "mgmt-groups.properties",
            "relative-to" => "jboss.server.config.dir"
        },
        "plain-text" => false,
        "users-properties" => {
            "path" => "mgmt-users.properties",
            "relative-to" => "jboss.server.config.dir"
        }
    }
}
Copy to Clipboard Toggle word wrap

2.1.1.2. 默认 Elytron Management CLI 身份验证

默认情况下,管理 CLI(jboss-cli.sh)配置为通过 远程+http 进行连接。

示例:默认的 jboss-cli.xml

<jboss-cli xmlns="urn:jboss:cli:3.1">

    <default-protocol use-legacy-override="true">remote+http</default-protocol>

    <!-- The default controller to connect to when 'connect' command is executed w/o arguments -->
    <default-controller>
        <protocol>remote+http</protocol>
        <host>localhost</host>
        <port>9990</port>
    </default-controller>
Copy to Clipboard Toggle word wrap

这将通过 HTTP 建立连接,并使用 HTTP 升级将通信协议更改为 远程。HTTP 升级连接在 http- interfacehttp-upgrade 部分中使用 sasl-authentication-factory 进行保护

示例:使用默认组件配置

/core-service=management/management-interface=http-interface:read-resource()
{
    "outcome" => "success",
    "result" => {
        "allowed-origins" => undefined,
        "console-enabled" => true,
        "http-authentication-factory" => "management-http-authentication",
        "http-upgrade" => {
            "enabled" => true,
            "sasl-authentication-factory" => "management-sasl-authentication"
        },
        "http-upgrade-enabled" => true,
        "sasl-protocol" => "remote",
        "secure-socket-binding" => undefined,
        "security-realm" => undefined,
        "server-name" => undefined,
        "socket-binding" => "management-http",
        "ssl-context" => undefined
    }
}
Copy to Clipboard Toggle word wrap

默认的 sasl-authentication-factory 是 management-sasl-authentication

/subsystem=elytron/sasl-authentication-factory=management-sasl-authentication:read-resource()
{
    "outcome" => "success",
    "result" => {
        "mechanism-configurations" => [
            {
                "mechanism-name" => "JBOSS-LOCAL-USER",
                "realm-mapper" => "local"
            },
            {
                "mechanism-name" => "DIGEST-MD5",
                "mechanism-realm-configurations" => [{"realm-name" => "ManagementRealm"}]
            }
        ],
        "sasl-server-factory" => "configured",
        "security-domain" => "ManagementDomain"
    }
}
Copy to Clipboard Toggle word wrap

management-sasl-authentication sasl-authentication-factory 指定 JBOSS-LOCAL-USERDIGEST-MD5 机制。

DIGEST-MD5 中使用的 ManagementRealm Elytron 安全域与 management- http-authentication http-authentication- factory 中使用的域相同。

示例: JBOSS-LOCAL-USER Realm

/subsystem=elytron/identity-realm=local:read-resource()
{
    "outcome" => "success",
    "result" => {
        "attribute-name" => undefined,
        "attribute-values" => undefined,
        "identity" => "$local"
    }
}
Copy to Clipboard Toggle word wrap

本地 Elytron 安全域用于处理本地用户的静默身份验证。

2.1.2. 使用新 Identity Store 保护管理接口

  1. 为您的身份存储创建安全域及任何支持的安全域、解码器或映射器。

    此过程将在 JBoss EAP 如何配置身份管理指南的 Elytron 子系统小节中阐述例如,如果要使用基于文件系统的身份存储保护管理接口,请按照使用基于文件系统的身份存储配置身份验证中的步骤进行操作。

  2. 创建 http-authentication-factory 或 sasl-authentication-factory

    示例:http-authentication-factory

    /subsystem=elytron/http-authentication-factory=example-http-auth:add(http-server-mechanism-factory=global, security-domain=exampleSD, mechanism-configurations=[{mechanism-name=DIGEST, mechanism-realm-configurations=[{realm-name=exampleManagementRealm}]}])
    Copy to Clipboard Toggle word wrap

    示例: sasl-authentication-factory

    /subsystem=elytron/sasl-authentication-factory=example-sasl-auth:add(sasl-server-factory=configured, security-domain=exampleSD, mechanism-configurations=[{mechanism-name=DIGEST-MD5, mechanism-realm-configurations=[{realm-name=exampleManagementRealm}]}])
    Copy to Clipboard Toggle word wrap

  3. 将 pattern-filter 添加到 配置的 可配置-sasl-server-factory 中。

    示例:将 GSSAPI 添加到配置的可配置-sasl-server-factory

    /subsystem=elytron/configurable-sasl-server-factory=configured:list-add(name=filters, value={pattern-filter=GSSAPI})
    Copy to Clipboard Toggle word wrap

    这是可选步骤。当客户端尝试连接 HTTP 管理接口时,JBoss EAP 会发回 HTTP 响应,其状态代码为 401 Unauthorized,还有一组列出受支持的身份验证机制的标头,如 Digest、GSSAPI 等。如需更多信息,请参阅 JBoss EAP 安全架构指南中的使用 HTTP 接口进行本地和远程客户端身份验证一节

  4. 更新管理接口,以使用 http-authentication-factory 或 sasl-authentication-factory

    示例:更新 http-authentication-factory

    /core-service=management/management-interface=http-interface:write-attribute(name=http-authentication-factory, value=example-http-auth)
    
    reload
    Copy to Clipboard Toggle word wrap

    示例:更新 sasl-authentication-factory

    /core-service=management/management-interface=http-interface:write-attribute(name=http-upgrade.sasl-authentication-factory, value=example-sasl-auth)
    
    reload
    Copy to Clipboard Toggle word wrap

    注意

    使用传统核心管理身份验证时,您只能通过单个传统安全域保护 http 管理接口。这会强制 HTTP 和 SASL 配置出现在单个传统安全域中。在使用 elytron 子系统时,您可以单独配置 http-authentication-factorysasl-authentication-factory,允许您使用不同的安全域来保护 http 管理界面的 HTTP 和 SASL 机制。

注意

如果管理界面中分别配置了在传统安全性和 Elytron 中实施相同的两个不同属性,则仅使用与 Elytron 相关的配置。例如,如果配置了传统安全性的 security -realm 和 Elytron 的 http-authentication-factory,则身份验证由 http-authentication-factory 配置来处理。

注意

当管理接口同时包含 http-authentication-factorysasl-authentication-factory (用于 HTTP 接口)以及 security-realm,并且不使用 ssl-context 属性时,身份验证由 Elytron 处理,并且 SSL 由旧安全域处理。

当管理接口同时包含 security-realmssl-context,以及 http-authentication-factory 或 sasl-authentication-factory 时,没有使用 HTTP 接口的 security-realm 和ssl-context,则身份验证由 Elytron 处理。

2.1.3. 添加 Silent 身份验证

默认情况下,JBoss EAP 提供了一种通过 本地 安全域供本地用户(也称为静默身份验证)的身份验证机制。您可以在 Silent Authentication 部分中找到有关静默身份验证的更多详细信息。

必须将静默身份验证添加到 sasl-authentication-factory 中。

在现有的 sasl-authentication-factory 中添加静默身份验证:

/subsystem=elytron/sasl-authentication-factory=example-sasl-auth:list-add(name=mechanism-configurations, value={mechanism-name=JBOSS-LOCAL-USER, realm-mapper=local})

reload
Copy to Clipboard Toggle word wrap

使用静默身份验证创建新的 sasl-server-factory

/subsystem=elytron/sasl-authentication-factory=example-sasl-auth:add(sasl-server-factory=configured,security-domain=ManagementDomain,mechanism-configurations=[{mechanism-name=DIGEST-MD5,mechanism-realm-configurations=[{realm-name=exampleManagementRealm}]},{mechanism-name=JBOSS-LOCAL-USER, realm-mapper=local}])

reload
Copy to Clipboard Toggle word wrap
注意

上例使用现有的 ManagementDomain 安全域,但您也可以创建和使用其他安全域。您可以在 JBoss EAP 如何配置身份管理指南的 Elytron Subsystem 部分中找到创建安全域的更多示例

重要

如果使用 Elytron 安全性,并且尝试使用带有身份验证名称的 JBOSS-LOCAL-USER SASL 机制进行身份验证,则身份验证会失败。

可以通过传统的 security 子系统为 JBOSS-LOCAL-USER 选择自定义用户名。身份验证通过将用户名映射到特殊身份进行

2.1.4. 映射经过身份验证的管理用户的身份

在使用 elytron 子系统来保护管理接口时,您可以将安全域提供给管理接口,以进行经过身份验证的用户的身份映射。这使得经过身份验证的用户在登录管理界面时能够使用适当的身份显示。

应用服务器公开多种管理接口。每种类型的接口可以与独立 的身份验证事实关联, 以处理该接口的身份验证要求。

为了做出授权决定,从安全域获取当前的安全身份。返回的安全身份具有角色映射和权限分配,具体取决于该安全域中定义的规则。

注意

在大多数情况下,常用的安全域用于所有管理;用于管理接口的身份验证以及获取用于授权决策的安全身份。在这些情况下,安全域与管理接口的身份验证工厂关联,无需定义特殊 access=identity

在某些情况下,使用不同的安全域来获取授权决策的身份。这里定义了 access=identity 资源。它包含对安全域的引用,以获取用于授权的身份。

以下示例假设您已使用 exampleSD Elytron 安全域保护管理接口,并将其公开为 exampleManagementRealm

要定义身份映射,请将 identity 资源添加到管理接口。

示例:添加 身份 资源

/core-service=management/access=identity:add(security-domain=exampleSD)
Copy to Clipboard Toggle word wrap

添加 身份 资源后,访问管理界面时,经过身份验证的用户的身份将显示。如果未添加 身份 资源,则使用用于身份验证的安全域的身份。

例如,如果以 user1 身份登录管理 CLI,则身份将正确显示。

示例:通过管理 CLI 显示经过身份验证的用户的身份

:whoami
{
    "outcome" => "success",
    "result" => {"identity" => {"username" => "user1"}}
}
Copy to Clipboard Toggle word wrap

重要

如果添加了 身份 资源,并且使用传统安全域来保护管理接口,经过身份验证的用户将始终具有 匿名 身份。删除 身份 资源后,从传统安全域进行身份验证的用户将显示具有适当身份的用户。

管理操作的授权始终使用安全域,即 access=identity 中指定的域。如果未指定,则它是用于身份验证的域。任何角色映射都始终在安全域的上下文中。

当前请求 的身份 资源将返回一组使用 Elytron 配置映射的角色。使用基于 RBAC 的角色映射定义时,来自 身份 资源的角色将取为组,并注入到管理 角色映射中,以获取 当前请求的管理角色。

Expand
表 2.1. 用于不同场景的身份
场景没有 access=identity 定义access=identity 引用 Elytron security-domain

使用传统 security-realm的 HTTP 管理接口

来自连接的身份.

不受支持的或匿名身份.

使用由 security-domain支持的 elytron HTTP 身份验证工厂的 HTTP 管理接口

来自连接的身份.

如果已成功溢出,来自引用的 security-domain 的身份。

原生管理,包括使用传统安全域的 HTTP 升级接口

来自连接的身份.

不受支持的或匿名身份.

使用由 security-domain支持的 elytron SASL 身份验证工厂的原生管理(包括 HTTP 升级)

来自连接的身份.

如果已成功溢出,来自引用的 security-domain 的身份。

注意

如果 身份 资源中使用的安全域不信任来自身份验证的安全域,则会使用匿名身份。

当它们都使用相同的安全域时,身份 资源中使用的安全域不需要从身份验证中信任安全域。

受信任的安全域不是传递性的安全域。

如果不定义 access=identity 资源,则将使用针对管理接口的身份验证期间建立的身份。使用连接(通过远程子系统或使用应用 创建的身份在此情形中不可用。

如果定义了 access=identity 资源,但管理接口使用的安全域不同,且未在域列表中列出,则不会建立任何身份。将使用身份验证期间创建的身份尝试一个内流。使用通过远程 子系统 或使用连接建立的身份不会以这种方式溢出。

重要

如果管理接口使用旧安全域进行保护,则身份在不同的安全域之间不可硬性。在这种情况下,不应定义 access=identity 资源。因此,身份验证期间建立的身份可以直接使用。因此,使用 PicketBox 保护的应用程序不支持 身份 资源。

2.1.5. 通过管理 CLI 使用 Elytron 客户端

您可以配置管理 CLI,以使用 Elytron 客户端在连接 JBoss EAP 时提供安全信息。

  1. 通过 Elytron 保护管理接口.

    若要将 Elytron 客户端与管理 CLI 搭配使用,您必须使用 Elytron 保护管理接口。您可以找到有关使用 Elytron 在用户身份验证中使用 Elytron 保护管理接口的更多详细信息。

  2. 创建 Elytron 客户端配置文件。

    您需要创建存放身份验证配置的 Elytron 客户端配置文件以及使用该配置的规则。您可以在 JBoss EAP 如何配置身份管理指南的"配置文件方法 "一节中找到有关创建身份验证配置的更多详细信息

    示例: custom-config.xml

    <configuration>
        <authentication-client xmlns="urn:elytron:client:1.2">
            <authentication-rules>
                <rule use-configuration="configuration1">
                    <match-host name="localhost" />
                </rule>
            </authentication-rules>
            <authentication-configurations>
                <configuration name="configuration1">
                    <sasl-mechanism-selector selector="DIGEST-MD5" />
                    <providers>
                      <use-service-loader />
                    </providers>
                    <set-user-name name="user1" />
                    <credentials>
                        <clear-password password="password123" />
                    </credentials>
                    <set-mechanism-realm name="exampleManagementRealm" />
                 </configuration>
            </authentication-configurations>
        </authentication-client>
    </configuration>
    Copy to Clipboard Toggle word wrap

  3. 通过管理 CLI 脚本,使用 Elytron 客户端配置文件。

    $ ./jboss-cli.sh -c  -Dwildfly.config.url=/path/to/custom-config.xml
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat