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

          主站蜘蛛池模板: 枣庄市| 监利县| 喜德县| 文化| 新宾| 台前县| 称多县| 罗源县| 屯昌县| 湘阴县| 正阳县| 县级市| 宁河县| 阳原县| 大同县| 都安| 顺平县| 香格里拉县| 西贡区| 宣威市| 耒阳市| 海阳市| 手游| 封丘县| 海伦市| 牙克石市| 辽阳县| 清涧县| 济阳县| 辛集市| 新余市| 安达市| 邯郸县| 大庆市| 昭通市| 荔波县| 灵台县| 容城县| 临泽县| 江孜县| 米林县|