【问题标题】:How to Validate an Access Token for OAuth2 + PCKE flow如何验证 OAuth2 + PCKE 流的访问令牌
【发布时间】:2019-04-24 15:57:55
【问题描述】:

根据本文档 https://developers.onelogin.com/openid-connect/guides/auth-flow-pkce

PCKE 流的令牌端点是 None(不是 Basic 或 POST)

那么,我该如何使用验证令牌 API https://developers.onelogin.com/openid-connect/api/validate-session,因为它支持 Basic authenticationPOST 但不支持 None (PCKE) 我找不到任何与此相关的信息。

注意:我尝试使用基本身份验证请求,并且不使用 + client_id、client_secret 作为参数但不起作用。

响应 401 未经授权

{
    "error": "invalid_client",
    "error_description": "client authentication failed"
}

【问题讨论】:

    标签: api session login token onelogin


    【解决方案1】:

    我将 OIDC 与 PKCE 一起使用,并且我设法使用通过授权代码流检索到的令牌调用 https://openid-connect.onelogin.com/oidc/token/introspection 端点:

    $ curl -i -d "token=...&token_type_hint=access_token&client_id=..." https://openid-connect.onelogin.com/oidc/token/introspection
    
    HTTP/1.1 200 OK
    Cache-Control: no-cache, no-store
    Content-Length: 304
    Content-Type: application/json; charset=utf-8
    Date: Thu, 25 Apr 2019 23:37:42 GMT
    Pragma: no-cache
    X-Powered-By: Express
    Set-Cookie: ol_oidc_canary_040819=false; path=/; domain=.onelogin.com
    
    {"active":true,"sub":"...","client_id":"...","exp":1558819177,"iat":1556227177,"sid":"...","iss":"https://openid-connect.onelogin.com/oidc","jti":"...","scope":"openid profile email"}
    

    从身份验证代码流https://developers.onelogin.com/openid-connect/api/authorization-code-grant 返回的access_tokenrefresh_token 都有效,而access_token 在过期后才返回{"active":false}

    确保您没有设置 Authorization 标头,而仅在有效负载中设置您的 client_id

    【讨论】:

      【解决方案2】:

      在 POST 正文中使用 client_id 和 code_verify。这将验证该端点上的请求。

      【讨论】:

      • 发现请求体中不需要通过code_verify!?
      • 嗨,Jongz。是尼尔。你和我正在通过另一个渠道交谈:)
      • LoL 地球是圆的! @niall_atlasidentity
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-03
      • 2023-02-22
      • 2017-01-12
      • 1970-01-01
      • 2015-10-23
      相关资源
      最近更新 更多