第 2 章 保护管理界面和应用程序
2.1. 向管理界面添加身份验证和授权
您可以为管理界面添加身份验证和授权,以便使用安全域来保护它们。要在添加身份验证和授权后访问管理界面,用户必须输入登录凭证。
您可以按照以下方法保护 JBoss EAP 管理界面:
管理 CLI
通过配置一个
sasl-authentication-factory
。管理控制台
通过配置一个
http-authentication-factory
.
先决条件
- 您已创建了一个引用安全域的安全域。
- JBoss EAP 正在运行。
流程
创建一个
http-authentication-factory
或sasl-authentication-factory
。创建一个
http-authentication-factory
。语法
/subsystem=elytron/http-authentication-factory=<authentication_factory_name>:add(http-server-mechanism-factory=global, security-domain=<security_domain_name>, mechanism-configurations=[{mechanism-name=<mechanism-name>, mechanism-realm-configurations=[{realm-name=<realm_name>}]}])
Example
/subsystem=elytron/http-authentication-factory=exampleAuthenticationFactory:add(http-server-mechanism-factory=global, security-domain=exampleSecurityDomain, mechanism-configurations=[{mechanism-name=BASIC, mechanism-realm-configurations=[{realm-name=exampleSecurityRealm}]}]) {"outcome" => "success"}
创建一个
sasl-authentication-factory
。语法
/subsystem=elytron/sasl-authentication-factory=<sasl_authentication_factory_name>:add(security-domain=<security_domain>,sasl-server-factory=configured,mechanism-configurations=[{mechanism-name=<mechanism-name>,mechanism-realm-configurations=[{realm-name=<realm_name>}]}])
Example
/subsystem=elytron/sasl-authentication-factory=exampleSaslAuthenticationFactory:add(security-domain=exampleSecurityDomain,sasl-server-factory=configured,mechanism-configurations=[{mechanism-name=PLAIN,mechanism-realm-configurations=[{realm-name=exampleSecurityRealm}]}]) {"outcome" => "success"}
更新管理界面。
使用
http-authentication-factory
来保护管理控制台。语法
/core-service=management/management-interface=http-interface:write-attribute(name=http-authentication-factory, value=<authentication_factory_name>)
Example
/core-service=management/management-interface=http-interface:write-attribute(name=http-authentication-factory, value=exampleAuthenticationFactory) { "outcome" => "success", "response-headers" => { "operation-requires-reload" => true, "process-state" => "reload-required" } }
使用
sasl-authentication-factory
来保护管理 CLI。语法
/core-service=management/management-interface=http-interface:write-attribute(name=http-upgrade,value={enabled=true,sasl-authentication-factory=<sasl_authentication_factory>})
Example
/core-service=management/management-interface=http-interface:write-attribute(name=http-upgrade,value={enabled=true,sasl-authentication-factory=exampleSaslAuthenticationFactory}) { "outcome" => "success", "response-headers" => { "operation-requires-reload" => true, "process-state" => "reload-required" } }
重新加载服务器。
reload
验证
要验证管理控制台是否需要身份验证和授权,请导航到位于
http://127.0.0.1:9990/console/index.html
的管理控制台。会提示您输入用户名和密码。
要验证管理 CLI 是否需要身份验证和授权,请使用以下命令启动管理 CLI:
$ bin/jboss-cli.sh --connect
会提示您输入用户名和密码。