×

列出用户拥有的 OAuth 访问令牌

您可以列出您拥有的 OAuth 访问令牌。令牌名称不敏感,不能用于登录。

步骤
  • 列出所有用户拥有的 OAuth 访问令牌

    $ oc get useroauthaccesstokens
    示例输出
    NAME       CLIENT NAME                    CREATED                EXPIRES                         REDIRECT URI                                                       SCOPES
    <token1>   openshift-challenging-client   2021-01-11T19:25:35Z   2021-01-12 19:25:35 +0000 UTC   https://oauth-openshift.apps.example.com/oauth/token/implicit      user:full
    <token2>   openshift-browser-client       2021-01-11T19:27:06Z   2021-01-12 19:27:06 +0000 UTC   https://oauth-openshift.apps.example.com/oauth/token/display       user:full
    <token3>   console                        2021-01-11T19:26:29Z   2021-01-12 19:26:29 +0000 UTC   https://console-openshift-console.apps.example.com/auth/callback   user:full
  • 列出特定 OAuth 客户端的用户拥有的 OAuth 访问令牌

    $ oc get useroauthaccesstokens --field-selector=clientName="console"
    示例输出
    NAME       CLIENT NAME                    CREATED                EXPIRES                         REDIRECT URI                                                       SCOPES
    <token3>   console                        2021-01-11T19:26:29Z   2021-01-12 19:26:29 +0000 UTC   https://console-openshift-console.apps.example.com/auth/callback   user:full

查看用户拥有的 OAuth 访问令牌的详细信息

您可以查看用户拥有的 OAuth 访问令牌的详细信息。

步骤
  • 描述用户拥有的 OAuth 访问令牌的详细信息

    $ oc describe useroauthaccesstokens <token_name>
    示例输出
    Name:                        <token_name> (1)
    Namespace:
    Labels:                      <none>
    Annotations:                 <none>
    API Version:                 oauth.openshift.io/v1
    Authorize Token:             sha256~Ksckkug-9Fg_RWn_AUysPoIg-_HqmFI9zUL_CgD8wr8
    Client Name:                 openshift-browser-client (2)
    Expires In:                  86400 (3)
    Inactivity Timeout Seconds:  317 (4)
    Kind:                        UserOAuthAccessToken
    Metadata:
      Creation Timestamp:  2021-01-11T19:27:06Z
      Managed Fields:
        API Version:  oauth.openshift.io/v1
        Fields Type:  FieldsV1
        fieldsV1:
          f:authorizeToken:
          f:clientName:
          f:expiresIn:
          f:redirectURI:
          f:scopes:
          f:userName:
          f:userUID:
        Manager:         oauth-server
        Operation:       Update
        Time:            2021-01-11T19:27:06Z
      Resource Version:  30535
      Self Link:         /apis/oauth.openshift.io/v1/useroauthaccesstokens/<token_name>
      UID:               f9d00b67-ab65-489b-8080-e427fa3c6181
    Redirect URI:        https://oauth-openshift.apps.example.com/oauth/token/display
    Scopes:
      user:full (5)
    User Name:  <user_name> (6)
    User UID:   82356ab0-95f9-4fb3-9bc0-10f1d6a6a345
    Events:     <none>
    1 令牌名称,即令牌的 sha256 哈希值。令牌名称不敏感,不能用于登录。
    2 客户端名称,描述令牌的来源。
    3 从创建时间开始,此令牌过期前的秒数。
    4 如果为 OAuth 服务器设置了令牌非活动超时,则这是从创建时间开始,此令牌不再可用的秒数。
    5 此令牌的范围。
    6 与此令牌关联的用户名称。

删除用户拥有的 OAuth 访问令牌

oc logout 命令仅使活动会话的 OAuth 令牌无效。您可以使用以下步骤删除不再需要的任何用户拥有的 OAuth 令牌。

删除 OAuth 访问令牌会将使用该令牌的所有会话中的用户注销。

步骤
  • 删除用户拥有的 OAuth 访问令牌

    $ oc delete useroauthaccesstokens <token_name>
    示例输出
    useroauthaccesstoken.oauth.openshift.io "<token_name>" deleted

将未经身份验证的组添加到集群角色

作为集群管理员,您可以通过创建集群角色绑定来将未经身份验证的用户添加到 Red Hat OpenShift Service on AWS 中的以下集群角色。未经身份验证的用户无权访问非公共集群角色。这应仅在必要时在特定用例中进行。

您可以将未经身份验证的用户添加到以下集群角色

  • system:scope-impersonation

  • system:webhook

  • system:oauth-token-deleter

  • self-access-reviewer

修改未经身份验证的访问权限时,请务必验证是否符合您组织的安全标准。

先决条件
  • 您可以作为具有 cluster-admin 角色的用户访问集群。

  • 您已安装 OpenShift CLI (oc)。

步骤
  1. 创建一个名为 add-<cluster_role>-unauth.yaml 的 YAML 文件并添加以下内容

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
     annotations:
       rbac.authorization.kubernetes.io/autoupdate: "true"
     name: <cluster_role>access-unauthenticated
    roleRef:
     apiGroup: rbac.authorization.k8s.io
     kind: ClusterRole
     name: <cluster_role>
    subjects:
     - apiGroup: rbac.authorization.k8s.io
       kind: Group
       name: system:unauthenticated
  2. 运行以下命令应用配置

    $ oc apply -f add-<cluster_role>.yaml