配置 OpenID Connect 提供者以接受客户机注册请求

客户机注册端点是管理员管理的服务,用于注册、更新、删除和检索有关计划使用 OpenID Connect 提供者的 OpenID Connect 依赖方的信息。反过来,注册过程可提供信息以供依赖方使用它,包括 OAuth 2.0 客户机标识和客户端密钥(如果未指定)。

开始之前

客户机注册服务按以下两种方式的其中一种运行:本地存储器或数据库存储器。这些方式由以下因素确定:Liberty 服务器配置其客户机存储器的方式,以及客户机是使用 server.xml 文件中的 oauthProvider localStore 属性定义的(本地存储器)还是使用数据库配置的(数据库存储器)。

在本地存储器配置中,客户机注册服务被限制为仅检索 OpenID Connect 依赖方信息。可修改 server.xml 文件来添加更多操作以注册、更新或删除 OpenID Connect 依赖方。

在数据库存储器配置中,没有针对客户机注册服务的限制,可通过 REST 接口完成所有操作。

注: Liberty 服务器不得同时使用本地存储器和数据库存储器配置其客户机存储器。仅应选择一个配置路由。

客户机注册端点是具有 clientManager 角色的受保护管理端点。为使用户能够访问此端点,管理员必须向此用户授予 clientManager 角色。

clientManager 角色是对 oauthProvider 定义的其中一个 oauth-roles。以下是样本配置,显示向 clientAdministrator 组中的用户 Alice 或成员授予 clientManager 角色的过程。

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

关于此任务

有关 OpenID Connect 依赖方的客户机注册信息主要用于定义客户机的使用方案约束。此外,对客户机不透明的 OP 的其他操作使用客户机注册元数据来制定权限决策。

以下示例假定在端口 443 上对 Liberty OP 配置了 SSL。

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

以上示例还假定对 server.xml 文件配置了用户名 clientAdmin 和密码 clientAdminPassword,并且使用 oauth-role clientManager

客户机注册元数据由以下参数组成:

表 1. 客户机注册参数
属性名称 数据类型 必需/可选 描述
client_id 输入/输出 可选 正向 OP 注册的客户机标识。除非指定,否则,在缺省情况下,此参数值是在注册期间生成的。它是一个字符串。
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 (order reversible)

对于特定 response_type,必须指定对应 grant_types。有关更多信息,请参阅 Client Metadata Web 站点上的 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 授予类型的客户机发出的请求相关联的用户标识。它是一个字符串。
functional_user_groupIds 输入 可选 要与使用客户机凭证授予类型的客户机获取的访问令牌相关联的组标识列表。该值为生效用户所属组的组标识列表,其中组标识是区分大小写的字符串。字符串由授权服务器定义。如果此值包含多个组标识,它们的顺序也无关紧要。如果列表为空,那么会省略声明。如果指定了此客户机元数据元素,那么系统会在来自内省端点的 functional_user_groupIds 响应参数中为具有客户机凭证授权的客户机发出的访问令牌返回值。如果未使用 functional_user_id 参数,那么此参数被忽略。
注: 授权服务器不得信任自我断言此参数的客户机。
introspect_tokens 输入 可选 一个参数值,用于指示所指定客户机是否有权对 OP 发出的访问令牌执行内省。它是一个布尔值。
registration_client_uri 仅输出 不适用 响应中返回的一个参数,其值指示已注册客户机的唯一 URL。它是一个字符串。
client_secret_expires_at 仅输出 不适用 响应中返回的一个参数,其值指示客户端密钥的到期时间,以从 1970-01- 01T0:0:0Z 开始的秒数(以 UTC 为标准进行测量)计算。值 0 指示无到期时间。
client_id_issued_at 仅输出 不适用 响应中返回的一个参数,其值指示客户机标识的发放时间,以从 1970-01- 01T0:0:0Z 开始的秒数(以 UTC 为标准进行测量)计算。值 0 指示未标识客户机标识发放时间。

过程

  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 依赖方。

用于指示主题类型的图标 任务主题



时间戳记图标 最近一次更新时间: Tuesday, 6 December 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twlp_client_registration
文件名:twlp_client_registration.html