You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "goblain (via GitHub)" <gi...@apache.org> on 2023/02/01 12:46:28 UTC

[GitHub] [apisix] goblain opened a new issue, #8772: feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule

goblain opened a new issue, #8772:
URL: https://github.com/apache/apisix/issues/8772

   ### Description
   
   ability to configure openid-connect with something like ```
   claim_validators:
   - claim: someclaim
     matches:
     - foo
     - bar
   ```
   that would return 401 if failed to evaluate successfully


-- 
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-unsubscribe@apisix.apache.org.apache.org

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


Re: [I] feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule [apisix]

Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on issue #8772:
URL: https://github.com/apache/apisix/issues/8772#issuecomment-1814396318

   would you like to work on it @Visserr2 ?


-- 
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-unsubscribe@apisix.apache.org

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


[GitHub] [apisix] ro4i7 commented on issue #8772: feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule

Posted by "ro4i7 (via GitHub)" <gi...@apache.org>.
ro4i7 commented on issue #8772:
URL: https://github.com/apache/apisix/issues/8772#issuecomment-1468870480

   > You could submit a PR with test added to it.
   
   @spacewander please checkout #9068 


-- 
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-unsubscribe@apisix.apache.org

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


[GitHub] [apisix] abs007 commented on issue #8772: feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule

Posted by "abs007 (via GitHub)" <gi...@apache.org>.
abs007 commented on issue #8772:
URL: https://github.com/apache/apisix/issues/8772#issuecomment-1495559694

   I'l like this issue to be assigned to me if possible, thanks.


-- 
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-unsubscribe@apisix.apache.org

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


Re: [I] feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule [apisix]

Posted by "Baoyuantop (via GitHub)" <gi...@apache.org>.
Baoyuantop closed issue #8772: feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule
URL: https://github.com/apache/apisix/issues/8772


-- 
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-unsubscribe@apisix.apache.org

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


Re: [I] feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule [apisix]

Posted by "beardnick (via GitHub)" <gi...@apache.org>.
beardnick commented on issue #8772:
URL: https://github.com/apache/apisix/issues/8772#issuecomment-2495932297

   What is the status of this issue?


-- 
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-unsubscribe@apisix.apache.org

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


[GitHub] [apisix] spacewander commented on issue #8772: feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule

Posted by "spacewander (via GitHub)" <gi...@apache.org>.
spacewander commented on issue #8772:
URL: https://github.com/apache/apisix/issues/8772#issuecomment-1465457609

   You could submit a PR with test added to it.


-- 
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-unsubscribe@apisix.apache.org

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


[GitHub] [apisix] abs007 commented on issue #8772: feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule

Posted by "abs007 (via GitHub)" <gi...@apache.org>.
abs007 commented on issue #8772:
URL: https://github.com/apache/apisix/issues/8772#issuecomment-1502130206

   @monkeyDluffy6017 


-- 
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-unsubscribe@apisix.apache.org

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


[GitHub] [apisix] ro4i7 commented on issue #8772: feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule

Posted by "ro4i7 (via GitHub)" <gi...@apache.org>.
ro4i7 commented on issue #8772:
URL: https://github.com/apache/apisix/issues/8772#issuecomment-1465214854

   Hello @spacewander @goblain 
   
   if this issue is still open, please assign it to me,
   
   possible solution: 
   
   To implement this feature, we can introduce a new configuration parameter in the OIDC auth plugin named `claim_validators`. This parameter will be a list of maps, each map representing a custom claim validator.
   
   Each map will contain two keys: `claim` and `matches`.` claim` is a string representing the name of the custom claim that needs to be validated. `matches` is a list of strings representing the allowed values of the custom claim.
   
   During the authentication process, the plugin will validate the custom claim against the allowed values specified in the `claim_validators` configuration. If the custom claim fails to match any of the allowed values, the plugin will return a 401 unauthorized response.
   
   ```
   local function validate_custom_claim(claim_value, allowed_values)
       for _, v in ipairs(allowed_values) do
           if v == claim_value then
               return true
           end
       end
   
       return false
   end
   
   local function oidc_authenticate(conf, ...)
       -- ...
       local claim_validators = conf.claim_validators or {}
   
       for _, validator in ipairs(claim_validators) do
           local claim = validator.claim
           local matches = validator.matches or {}
   
           local claim_value = json.decode(claims[claim] or "{}")[1]
           if not validate_custom_claim(claim_value, matches) then
               return responses.send_HTTP_UNAUTHORIZED("Invalid custom claim")
           end
       end
   
       -- ...
   end
   
   ```
   With this implementation, the user can specify a list of custom claim validators in the `claim_validators` configuration. For example:
   ```
   plugins:
   - name: oidc
     config:
       client_id: YOUR_CLIENT_ID
       client_secret: YOUR_CLIENT_SECRET
       discovery: https://your-oidc-provider.com/.well-known/openid-configuration
       redirect_uri: http://your-redirect-uri.com
       claim_validators:
       - claim: someclaim
         matches:
         - foo
         - bar
   ```
   This will ensure that the `someclaim` custom claim in the OIDC token matches either `foo` or `bar`. If it does not match any of these values, the plugin will return a 401 unauthorized 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-unsubscribe@apisix.apache.org

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


Re: [I] feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule [apisix]

Posted by "Visserr2 (via GitHub)" <gi...@apache.org>.
Visserr2 commented on issue #8772:
URL: https://github.com/apache/apisix/issues/8772#issuecomment-1758602680

   What is the status on this issue?


-- 
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-unsubscribe@apisix.apache.org

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


Re: [I] feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule [apisix]

Posted by "beardnick (via GitHub)" <gi...@apache.org>.
beardnick commented on issue #8772:
URL: https://github.com/apache/apisix/issues/8772#issuecomment-2538412174

   @shreemaan-abhishek cc


-- 
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-unsubscribe@apisix.apache.org

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


[GitHub] [apisix] spacewander commented on issue #8772: feat: As a user, I want to set a validation on custom claims in oidc auth, so that I can restrict access to backend based on that rule

Posted by "spacewander (via GitHub)" <gi...@apache.org>.
spacewander commented on issue #8772:
URL: https://github.com/apache/apisix/issues/8772#issuecomment-1413059301

   LGTM


-- 
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-unsubscribe@apisix.apache.org

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