azure api management 与 auth0 的集成

16 篇文章 0 订阅

azure api gateway 提供了 JWT 验证,auth0 推荐使用 machine to machine 的OAuth 验证方式,但是配置异常复杂。其实我们可以使用 jwks 来得到 auth0 的 public key,然后再来验证 auth0 的 JWT token。Azure API Gateway 的配置如下:

<policies>
    <inbound>
        <base />
        <cors>
            <allowed-origins>
                <origin>*</origin>
            </allowed-origins>
            <allowed-methods>
                <method>GET</method>
                <method>POST</method>
            </allowed-methods>
            <allowed-headers>
                <header>*</header>
            </allowed-headers>
        </cors>
        <validate-jwt header-name="Authorization" failed-validation-httpcode="401" require-scheme="Bearer" require-signed-tokens="true" clock-skew="120">
            <openid-config url="https://your_auth0_domain.us.auth0.com/.well-known/openid-configuration" />
        </validate-jwt>
    </inbound>
    <backend>
        <base />
    </backend>
    <outbound>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>

这里的关键是使用 openid 来得到 public key 虽然一般会使用 https://your_auth0_domain.us.auth0.com/.well-known/jwks.json,但是 Azure API Gateway 要求使用 open id 的形式。Auth0 支持这种形式:https://your_auth0_domain.us.auth0.com/.well-known/openid-configuration

参考链接

https://social.msdn.microsoft.com/Forums/azure/en-US/6066631f-c4ca-4757-9190-bc363e4e242f/caching-jwks-from-identity-provider-using-azure-api-management-for-validating-jwt?forum=azureapimgmt
https://docs.microsoft.com/en-us/azure/api-management/api-management-access-restriction-policies#ValidateJWT

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

surfirst

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值