While the module provides a JSON source plugin for remote content, it does not support JWT authentication, which is common on many systems.
Add a new authentication plugin which allows JWT transactions.
It should accept several values:
- The URL to request authentication from.
- The client ID value to pass.
- The client secret value to pass.
- The name of the return value that stores the token, e.g. "clientToken".
- The name of the query argument to pass on all subsequent requests with the token, e.g. "x-api-token".
Disclaimer:
This is to work with a 3rd party API that requires an authentication process which it calls "JWT Authentication", but it doesn't match the JWT standard. As such I'm not sure if this should even be called "JWT"?
Comments
Comment #2
damienmckennaComment #3
damienmckennaComment #4
damienmckennaComment #5
merauluka commented@DamienMcKenna From my review of that endpoint, it appears to just be using a client id and client secret to generate a token that can be used in Authorization headers for future requests. That being said, it doesn't appear to be using JWT at all.
I would suggest making this a RESTAuth plugin instead so the implementation can be a bit more generic.
Attached is my first stab at it. This hasn't been tested and needs review.
Comment #6
damienmckennaThat's pretty fantastic, thanks @merauluka!
Let's have the testbot give it a look-see.
I think one improvement would be to improve the class' docblock to provide an example of how to use it.
Comment #7
markie commentedShouldn't this be `$e->getMessage()`? $e is a Class...
Comment #8
markie commentedUpdated patch to fix issue with Exception->getMessage, and added documentation. Looking at my specific use case, the resulting auth header is not 'Authorization: Bearer $token' so added the ability to configure the response_header and response_prefix. Still don't have access to the api that I want to use this on, so it's still pretty much a WIP.
Comment #9
markie commentedAdding file with actual changes.. Sorry kids.
Comment #10
merauluka commentedOne thing I'm wondering @markie, is if the logger can be updated to use dependency injection instead of calling it statically.
Comment #11
damienmckennaThis is the code that ended up working:
I think it could be refactored to match the original request.