Liberty 儲存庫[8.5.5.4 或更新版本]

將「OpenID Connect 提供者」配置成接受用戶端登錄要求

用戶端登錄端點是管理者所管理的服務,用來登錄、更新、刪除和擷取打算使用「OpenID Connect 提供者」之「OpenID Connect 依賴方」的相關資訊。登錄程序可進而提供資訊供「依賴方」使用,包括 OAuth 2.0 用戶端 ID 和用戶端密碼(如果沒有指定的話)。

開始之前

用戶端登錄服務是在下列兩種模式之一下運作:本端儲存庫或資料庫儲存庫:這些模式取決於 Liberty 伺服器如何配置其用戶端儲存庫,亦即,在 server.xml 檔中是使用 oauthProvider localStore 屬性(本端儲存庫)來定義用戶端,或是使用資料庫(資料庫儲存庫)來配置用戶端。

在本端儲存庫配置中,用戶端登錄服務受限於只能擷取「OpenID Connect 依賴方」資訊。您可以修改 server.xml 檔,以新增用來登錄、更新或刪除「OpenID Connect 依賴方」等其他作業。

在資料庫儲存庫配置中,用戶端登錄服務並無任何限制,所有作業都是透過 REST 介面來運作。

註: Liberty 伺服器不得將其用戶端儲存庫同時配置成使用本端儲存庫和資料庫儲存庫。只能選擇一種配置路徑。

用戶端登錄端點是受保護的管理端點,並具備 clientManager 角色。如果要存取這個端點,使用者必須獲得管理者授與 clientManager 角色。

clientManager 角色是定義給 oauthProvider 的其中一個 oauth-roles。以下是範例配置,顯示將 clientManager 角色授與使用者 Alice 或 clientAdministrator 群組中的成員。

<oauth-roles>
<authenticated>
<special-subject type="ALL_AUTHENTICATED_USERS" />
</authenticated>
<clientManager>
<group name="clientAdministrator" />
<user name="Alice" />
</clientManager>
</oauth-roles>

關於這項作業

「OpenID Connect 依賴方」的相關用戶端登錄資訊大量用來定義用戶端的使用實務限制。此外,用戶端所看不到的其他 OP 作業會使用用戶端登錄 meta 資料來做出授權決策。

下列範例假設 Liberty OP 是配置成使用 SSL 埠 443。

https://server.example.com:443/oidc/endpoint/<provider_name>/registration

上述範例亦假設 server.xml 檔是配置成使用使用者名稱 clientAdmin 和密碼 clientAdminPassword,並使用 oauth-roleclientManager

用戶端登錄 meta 資料由下列參數組成:

表 1. 用戶端登錄參數
屬性名稱 資料類型 必要/選用 說明
client_id 輸入/輸出 選用 要向 OP 登錄的用戶端 ID。除非另有指定,依預設,會在登錄期間產生這個參數值。這是字串。
client_secret 輸入/輸出 選用 向 OP 登錄的用戶端密碼。除非另有指定,依預設,會在登錄期間產生這個參數值。這是字串。在更新作業期間,參數值 '*' 會保留現有的值。空白參數值會產生新的 client_secret。非空白參數值會以新指定的值置換現有的值。
client_name 輸入/輸出 選用 要向 OP 登錄之用戶端的說明。除非另有指定,依預設,這個參數會設為 client_id 參數值。這是字串。
application_type 輸入 選用 說明用戶端的應用程式類型。除非另有指定,預設值為 web。這是字串。例如,可能的值如下:
  • <an empty value is valid>
  • web
  • native
response_types 輸入 選用 這個用戶端使用的回應類型限制。除非另有指定,預設值為 code。這是 JSON 陣列。例如,可能的值如下:
  • <an empty value is valid>
  • code
  • token
  • id_token token(順序可顛倒)

如果是特定 response_type,必須指定對應的 grant_types。如需相關資訊,請參閱 Client Metadata 網站上的 response_types

grant_types 輸入 選用 這個用戶端使用的授權類型限制。除非另有指定,預設值為 authorization_code。這是 JSON 陣列。例如,可能的值如下:
  • <an empty value is valid>
  • authorization_code
  • implicit
  • refresh_token
  • client_credentials
  • urn:ietf:params:oauth:grant-type:jwtbearer
  • password
redirect_uris 輸入 選用 限制用戶端的重新導向 URI 陣列。這是 JSON 陣列。
post_logout_redirect_uris 輸入 選用 限制用戶端登出後的重新導向 URI 陣列。這是 JSON 陣列。
trusted_uri_prefixes 輸入 選用 用戶端視為可安全傳送存取記號的授信 URI 字首陣列。這是 JSON 陣列。
scope 輸入 選用 限制用戶端的範圍值(以空格分隔)。這是字串。如果容許用戶端要求任何範圍,可以使用值 ALL_SCOPES
preauthorized_scope 輸入 選用 預先授權給用戶端而不需要使用者同意的範圍值(以空格分隔)。這是字串。
subject_type 輸入 選用 用戶端所說明的主體類型限制。這是字串。例如,可能的值如下:
  • <an empty value is valid>
  • public
