On 8/21/16 9:39 AM, Márk Sági-Kazár wrote:
> 2. How to integrate Kong into the existing registration/authentication
> flow.
Maybe consider the Consumer's 'custom_id' property. When Kong
authenticates a Consumer (from any authentication plugin), it will send
a few headers to your upstream services. See the "upstream headers"
section of the plugin's doc.
> but I still see a possible danger of inconsistency.
That is true. I don't see a specific solution to this.
> There are also more hidden problems with using the JWT plugin in an
> infrastructure like this. For example: JWTs are self-container,
> meaning my auth service MUST BE able to add custom claims to the
> token. The client should be able to utilize refresh tokens, which is
> also not possible with the JWT plugin at the moment.
Indeed, the plugin only verifies that JWT tokens are valid, its primary
goal is to take care of this, allowing your upstream services to
consider them valid and simply decode them.
> Right at the moment, I am thinking about the following: implement a
> custom authentication plugin which uses my already existing user
> services for token creation and only validates JWT without using the
> Consumer concept of Kong. How would that work together with other auth
> related things (ACLs, etc)?
Some plugins in Kong require that your request be authenticated with one
of Kong's Consumers (ACL is a good and obvious example). If you wish to
"authenticate" a Consumer, simply set the 'ngx.ctx.authenticated_*'
values. See the key-auth plugin for example:
https://github.com/Mashape/kong/blob/master/kong/plugins/key-auth/handler.lua#L101-L102
Best,
Thibault