Adding realm support for Authorization headers
• elixir and guardian
When you’re verifying tokens with Guardian, for API access you probably want to use the Authorization header.
Usually these headers look something like
The bearer part is known as the realm. You might want to use different realms. I remember writing and OAuth provider, and as part of renewing your token the API required that the client and user tokens were set. For example, the client being the application requesting the renual, and the user for the user who owns the token.
These authentication headers can both be set on the same response.
Guardian can handle the easy case of token or many if that’s what you need. These can go in your route file to form a plugin, or you can use them directly in a controller.
Using the above as an example, you can include them in your pipelines
Inside your controller action, you can access each set in the usual ways:
Adding realm support is important for supporting robust API support. Having it integrated seamlessly with Guardian should make it dead simple.