How to get generated KeyAuth keys for hashing

Hey there
I am trying to hash (sha256) the keyauth credentials and I am stuck on how to get the automatically generated keys. If I passed the value of the key in, I can get it by self.args.post.key in api.lua but I couldn’t figure out how/where to get the kong generated key value anywhere.

I need to do this before storing it in the database when the credential is created. Currently, I am doing it in ["/consumers/:consumers/key-auth"] route in api.lua.

Any help is appreciated, thanks

Basically we just call this:

When we do process_auto_fields:

Which we call on DAO insert:


Perhaps you can automatically generate the key yourself using the kong.tools.utils.random_string() and put that to self.args.post.key in case the request does not contain key?

Thanks! This is exactly what I was looking for.


© 2018 Kong Inc.    Terms  •  Privacy  •  FAQ