【问题标题】:JWT Token Validation using Mule使用 Mule 进行 JWT 令牌验证
【发布时间】:2018-11-01 12:59:42
【问题描述】:

我正在尝试创建一个 oAuth 策略来保护使用 JWT 访问令牌的 API。可以通过调用外部 URL 来验证该令牌。

我正在为我的 Mule 代理使用以下 RAML。

#%RAML 1.0
title: Custom API
version: 1
baseUri: http://localhost:8081
securitySchemes:
  oauth_2_0:
    description: |
      This API supports OAuth 2.0 for authenticating all API requests.
    type: OAuth 2.0
    describedBy:
      headers:
        authorization:
          description: |
             Used to send a valid OAuth 2 access token. Do not use with the "access_token" query
             string parameter.
          type: string      
      responses:
        401:
          description: |
            Bad or expired token. This can happen if the user or the API revoked or expired an
            access token. To fix, you should re-authenticate the user.
        403:
          description: |
            Bad OAuth request (wrong consumer key, bad nonce, expired timestamp...). Unfortunately,
            re-authenticating the user won't help here.
/hello:
  get:
  securedBy: [oauth_2_0]

但是,mule 在验证外部服务时无法发送授权标头。

【问题讨论】:

  • “mule 无法发送授权标头”是什么意思?从 mule 调用外部服务时,您是否明确设置了 Authorization 标头?
  • 当我验证授权服务中的所有标头时,缺少名为“授权”的标头
  • 调用外部服务时需要设置Authorization header。请分享您的代码,以便我们更轻松地了解问题所在。
  • 我没有代码。这是通过 API 管理器中的 OAuth 策略实现的。

标签: validation mule jwt token using


【解决方案1】:

您发布的 RAML 很好,但仅供参考。您必须将 JWT oAuth 令牌执行功能作为自定义策略或作为 Mule 流程的一部分来实施。目前,JWT 令牌验证没有开箱即用的策略。

通常,为了验证令牌,调用外部端点提供令牌作为内部 [策略] 请求的一部分。这意味着策略本身将解析传入的用户请求,并从查询参数或授权标头中提取令牌(删除承载部分)。 AFAIK,授权标头永远不会发送到自省令牌 URL。

【讨论】:

猜你喜欢
  • 2016-12-13
  • 2019-09-14
  • 1970-01-01
  • 2018-08-29
  • 1970-01-01
  • 2017-02-04
  • 1970-01-01
  • 2019-06-23
  • 2022-09-11
相关资源
最近更新 更多