token_endpoint_auth_method 輸入 選用 用戶端使用的記號端點鑑別方法限制。除非另有指定,預設值為 client_secret_basic。這是字串。例如,可能的值如下:
  • <an empty value is valid>
  • client_secret_basic
  • client_secret_post
  • none
functional_user_id 輸入 選用 這個參數指出在 client_credentials 授權類型中,哪個使用者 ID 與代表用戶端發出的要求相關聯。這是字串。
functional_user_groupIds 輸入 選用 當這個用戶端使用用戶端認證授權類型取得存取記號時,與這些存取記號相關聯的群組 ID 清單。值會是功能使用者所屬的群組 ID 清單,其中,群組 ID 是區分大小寫的字串。字串由授權伺服器定義。如果值含有多個群組 ID,其順序並不重要。如果清單是空的,會省略聲明。當指定這個用戶端 meta 資料參數時,內部檢查端點會針對簽發給這個用戶端(具有用戶端認證授權)的存取記號,在 functional_user_groupIds 回應參數中傳回值。如果沒有使用 functional_user_id 參數,會忽略這個參數。
註: 授權伺服器不得信任用戶端自行主張這個參數。
introspect_tokens 輸入 選用 這個參數值指出指定的用戶端是否有權內部檢查 OP 簽發的存取記號。這是布林值。
registration_client_uri 僅輸出 N/A 放在回應中傳回的參數,其值指出已登錄用戶端的唯一 URL。這是字串。
client_secret_expires_at 僅輸出 N/A 放在回應中傳回的參數,其值指出用戶端密碼的有效秒數,時間從 1970-01- 01T0:0:0Z 算起,並以 UTC(世界標準時間)測量。值 0 表示沒有有效期限。
client_id_issued_at 僅輸出 N/A 放在回應中傳回的參數,其值指出簽發用戶端 ID 的秒數,時間從 1970-01- 01T0:0:0Z 算起,並以 UTC(世界標準時間)測量。值 0 表示未識別用戶端 ID 簽發時間。

