paulwong

          Keycloak初探

          Keycloak是Jboss出品的做認證和授權的WEB程序,根據OPENIDC協議,OPENID是做認證,OAUTH2.0是做授權,OPENIDC則將這兩者整合。

          有提供一套WEB界面維護用戶、應用與角色。

          Ream則可認為是多租戶,每個租戶的應用和用戶數據是隔離的。

          http://10.80.27.69:8180/auth/realms/quickstart/.well-known/openid-configuration 提供當前所有的API節點。
          get_access_token_from_public_client:
          curl --location --request POST 'http://10.80.27.69:8180/auth/realms/quickstart/protocol/openid-connect/token' \
          --header 'Content-Type: application/x-www-form-urlencoded' \
          --data-urlencode 'username=alice' \
          --data-urlencode 'password=123456' \
          --data-urlencode 'client_id=app-springboot-public' \
          --data-urlencode 'grant_type=password' \
          | jq

          ./get_access_token_from_confidential_client.sh
          curl --location --request POST 'http://10.80.27.69:8180/auth/realms/quickstart/protocol/openid-connect/token' \
          --header 'Content-Type: application/x-www-form-urlencoded' \
          --data-urlencode 'client_id=app-springboot-confidential' \
          --data-urlencode 'client_secret=3acf7692-49cb-4c45-9943-6f3dba512dae' \
          --data-urlencode 'grant_type=client_credentials' \
          | jq

          訪問一個ACCESS TYPE為Bare only的應用的一個API:
          access_token=$(curl \
          -d "client_id=app-springboot-public" \
          -d "username=alice" \
          -d "password=123456" \
          -d "grant_type=password" \
          "http://10.80.27.69:8180/auth/realms/quickstart/protocol/openid-connect/token" \
          | jq -r '.access_token')

          #echo $access_token

          curl -H "Authorization: Bearer $access_token" 'http://10.80.27.69:8182/products' | jq

          訪問用戶信息:
          access_token=$(curl \
          -d "client_id=app-springboot-public" \
          -d "username=alice" \
          -d "password=123456" \
          -d "grant_type=password" \
          "http://10.80.27.69:8180/auth/realms/quickstart/protocol/openid-connect/token" | jq -r '.access_token')


          curl -H "Authorization: Bearer $access_token" http://10.80.27.69:8180/auth/realms/quickstart/protocol/openid-connect/userinfo | jq














          posted on 2020-10-08 13:56 paulwong 閱讀(741) 評論(0)  編輯  收藏 所屬分類: KEYCLOAK

          主站蜘蛛池模板: 龙南县| 奉节县| 五指山市| 昌都县| 大渡口区| 阳谷县| 辛集市| 天柱县| 鄂伦春自治旗| 修武县| 米易县| 巫山县| 札达县| 嘉祥县| 湖口县| 来宾市| 长顺县| 于田县| 宁强县| 巧家县| 象州县| 景泰县| 昌吉市| 昭苏县| 仁化县| 冷水江市| 周宁县| 磴口县| 安顺市| 西峡县| 镇宁| 潜江市| 资讯 | 黄浦区| 曲阜市| 五台县| 瑞昌市| 建昌县| 上杭县| 和政县| 乐平市|