16.2. 管理端点和管理控制台
默认情况下,Red Hat Single Sign-On 会公开管理 REST API 和 Web 控制台与非管理员用户使用情况相同的端口。如果不需要外部访问,请不要在外部公开管理端点。如果您需要外部公开管理端点,您可以直接在 Red Hat Single Sign-On 中公开它们,或使用代理。
要使用代理公开端点,请参阅代理的文档。您需要控制对 /auth/admin 端点的请求的访问。
Red Hat Single Sign-On 中有两个选项直接公开端点,IP 限制和单独的端口。
当在 Red Hat Single Sign-On 的前端 URL 上无法访问 Admin Console 时,在默认主机名供应商中配置固定的 admin URL。
16.2.1. IP 限制 复制链接链接已复制到粘贴板!
您可以将 /auth/admin 访问权限限制为特定的 IP 地址。例如,将 /auth/admin 的访问权限限制为 10.0.0.1 到 10.0.0.255 的 IP 地址。
<subsystem xmlns="urn:jboss:domain:undertow:12.0">
...
<server name="default-server">
...
<host name="default-host" alias="localhost">
...
<filter-ref name="ipAccess"/>
</host>
</server>
<filters>
<expression-filter name="ipAccess" expression="path-prefix('/auth/admin') -> ip-access-control(acl={'10.0.0.0/24 allow'})"/>
</filters>
...
</subsystem>
您还可以使用这些 CLI 命令限制对特定 IP 地址的访问:
/subsystem=undertow/configuration=filter/expression-filter=ipAccess:add(,expression="path-prefix[/auth/admin] -> ip-access-control(acl={'10.0.0.0/24 allow'})")
/subsystem=undertow/server=default-server/host=default-host/filter-ref=ipAccess:add()
对于使用代理的 IP 限制,请配置代理以确保 Red Hat Single Sign-On 接收客户端 IP 地址,而不是代理 IP 地址。
16.2.2. 端口限制 复制链接链接已复制到粘贴板!
您可以将 /auth/admin 公开给不同的非公开端口。例如,在端口 8444 上公开 /auth/admin,并阻止访问默认端口 8443。
<subsystem xmlns="urn:jboss:domain:undertow:12.0">
...
<server name="default-server">
...
<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
<https-listener name="https-admin" socket-binding="https-admin" security-realm="ApplicationRealm" enable-http2="true"/>
<host name="default-host" alias="localhost">
...
<filter-ref name="portAccess"/>
</host>
</server>
<filters>
<expression-filter name="portAccess" expression="path-prefix('/auth/admin') and not equals(%p, 8444) -> response-code(403)"/>
</filters>
...
</subsystem>
...
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
...
<socket-binding name="https" port="${jboss.https.port:8443}"/>
<socket-binding name="https-admin" port="${jboss.https.port:8444}"/>
...
</socket-binding-group>
您可以在端口 8444 上公开 /auth/admin,并使用 CLI 命令阻止访问默认端口 8443 :
/socket-binding-group=standard-sockets/socket-binding=https-admin/:add(port=8444)
/subsystem=undertow/server=default-server/https-listener=https-admin:add(socket-binding=https-admin, security-realm=ApplicationRealm, enable-http2=true)
/subsystem=undertow/configuration=filter/expression-filter=portAccess:add(,expression="path-prefix('/auth/admin') and not equals(%p, 8444) -> response-code(403)")
/subsystem=undertow/server=default-server/host=default-host/filter-ref=portAccess:add()