程序

  1. 登錄用戶端,如下列範例所示:

    要求標頭:

    POST https://server.example.com:443/oidc/endpoint/<provider_name>/registration
    Accept: application/json
    Content-Type: application/json
    Authorization: Basic Y2xpZW50QWRtaW46Y2xpZW50QWRtaW5QYXNzd29yZA==

    要求內容:

    {
       "token_endpoint_auth_method":"client_secret_basic",
       "scope":"openid profile email general",
       "grant_types":[
          "authorization_code",
          "client_credentials",
          "implicit",
          "refresh_token",
          "urn:ietf:params:oauth:grant-type:jwt-bearer"
       ],
       "response_types":[
          "code",
          "token",
          "id_token token"
       ],
       "application_type":"web",
       "subject_type":"public",
       "post_logout_redirect_uris":[
          "https://server.example.com:9000/logout/",
          "https://server.example.com:9001/exit/"
       ],
       "preauthorized_scope":"openid profile email general",
       "introspect_tokens":true,
       "trusted_uri_prefixes":[
          "https://server.example.com:9000/trusted/"
       ],
       "redirect_uris":[
          "https://server.example.com:443/resource/redirect1",
          "https://server.example.com:9000/resource/redirect2"
       ]
    }

    回應標頭:

    Status: 201
    Cache-Control: private
    ETag: "1B2M2Y8AsgTpgAmY7PhCfg=="
    Content-Type: application/json

    回應內文:

    {
       "client_id_issued_at":1401776782,
       "registration_client_uri":"https://server.example.com:8020/oidc/endpoint/OIDC/registration/b0a376ec4b694b67b6baeb0604a312d8",
       "client_secret_expires_at":0,
       "token_endpoint_auth_method":"client_secret_basic",
       "scope":"openid profile email general",
       "grant_types":[
          "authorization_code",
          "client_credentials",
          "implicit",
          "refresh_token",
          "urn:ietf:params:oauth:grant-type:jwt-bearer"
       ],
       "response_types":[
          "code",
          "token",
          "id_token token"
       ],
       "application_type":"web",
       "subject_type":"public",
       "post_logout_redirect_uris":[
          "https://server.example.com:9000/logout/",
          "https://server.example.com:9001/exit/"
       ],
       "preauthorized_scope":"openid profile email general",
       "introspect_tokens":true,
       "trusted_uri_prefixes":[
          "https://server.example.com:9000/trusted/"
       ],
       "client_id":"b0a376ec4b694b67b6baeb0604a312d8",
       "client_secret":"nmrOQ20CrMdwd4pjqaimutZTcbQPzIoYgItjaccb9Wk33rKarhM3WDLmWIoE",
       "client_name":"b0a376ec4b694b67b6baeb0604a312d8",
       "redirect_uris":[
          "https://server.example.com:443/resource/redirect1",
          "https://server.example.com:9000/resource/redirect2"
       ]
    }
  2. 更新用戶端,如下列範例所示:

    要求標頭:

    PUT https://server.example.com:443/oidc/endpoint/<provider_name>/registration/registration/b0a376ec4b694b67b6baeb0604a312d8
    Accept: application/json
    Content-Type: application/json
    Authorization: Basic Y2xpZW50QWRtaW46Y2xpZW50QWRtaW5QYXNzd29yZA==

    要求內容:

    {
       "token_endpoint_auth_method":"client_secret_basic",
       "scope":"openid profile",
       "grant_types":[
          "authorization_code"
       ],
       "response_types":[
          "code"
       ],
       "application_type":"native",
       "subject_type":"public",
       "post_logout_redirect_uris":[
          "https://server.example.com:9000/logout/"
       ],
       "preauthorized_scope":"openid",
       "introspect_tokens":false,
       "trusted_uri_prefixes":[
          "https://server.example.com:9003/trusted/"
       ],
       "client_id":"b0a376ec4b694b67b6baeb0604a312d8",
       "client_secret":"*",
       "client_name":"updated client",
       "redirect_uris":[
          "https://server.example.com:443/resource/redirect1"
       ]
    }

    回應標頭:

    Status: 200
    ETag: "3DD7affTGS91mfhPZ83B39Y=="
    Content-Type: application/json

    回應內文:

    {
       "client_id_issued_at":1401776782,
       "registration_client_uri":"https://server.example.com:8020/oidc/endpoint/OIDC/registration/b0a376ec4b694b67b6baeb0604a312d8",
       "client_secret_expires_at":0,
       "token_endpoint_auth_method":"client_secret_basic",
       "scope":"openid profile",
       "grant_types":[
          "authorization_code"
       ],
       "response_types":[
          "code"
       ],
       "application_type":"native",
       "subject_type":"public",
       "post_logout_redirect_uris":[
          "https://server.example.com:9000/logout/"
       ],
       "preauthorized_scope":"openid",
       "introspect_tokens":false,
       "trusted_uri_prefixes":[
          "https://server.example.com:9003/trusted/"
       ],
       "client_id":"b0a376ec4b694b67b6baeb0604a312d8",
       "client_secret":"*",
       "client_name":"updated client",
       "redirect_uris":[
          "https://server.example.com:443/resource/redirect1"
       ]
    }
  3. 擷取用戶端,如下列範例所示:

    要求標頭:

    GET https://server.example.com:443/oidc/endpoint/<provider_name>/registration/registration/b0a376ec4b694b67b6baeb0604a312d8
    Accept: application/json
    Authorization: Basic Y2xpZW50QWRtaW46Y2xpZW50QWRtaW5QYXNzd29yZA==

    回應標頭:

    Status: 200
    Cache-Control: private
    ETag: "3DD7affTGS91mfhPZ83B39Y=="
    Content-Type: application/json

    回應內文:

    {
       "client_id_issued_at":1401776782,
       "registration_client_uri":"https://server.example.com:8020/oidc/endpoint/OIDC/registration/b0a376ec4b694b67b6baeb0604a312d8",
       "client_secret_expires_at":0,
       "token_endpoint_auth_method":"client_secret_basic",
       "scope":"openid profile",
       "grant_types":[
          "authorization_code"
       ],
       "response_types":[
          "code"
       ],
       "application_type":"native",
       "subject_type":"public",
       "post_logout_redirect_uris":[
          "https://server.example.com:9000/logout/"
       ],
       "preauthorized_scope":"openid",
       "introspect_tokens":false,
       "trusted_uri_prefixes":[
          "https://server.example.com:9003/trusted/"
       ],
       "client_id":"b0a376ec4b694b67b6baeb0604a312d8",
       "client_secret":"*",
       "client_name":"updated client",
       "redirect_uris":[
          "https://server.example.com:443/resource/redirect1"
       ]
    }
  4. 擷取用戶端(標題要求),如下列範例所示:

    要求標頭:

    HEAD https://server.example.com:443/oidc/endpoint/<provider_name>/registration/registration/b0a376ec4b694b67b6baeb0604a312d8
    Accept: application/json
    Authorization: Basic Y2xpZW50QWRtaW46Y2xpZW50QWRtaW5QYXNzd29yZA==

    回應標頭:

    Status: 200
    Cache-Control: private, no-cache=set-cookie
    ETag: "3DD7affTGS91mfhPZ83B39Y=="
    Content-Type: application/json
  5. 刪除用戶端,如下列範例所示:

    要求標頭:

    DELETE https://server.example.com:443/oidc/endpoint/<provider_name>/registration/registration/b0a376ec4b694b67b6baeb0604a312d8
    Authorization: Basic Y2xpZW50QWRtaW46Y2xpZW50QWRtaW5QYXNzd29yZA==

    回應標頭:

    Status: 204
    Content-Length: 0
    Content-Language: en-US
    註: 這個主題中的資訊亦適用於 OAuth 2.0 用戶端的用戶端登錄服務,以及 OpenID Connect 依賴方。

指示主題類型的圖示 作業主題

資訊中心條款 | 意見


「時間戳記」圖示 前次更新: 2015 年 6 月 22 日
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=phil&product=was-libcore-mp&topic=twlp_client_registration
檔名:twlp_client_registration.html