18.14. 身份验证操作
设置密码策略
- 
						将 realm 的 passwordPolicy属性设置为 enumeration 表达式,其中包含特定的策略提供程序 ID 和可选配置。
- 使用以下示例将密码策略设置为默认值。默认值包括: - 27,500 个哈希迭代
- 至少一个特殊字符
- 至少一个大写字母字符
- 至少一个数字字符
- 
								不等于 用户的用户名
- 至少 8 个字符 - kcadm.sh update realms/demorealm -s 'passwordPolicy="hashIterations and specialChars and upperCase and digits and notUsername and length"' - $ kcadm.sh update realms/demorealm -s 'passwordPolicy="hashIterations and specialChars and upperCase and digits and notUsername and length"'- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
- 要使用与默认值不同的值,请在括号中传递配置。
- 使用以下示例将密码策略设置为: - 25,000 个哈希迭代
- 至少两个特殊字符
- 至少两个大写字符
- 至少两个小写字母字符
- 至少两个数字
- 至少 9 个字符
- 
								不等于 用户的用户名
- 不对至少四个更改重复 - kcadm.sh update realms/demorealm -s 'passwordPolicy="hashIterations(25000) and specialChars(2) and upperCase(2) and lowerCase(2) and digits(2) and length(9) and notUsername and passwordHistory(4)"' - $ kcadm.sh update realms/demorealm -s 'passwordPolicy="hashIterations(25000) and specialChars(2) and upperCase(2) and lowerCase(2) and digits(2) and length(9) and notUsername and passwordHistory(4)"'- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
 
获取当前密码策略
				您可以通过过滤除 passwordPolicy 属性以外的所有输出来获取当前的域配置。
			
				例如,显示 demorealm 的 passwordPolicy。
			
kcadm.sh get realms/demorealm --fields passwordPolicy
$ kcadm.sh get realms/demorealm --fields passwordPolicy列出验证流
				在 authentication/flows 端点上运行 get 命令。
			
例如:
kcadm.sh get authentication/flows -r demorealm
$ kcadm.sh get authentication/flows -r demorealm获取特定的身份验证流程
				在 authentication/flows/FLOW_ID 端点上运行 get 命令。
			
例如:
kcadm.sh get authentication/flows/febfd772-e1a1-42fb-b8ae-00c0566fafb8 -r demorealm
$ kcadm.sh get authentication/flows/febfd772-e1a1-42fb-b8ae-00c0566fafb8 -r demorealm列出流的执行
				在 authentication/flows/FLOW_ALIAS/executions 端点上运行 get 命令。
			
例如:
kcadm.sh get authentication/flows/Copy%20of%20browser/executions -r demorealm
$ kcadm.sh get authentication/flows/Copy%20of%20browser/executions -r demorealm在执行中添加配置
- 获取流程的执行。
- 记下流的 ID。
- 
						对 authentication/executions/{executionId}/config端点运行create命令。
