Skip to content

help request: rate-limit by key value from the Oauth token when using openid #12483

@spedou

Description

@spedou

Description

Hello!

Im using OpenID-connect plugin against Auth0 for an m2m authentication.
I'm trying to use it with the rate-limit plugin, using the azp value from the jwt, but i'm not sure if this feature is supported.

apiVersion: apisix.apache.org/v2
kind: ApisixRoute
metadata:
  name: external-cv-route
spec:
  http:
    - name: external-route-to-cv
      match:
        paths:
          - /api/cv/*
        - name: openid-connect
          enable: true
          config:
            bearer_only: true
            discovery: https://domain.auth0.com/.well-known/openid-configuration
            client_id: cv # WIll match the audience and authorize cv as aud value
            client_secret: dummy 
            use_jwks: true
            claim_validator:
              audience:
                required: true
                match_with_client_id: true
        - name: limit-count
          enable: true
          config:
            count: 2             
            time_window: 30         
            key: $jwt_claim_azp        # Auth0 client ID
            rejected_code: 429
            policy: local
            key_type: var_combination
      backends:
        - serviceName: cv
          servicePort: 9191

I'm not sure if this variable "$jwt_claim_azp" exists? I could make it work with $http_authorization, but is not the ideal, because token could be regenerated, and I would be able to filter by "application/client"

Environment

  • APISIX version (run apisix version): 2.11.3 (Helm)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions