WSO2 是具有 属性 个文件的自定义身份验证器

WSO2 IS Custom authenticator with property files

我正在 WSO2 IS 5.11 中创建自定义身份验证器,我需要在服务器中创建一些 属性 文件,即 repository/conf/myproperties.properties 以从自定义身份验证器加载它们。我总是得到“访问被拒绝”。如何在服务器中设置此 属性 文件并在自定义身份验证器中正确读取它们?

干杯

  1. 如果你想从一个新的属性文件中加载属性,将文件添加到 IS 的首选位置,并编写逻辑来读取你的文件并将属性加载到数据容器中OSGi 服务激活。 该文件读取和存储逻辑需要在步骤3中提到的activate(ComponentContext ctxt)方法中调用 https://is.docs.wso2.com/en/latest/develop/writing-a-custom-local-authenticator/#configurations.

  2. 作为替代选项,您可以使用 <is-home>/repository/conf/identity/application-authentication.xml 文件来存储您的自定义身份验证器属性。以下配置需要应用到 <is-home>/repository/conf/deployment.toml 文件。 (注意:,应该被替换)

[authentication.authenticator.<cutom_alias>]
name = "<CustomeAuthenticatorName>"
enable = true

[authentication.authenticator.<cutom_alias>.parameters]
param1 = "value1"
param2 = "value2"

该文件读取逻辑已经实现,您可以通过AbstractApplicationAuthenticator中的getAuthenticatorConfig()方法检索参数class。getAuthenticatorConfig().getParameterMap();可用于加载定义的参数。 (例如: https://github.com/wso2-extensions/identity-local-auth-basicauth/blob/6b6ae8d452397f26f948a870e72e8086b46669c9/components/org.wso2.carbon.identity.application.authenticator.basicauth/src/main/java/org/wso2/carbon/identity/application/authenticator/basicauth/BasicAuthenticator.java#L203)