spedou commented on issue #12483:
URL: https://github.com/apache/apisix/issues/12483#issuecomment-3154174780

   Hello!
   
   thanks for the help!
   
   Just this morning I found a workaround with a pre-funcion.
   
   ```
         plugins:
           - name: serverless-pre-function
             enable: true
             config:
               phase: rewrite
               functions:
                 - |
                   return function()
                     local jwt = require("resty.jwt")
                     local token = ngx.var.http_authorization
                     if not token then return end
                     local _, _, token_str = string.find(token, "Bearer%s+(.+)")
                     if not token_str then return end
                     local decoded = jwt:load_jwt(token_str)
                     if decoded and decoded.valid and decoded.payload and 
decoded.payload.sub then
                       ngx.req.set_header("X-User-Sub", decoded.payload.sub)
                     end
                   end
           - name: limit-count
             enable: true
             config:
               count: 2
               time_window: 30
               key: $http_x_user_sub
               rejected_code: 429
               policy: local
               key_type: var_combination
   ```
   
   Would you avoid serverless-pre-function in a production environment ?
   
   I will check if there is a way to add the userinfo in the jwt in Auth0 for 
an application.
   
   I have another question, when you said "Tip: You can process the response or 
userinfo after", Does this mean there is a variable response ?
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to