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

Fix authorization headers feature #48

Merged

Conversation

davidbrewer
Copy link
Contributor

Hello! I don't believe this is a ready-to-merge PR, but I thought that this would be the best way to start a discussion of it.

In the discussion of PR #25, @supagroova mentioned a change he had made to the index template which fixed some issues with using authorization headers. I found that a variant on this change was necessary to get my own authorization headers working properly, because otherwise the headers just didn't get sent with requests at all.

The change shown in this PR is similar to what I read on PR #25, except that I kept in the code which gets the api_auth, api_key_name and api_key_type from the grape-swagger-rails configuration. It seems to fix the issue for me, without causing any regressions.

However, I'm unsure how best to write a test that demonstrates that this fixes an issue. I'm also not using this library in an especially complex way so I'm uncertain if I may have broken something that I'm not using myself. Let me know if you have any ideas as to steps I can take to improve this PR to make it something useful for you.

@dblock
Copy link
Member

dblock commented Mar 6, 2016

Having debugged this once via #13 my answer is "I don't know" :) I'd take this or a variation of this change though as it seems that it works for everyone.

@dblock
Copy link
Member

dblock commented Mar 6, 2016

To get merged, please rebase/squash it.

Previous to this update, when I tried to do API-key authorization using
headers rather than the query string, Swagger-UI would not send my
authorization headers. This update basically makes the authorization
options get set AFTER Swagger-UI has finished initializing, which seems
to make the system much happier. Changes based on a conversation on a
mostly-unrelated pull request,
ruby-grape#25
@davidbrewer davidbrewer force-pushed the fix-authorization-headers-branch branch from ee4a93e to 924038c Compare March 7, 2016 17:21
@davidbrewer
Copy link
Contributor Author

OK, rebased.

I know this change works for my specific use case of a simple api key in an Authorization header (when accompanied with appropriate settings in the initializer). I can't comment on if it will work for more complex use cases like OAuth and so on, but I do think it's probably at the very least a step in the right direction and shouldn't remove any flexibility that was already present.

dblock added a commit that referenced this pull request Mar 8, 2016
@dblock dblock merged commit b8b5981 into ruby-grape:master Mar 8, 2016
@dblock
Copy link
Member

dblock commented Mar 8, 2016

Merged.

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

Successfully merging this pull request may close these issues.

2 participants