zoukankan      html  css  js  c++  java
  • Keycloak 导入多个领域文件 import multiple realms

    官方文档 https://www.keycloak.org/docs/7.0/server_admin/#admin-console-export-import

    If more than one realm file needs to be imported, a comma separated list of file names can be specified.

    This is more appropriate than the cases before, as this will happen only after the master realm has been initialized.

    Examples:

    • -Dkeycloak.import=/tmp/realm1.json

    • -Dkeycloak.import=/tmp/realm1.json,/tmp/realm2.json

    使用场景:

    在上线前需要在本地新建出不同的realm,然后导出成json配置文件,集成到docker-compose配置文件里,这样发布的时候就可以比较方便,直接部署完就自动新建出不同的realm。

    (0) 启动: docker run -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin  -p 8080:8080 jboss/keycloak

    登录localhost:8080, 先配置realm,新建完导出realm。这里可以新建多个realm,分别导出多个json文件。

    (1)把刚才启动的docker停止,可以直接删除上一步用到的container 也可以先留着:

    删除的命令是 docker rm <container ID>

    (2)新建docker-compose.yml,内容如下, 然后执行启动命令:docker-compose up -d

    version: "3"
    services:
      keycloak:
        image: jboss/keycloak:7.0.0
        ports:
          - "8080:8080"
        volumes:
          - "./imports:/Users/luciawang/workspace/practise/docker-compose/imports/"
        environment:
          - "KEYCLOAK_USER=admin"
          - "KEYCLOAK_PASSWORD=admin"
          - "DB_VENDOR=postgres"
          - "DB_ADDR=postgres"
          - "DB_DATABASE=postgres"
          - "DB_USER=postgres"
          - "DB_PASSWORD=123456"
          - "PROXY_ADDRESS_FORWARDING=true"
          - "KEYCLOAK_IMPORT=/Users/luciawang/workspace/practise/docker-compose/imports/realms.json,/Users/luciawang/workspace/practise/docker-compose/imports/realms1.json" 
        depends_on:
          - postgres
      postgres:
        image: postgres
        ports:
          - "5432:5432"
        environment:
          - "POSTGRES_PASSWORD:123456"

    另一种方式:

    version: "3"
    services:
      keycloak:
        image: jboss/keycloak:7.0.0
        ports:
          - "8080:8080"
        volumes:
          - "./imports:/Users/lucia/workspace/practise/docker-compose/imports/"
        environment:
          - "KEYCLOAK_USER=admin"
          - "KEYCLOAK_PASSWORD=admin"
          - "DB_VENDOR=postgres"
          - "DB_ADDR=postgres"
          - "DB_DATABASE=postgres"
          - "DB_USER=postgres"
          - "DB_PASSWORD=123456"
          - "PROXY_ADDRESS_FORWARDING=true"
        command:
          - "-b 0.0.0.0 -Dkeycloak.import=/Users/lucia/workspace/practise/docker-compose/imports/realms.json,/Users/luciawang/workspace/practise/docker-compose/imports/realms1.json"
        depends_on:
          - postgres
      postgres:
        image: postgres
        ports:
          - "5432:5432"
        environment:
          - "POSTGRES_PASSWORD:123456"

    登录localhost:8080, 进入的用户名密码都是admin,查看一下是否所有的realm都新建成功了

  • 相关阅读:
    pyecharts的版本问题
    世界各国中英文名称映射字典(pyecharts)
    爬取世界疫情数据绘制疫情可视化地图
    好好写,好好干-PHP基础(二)
    自罚一杯-PHP基础(一)
    又是一周-AJAX(三)
    我懒蛋又回来了!-PDO
    退役了退役了-AJAX
    睡觉问题早晚成为我顶头疼的问题。。。-PHP
    其实今天没有欲望..-MySQLi
  • 原文地址:https://www.cnblogs.com/iwangzheng/p/11669812.html
Copyright © 2011-2022 走看看