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 閱讀(738) 評論(0)  編輯  收藏 所屬分類: KEYCLOAK

          主站蜘蛛池模板: 盘锦市| 商丘市| 鸡泽县| 炎陵县| 建瓯市| 神木县| 承德市| 六安市| 望江县| 岳阳市| 普宁市| 博客| 吴旗县| 抚宁县| 三河市| 岢岚县| 裕民县| 定兴县| 哈巴河县| 晋城| 富蕴县| 张家界市| 上饶县| 长春市| 德令哈市| 钟祥市| 吕梁市| 新化县| 通辽市| 丹江口市| 中阳县| 彭泽县| 海晏县| 保康县| 晴隆县| 松桃| 宜兰县| 西藏| 新竹市| 武威市| 巴青县|