Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header override #102

Open
sqlninja opened this issue Aug 21, 2021 · 1 comment
Open

Header override #102

sqlninja opened this issue Aug 21, 2021 · 1 comment

Comments

@sqlninja
Copy link

Is it possible to use an alternative header for authentication?
I use stitches to protect the API routes from unauthorized requests based on the API key, but I use devise-jwt to authenticate/authorize user access.
Devise-jwt uses a Bearer token in the Authorization header, so being able to override the header used by stitches to almost anything else would let these two gems play nice together.

@davetron5000
Copy link
Contributor

This behavior is part of the ApiKey middleware. You can either remove it or include the norailtie version of Stitches and configure it yourself.

You could create a middleware exactly like ApiKey but does whatever you need for JWT.

Note that if you generated an app from this gem, the ApiController will assume that the ApiKey middleware has been used:

def api_client
@api_client ||= request.env[Stitches.configuration.env_var_to_hold_api_client]
# Use this if you want to look up the ApiClient instead of using the one placed into the env
# @api_client ||= ApiClient.find(request.env[Stitches.configuration.env_var_to_hold_api_client_primary_key])
end

Since that is generated, you can remove or change that method to do whatever you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants