You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/11/17 13:31:23 UTC

[GitHub] [apisix] dgradecak opened a new issue, #8353: help request: openid-connect with proxy-rewrite => preferred_username

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

   ### Description
   
   I would like to set a downstream header that where the value is based on the OIDC user attributes. I am mostly interested in using preffered_username but sure, this can apply to any claims
   
   ### Environment
   
   - APISIX version (run `apisix version`): 3.0.0
   - Operating system (run `uname -a`): "official" docker image
   
   


-- 
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


[GitHub] [apisix] tzssangglass commented on issue #8353: help request: openid-connect with proxy-rewrite => preferred_username

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #8353:
URL: https://github.com/apache/apisix/issues/8353#issuecomment-1321357153

   I think this plugin works for you


-- 
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] help request: openid-connect with proxy-rewrite => preferred_username [apisix]

Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek closed issue #8353: help request: openid-connect  with proxy-rewrite => preferred_username 
URL: https://github.com/apache/apisix/issues/8353


-- 
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] help request: openid-connect with proxy-rewrite => preferred_username [apisix]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #8353:
URL: https://github.com/apache/apisix/issues/8353#issuecomment-1803528540

   This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.


-- 
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] dgradecak commented on issue #8353: help request: openid-connect with proxy-rewrite => preferred_username

Posted by GitBox <gi...@apache.org>.
dgradecak commented on issue #8353:
URL: https://github.com/apache/apisix/issues/8353#issuecomment-1320510732

   I made it work for me but, I have a big doubt it is the right way. I created a new plugin that is executed after oidc and it extracts the userinfo header and uses the preffered_name claim
   
   ```
   plugins:
        openid-connect:
            ...
        rewrite-openid-connect-userinfo:
               remote_user_header: "X-My-Remote-User"
   ```
   
   ```
   local core    = require("apisix.core")
   local ngx     = ngx
   
   local plugin_name = "rewrite-openid-connect-userinfo"
   
   local schema = {
       type = "object",
       properties = {        
           remote_user_header = {
               description = "external auth header",
               type = "string",
               default = "X-Remote-User",
           },
   		oidc_userinfo_header = {
               description = "external auth header",
               type = "string",
               default = "X-Userinfo",
           },
   		userinfo_claim = {
               description = "oidc username to be mapped to remote_user_header",
               type = "string",
               default = "preferred_username",
           }
       }
   }
   
   local _M = {
       version = 0.1,
       priority = 1000,
       name = plugin_name,
       schema = schema,
   }
   
   function _M.check_schema(conf)    
   
       local ok, err = core.schema.check(schema, conf)
       if not ok then
           return false, err
       end
   
       return true
   end
   
   function _M.rewrite(plugin_conf, ctx)
       local conf = core.table.clone(plugin_conf)
   	local user = core.json.decode(ngx.decode_base64(core.request.header(ctx, conf.oidc_userinfo_header)))[conf.userinfo_claim]
   	core.request.set_header(ctx, conf.remote_user_header, user)	 
   end
   
   return _M
   ```


-- 
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] dgradecak commented on issue #8353: help request: openid-connect with proxy-rewrite => preferred_username

Posted by GitBox <gi...@apache.org>.
dgradecak commented on issue #8353:
URL: https://github.com/apache/apisix/issues/8353#issuecomment-1318780075

   sample config:
   
   ```
   routes:
      -
       uri: /*
       plugins:       
           openid-connect:
               client_id: "apisix"
               client_secret: "..."
               discovery: "..."
               scope: "openid profile"
               bearer_only: false
               realm: "master"
               redirect_uri: ".../.apisix/callback"
               set_id_token_header: false
               set_userinfo_header: true
               set_access_token_header: false
               session:
                 secret: "testtesttesttesttest"        
           proxy-rewrite: 
               headers: 
                   X-Alfresco-Remote-User: "!!!HERE_GOES_THE_CLAIM!!!"
   
       upstream_id: 1
   ```


-- 
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] tzssangglass commented on issue #8353: help request: openid-connect with proxy-rewrite => preferred_username

Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #8353:
URL: https://github.com/apache/apisix/issues/8353#issuecomment-1319478605

   > proxy-rewrite: 
   >             headers: 
   >                 X-Remote-User: "!!!HERE_GOES_THE_CLAIM!!!"
   
   we can use 
   
   ```
   > proxy-rewrite: 
   >             headers: 
   >                 X-Remote-User: $consumer_name
   ```
   
   about `$consumer_name`: https://github.com/apache/apisix/blob/master/docs/en/latest/apisix-variable.md#list-of-variables
   
   Note that the `consumer_name` here comes from the `name` when you added the consumer. ref: https://github.com/apache/apisix/blob/master/docs/en/latest/admin-api.md#consumer


-- 
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] dgradecak commented on issue #8353: help request: openid-connect with proxy-rewrite => preferred_username

Posted by GitBox <gi...@apache.org>.
dgradecak commented on issue #8353:
URL: https://github.com/apache/apisix/issues/8353#issuecomment-1320441074

   consumers are really not clear to me, even if I read and re-re-read the docs.
   
   Are you sure it is meant that the plugin openid-connect would set a claim in the $consumer_name variable?
   


-- 
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