DBLess Kong, how could I confirm a given client_id and client_secret from oauth2_credentials resource? #7747
Unanswered
jeremyjpj0916
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Trying to learn a thing or two about querying these db-less yaml elements using the native Kong resources in a custom plugin:
Say you have this native Kong OAuth2.0 credentials resource on a export command, basically has the consumer
id
of a consumer resource, and each respective consumersclient_id
andclient_secret
pair stored for them and some other metadata I don't care to use for my impl:And in a DB-Less plugin I want to lookup and make sure the
client_id
andclient_secret
pair exists as a valid values in the list AND I want to get the subsequent consumers id who owns the credential associated with that validclient_id
andclient_secret
. How can I do so?I was looking at code here:
https://github.com/Kong/kong/blob/master/kong/plugins/oauth2/access.lua#L154
Aka:
Would it be as simple as this running in db-less mode?
I think the part I am not sure will work is:
uuid_of_consumer_kong_resource = credential_from_client_id.consumer
, or maybe it is right?, could you clarify that last bit of code and if I am doing it right or how I could link back to the consumers id(not the credential id, that field is unneeded metadata for me) at the point in time after confirming the client_id and client_secret?Edit, based on existing oauth2 code maybe I have to do it like this after?
But this seems like extra work if the consumers id is already present in the oauth2 credentials list resources like so and I don't need the full consumers information(name, tags, etc.) , just their id(a uuid) to make a proper authentication call later for them with the pdk:
@bungle or @gszr @javierguerragiraldez can you weigh in on approach? Would my original idea of
credential_from_client_id.consumer
reference the id of that consumer for the credential lookup?P.S. - This discussion feature now in github is cool for code related things. I like this approach better than using the standalone konghq forum, keeping it in github is nice.
EDIT - ADDING MORE INFO FROM FURTHER TESTING/RESEARCH:
One of the more interesting things is in DB mode a given oauth2 credentials output table looks like this:
Where consumer is a table with id as the string index. But this differs from the Kong YAML export of oauth2_credentials as seen in my original post.. does this mean Kong has a goof somewhere? Because to support reading the creds in db vs db-less mode for looking up a consumer based on creds would look like this? Which this feels wrong imo, the native resources in YAML config should conform to the format in what the db has too.
And it seems in YAML consumer becomes a string of the consumers id as shown in my original post. In DB Mode consumer is a element(in lua its a table) that then has an id sub-element which is the UUID of the consumer resource.
Beta Was this translation helpful? Give feedback.
All reactions