AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1076851
Accepted
McLayn
McLayn
Asked: 2021-09-08 01:37:33 +0800 CST2021-09-08 01:37:33 +0800 CST 2021-09-08 01:37:33 +0800 CST

Wildfly Standalone.xml - 从 elytron 凭证存储向 KeyCloak SPI 传递秘密

  • 772

我正在将 KeyCloak v15 (WildFly v23) 密码从旧保险库迁移到 elytron 凭证存储。它适用于标准用例。在standalone.xml中,我有 /server/extensions/extension:

<extension module="org.wildfly.extension.elytron"/>

/server/profile/subsystem:

<subsystem xmlns="urn:wildfly:elytron:13.0" final-providers="elytron" disallowed-providers="OracleUcrypto">
    <providers>
        <provider-loader name="elytron" module="org.wildfly.security.elytron"/>
    </providers>
    <audit-logging>
        <file-audit-log name="local-audit" path="audit-log.log" relative-to="jboss.server.log.dir" format="JSON"/>
    </audit-logging>
    <credential-stores>
        <credential-store name="credStore" location="/data/credStore.jceks">
            <implementation-properties>
                <property name="keyStoreType" value="JCEKS"/>
            </implementation-properties>
            <credential-reference clear-text="MASK-123456789;salt123;42"/>
        </credential-store>
    </credential-stores>
</subsystem>

我使用以下方式访问密码 /server/profile/subsystem[@xmlns="urn:jboss:domain:jgroups:8.0"]/stacks/stack[@name="tcp"]/auth-protocol/digest-token/shared-secret-reference:

<shared-secret-reference store="credStore" alias="myBlock::mySecret"/>

但是,我需要将一个秘密传递给属性中的 SPI。知道怎么做吗?这是旧的保险库方式:

/server/system-properties/property:

<property name="secret" value="${VAULT::myBlock::mySecret::1}"/>

/server/profile/subsystem[@xmlns="urn:jboss:domain:keycloak-server:1.1"]/spi:

<spi name="mySpi">
    <provider name="file" enabled="true">
        <properties>
            <property name="password" value="${secret}"/>
        </properties>
    </provider>
</spi>
configuration keycloak wildfly
  • 2 2 个回答
  • 403 Views

2 个回答

  • Voted
  1. McLayn
    2021-09-15T10:06:27+08:002021-09-15T10:06:27+08:00

    我发现了两种可能性:

    1. 重写 SPI 以直接从 Java 中的 Elytron 凭证存储中检索秘密
    2. 预先设置环境变量 ( export SECRET="$(secret-getter-script)") 并使用变量 in standalone.xml:
    <spi name="mySpi">
        <provider name="file" enabled="true">
            <properties>
                <property name="password" value="${env.SECRET}"/>
            </properties>
        </provider>
    </spi>
    
    • 0
  2. Best Answer
    McLayn
    2021-11-10T04:30:52+08:002021-11-10T04:30:52+08:00

    我不得不重写我们的 SPI 来读取 Elytron 凭证存储内容:

    import org.jboss.as.server.CurrentServiceContainer;
    import org.jboss.msc.service.ServiceController;
    import org.jboss.msc.service.ServiceName;
    import org.jboss.msc.service.ServiceRegistry;
    import org.wildfly.security.credential.PasswordCredential;
    import org.wildfly.security.credential.store.CredentialStore;
    import org.wildfly.security.credential.store.CredentialStoreException;
    import org.wildfly.security.password.Password;
    import org.wildfly.security.password.interfaces.ClearPassword;
    
      private static String getClientSecret(String credentialStore, String secretAlias) {
        final ServiceName SERVICE_NAME_CRED_STORE = ServiceName.of("org", "wildfly", "security", "credential-store");
        final ServiceName sn = ServiceName.of(SERVICE_NAME_CRED_STORE, credentialStore);
        final ServiceRegistry registry = CurrentServiceContainer.getServiceContainer();
        final ServiceController<?> credStoreService = registry.getService(sn);
        final CredentialStore cs = (CredentialStore) credStoreService.getValue();
    //    if (!cs.exists(secretAlias, PasswordCredential.class)) {
    //      throw new CredentialStoreException("Alias " + secretAlias + " not found in credential store.");
    //    }
        final Password password;
        try {
          password = cs.retrieve(secretAlias, PasswordCredential.class).getPassword();
        } catch (CredentialStoreException e) {
          e.printStackTrace();
          return null;
        }
        if (!(password instanceof ClearPassword)) {
          throw new ClassCastException("Password is not of type ClearPassword");
        }
        return new String(((ClearPassword) password).getPassword());
      }
    
    • 0

相关问题

  • 小型企业的服务器虚拟化/RAID 配置

  • httpd.conf 用于不区分大小写的文件服务

  • Windows Server 2003 DNS 添加的 CNAME 不起作用

  • 我应该使用什么策略在 linux 上安装 smtp 服务器?用于多线程服务

  • 为什么我的站点在配置为直通身份验证时使用 IUSR 帐户?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve