使用 jwks 验证令牌

问题描述

我正在尝试在 GKE 集群上设置 Kong,以便我可以验证传入的请求。我有一个 jwks 文件/uri,我想用于验证。

我已按照以下步骤...

  1. 部署一个通过服务公开的 hello world 应用。

  2. 安装Kong kubectl apply -f https://raw.githubusercontent.com/Kong/kubernetes-ingress-controller/master/deploy/single/all-in-one-dbless.yaml

  3. 设置 Kong JWT 插件

    apiVersion: configuration.konghq.com/v1
    kind: KongPlugin
    Metadata:
      name: weather-jwt
      namespace: weather-api
    plugin: jwt
    
  4. 创建入口

    apiVersion: networking.k8s.io/v1beta1
    kind: Ingress
    Metadata:
      name: weather-ingress
      namespace: weather-api
      annotations:          
        kubernetes.io/ingress.class: kong
        plugins.konghq.com: weather-jwt
      spec:
        backend:
          serviceName: weather-service
          servicePort: 80
    

我看到的下一步是..

  1. 创建一个具有类似公钥的秘密

    apiVersion: v1
    kind: Secret
    Metadata:
      name: apiuser-apikey
      namespace: weather-api
    type: Opaque
    stringData:
      kongCredType: jwt
      key: https://farrellsoft.auth0.com/
      algorithm: RS256
      rsa_public_key: |-
    -----BEGIN PUBLIC KEY-----
    MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3PYgeiVyURLhqAkkUOfL
    roY281upGVWgBTZKZu6rIMPCiyzuZU8Rnlc1k+cHkbov0uRZIVmwrhMLTr6E9ZwD
    -----END PUBLIC KEY-----
    
  2. 创建kong消费者

    apiVersion: configuration.konghq.com/v1
    kind: KongConsumer
    Metadata:
      name: api-consumer
      namespace: weather-api
    username: apiUser
    credentials:
      - apiuser-apikey
    

这应该一切正常...问题是我没有秘密的公钥。我所拥有的只是 JWKS uri 之类的 https://YOUR_DOMAIN/.well-kNown/jwks.json 并且我不确定如何使用它进行令牌验证。有没有我需要使用的其他插件

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)