nokia / kong-oidc

OIDC plugin for Kong
Apache License 2.0
454 stars 321 forks source link

consumer_id expected to be uuid in Kong 0.12 #38

Closed nbkntu closed 6 years ago

nbkntu commented 6 years ago

I upgraded kong from 0.11 to 0.12 and ran into a problem with consumer_id which didn't happen before.

When user logs in successfully, kong-oidc passes user.sub as the id in ngx.ctx.authenticated_consumer.

https://github.com/nokia/kong-oidc/blob/6ff94662ff78e1c61149b8d09f872bf3b34170a3/kong/plugins/oidc/utils.lua#L64

This will trigger consumer lookup at kong level. Since the user.sub that I have is not a uuid, it results in error.

responses.lua:121: load_plugin_configuration(): failed to get from node cache: callback threw an error: [postgres error] consumer_id=00u1xxxx is not a valid uuid

It's running fine when I comment out the code that sets ngx.ctx.authenticated_consumer.

Trojan295 commented 6 years ago

The main purpose for setting the ngx.ctx.authenticated_consumer was to make this plugin somehow compatible with other plugins, which could use the information about the consumer, but I know it was a bit of a hack. There's also an another object called authenticated_credential, which has the similar purpose, but I think, it's designed for the case, then the user isn't in KongDB. Could you try to replace ngx.ctx.authenticated_consumer with ngx.ctx.authenticated_credential?

BTW. Could I know what OIDC Provider do you use?

nbkntu commented 6 years ago

Thanks for the info. It works fine when I replace ngx.ctx.authenticated_consumer with ngx.ctx.authenticated_credential as what you suggested.

I'm using Okta as the OIDC Provider. You can set up a trial server, it's free for 30 days.