例如:
kcadm create "authentication/executions/a3147129-c402-4760-86d9-3f2345e401c7/config" -r examplerealm -b '{"config":{"x509-cert-auth.mapping-source-selection":"Match SubjectDN using regular expression","x509-cert-auth.regular-expression":"(.*?)(?:$)","x509-cert-auth.mapper-selection":"Custom Attribute Mapper","x509-cert-auth.mapper-selection.user-attribute-name":"usercertificate","x509-cert-auth.crl-checking-enabled":"","x509-cert-auth.crldp-checking-enabled":false,"x509-cert-auth.crl-relative-path":"crl.pem","x509-cert-auth.ocsp-checking-enabled":"","x509-cert-auth.ocsp-responder-uri":"","x509-cert-auth.keyusage":"","x509-cert-auth.extendedkeyusage":"","x509-cert-auth.confirmation-page-disallowed":""},"alias":"my_otp_config"}'
$ kcadm create "authentication/executions/a3147129-c402-4760-86d9-3f2345e401c7/config" -r examplerealm -b '{"config":{"x509-cert-auth.mapping-source-selection":"Match SubjectDN using regular expression","x509-cert-auth.regular-expression":"(.*?)(?:$)","x509-cert-auth.mapper-selection":"Custom Attribute Mapper","x509-cert-auth.mapper-selection.user-attribute-name":"usercertificate","x509-cert-auth.crl-checking-enabled":"","x509-cert-auth.crldp-checking-enabled":false,"x509-cert-auth.crl-relative-path":"crl.pem","x509-cert-auth.ocsp-checking-enabled":"","x509-cert-auth.ocsp-responder-uri":"","x509-cert-auth.keyusage":"","x509-cert-auth.extendedkeyusage":"","x509-cert-auth.confirmation-page-disallowed":""},"alias":"my_otp_config"}'获取执行配置
- 获取流程的执行。
- 
						请注意其 authenticationConfig属性,其中包含配置 ID。
- 
						在 authentication/config/ID端点上运行get命令。
例如:
kcadm get "authentication/config/dd91611a-d25c-421a-87e2-227c18421833" -r examplerealm
$ kcadm get "authentication/config/dd91611a-d25c-421a-87e2-227c18421833" -r examplerealm更新执行的配置
- 获取流程的执行。
- 
						获取流程的 authenticationConfig属性。
- 请注意属性中的配置 ID。
- 
						在 authentication/config/ID端点上运行update命令。
例如:
kcadm update "authentication/config/dd91611a-d25c-421a-87e2-227c18421833" -r examplerealm -b '{"id":"dd91611a-d25c-421a-87e2-227c18421833","alias":"my_otp_config","config":{"x509-cert-auth.extendedkeyusage":"","x509-cert-auth.mapper-selection.user-attribute-name":"usercertificate","x509-cert-auth.ocsp-responder-uri":"","x509-cert-auth.regular-expression":"(.*?)(?:$)","x509-cert-auth.crl-checking-enabled":"true","x509-cert-auth.confirmation-page-disallowed":"","x509-cert-auth.keyusage":"","x509-cert-auth.mapper-selection":"Custom Attribute Mapper","x509-cert-auth.crl-relative-path":"crl.pem","x509-cert-auth.crldp-checking-enabled":"false","x509-cert-auth.mapping-source-selection":"Match SubjectDN using regular expression","x509-cert-auth.ocsp-checking-enabled":""}}'
$ kcadm update "authentication/config/dd91611a-d25c-421a-87e2-227c18421833" -r examplerealm -b '{"id":"dd91611a-d25c-421a-87e2-227c18421833","alias":"my_otp_config","config":{"x509-cert-auth.extendedkeyusage":"","x509-cert-auth.mapper-selection.user-attribute-name":"usercertificate","x509-cert-auth.ocsp-responder-uri":"","x509-cert-auth.regular-expression":"(.*?)(?:$)","x509-cert-auth.crl-checking-enabled":"true","x509-cert-auth.confirmation-page-disallowed":"","x509-cert-auth.keyusage":"","x509-cert-auth.mapper-selection":"Custom Attribute Mapper","x509-cert-auth.crl-relative-path":"crl.pem","x509-cert-auth.crldp-checking-enabled":"false","x509-cert-auth.mapping-source-selection":"Match SubjectDN using regular expression","x509-cert-auth.ocsp-checking-enabled":""}}'删除执行的配置
- 获取流程的执行。
- 
						获取 flows authenticationConfig属性。
- 请注意属性中的配置 ID。
- 
						在 authentication/config/ID端点上运行delete命令。
例如:
kcadm delete "authentication/config/dd91611a-d25c-421a-87e2-227c18421833" -r examplerealm
$ kcadm delete "authentication/config/dd91611a-d25c-421a-87e2-227c18421833" -r examplerealm