-
Notifications
You must be signed in to change notification settings - Fork 119
Added a convenience function to pull a desired claim value out of the token #28
base: master
Are you sure you want to change the base?
Conversation
@ChrisWhiten sorry for taking so long to get back to this. Can you explain a little more the use case that requires this convenience function? I ask because the existing auth function already provides a way to ensure certain claims exist with desired values. So if that's all you're wanting to do, then I'd suggest we stick with (or enhance if needed) the But if you've got something else in mind, I'd love to understand the details. |
Thanks for getting back to me @twistedstream The use case here is a bit different than just deciding whether a claim exists or not. The use case I was targeting is more pulling out the value of a given claim, so that we can use that later on. For example, imagine a scenario where you are routing requests from a specific customer to a specific server. You can have a At a high level, that was a use case that wasn't clearly satisfied with the library as it stands, and that's why I added that convenience method - to return the value associated with a claim, rather than just whether or not that claim exists with a specific value |
@ChrisWhiten: Ah, good. So this routing logic would still be running in the nginx server (presumably in some calling Lua code in the The only thing I'd change with your implementation is to maybe not repeat the use of the same regex parsing of the |
Ideally we'd also have a test or two to verify the new function works and continues to work. |
@twistedstream Sure, I can do that shortly. As a heads up, the test setup doesn't seem to work on OS X, since all of the Docker scaffolding scripts appear to fail. |
@ChrisWhiten Have you installed Docker Toolbox? We moved away from using boot2docker as of PR #36 |
@twistedstream Sorry for the delay on this - it fell through the cracks on me. As requested, I've refactored out the regex parsing and added a couple of tests to verify that the new functionality doesn't break going forwards |
Added a method to the API that will retrieve a given claim from the payload, and return its value to the caller. This is especially useful if the JWT token contains information that can assist Nginx with tasks such as message routing.
Example usage in nginx.conf