Closed shawnchapla-8451 closed 4 months ago
Closing this because investigation seems to indicate that you cannot find a consumer object by the custom_id attribute with the PDK (also seems to be the case for the Golang and JavaScript PDKs). I ended up having to call out to the Kong admin API directly from the plugin to accomplish this. Not at all ideal, but it worked.
I'm working on a Python plugin that will validate an OAuth access token and, if valid, want to then use information from the token to set the Kong consumer context of the request. Our standard for creating consumers is:
Access tokens generated by the IdP will include the app's client ID in the cid claim, and this is what I have in hand to try to match the consumer. In an earlier Lua plugin, I first used the PDK method
kong.db.consumers:select_by_username()
to get the consumer object's internal ID, and if that didn't match, I usedkong.db.consumers:select_by_custom_id()
; once I had the ID, then I set the consumer context withkong.client.authenticate()
.However, it looks like the kong.db interface doesn't exist in the Python PDK, and the
kong.client.load_consumer()
method only supports searching by the username attribute. Is there any option for finding the consumer by the custom_id with the Python PDK?