-
Notifications
You must be signed in to change notification settings - Fork 58
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
thoughts about auth strategies #32
Comments
Good thinking. This would be a great improvement. This is actually what the protected strategy is doing. |
I'm in agreeance here. I'm happy to send a PR that moves swagger as a configuration option but I'm having a hard time understanding what the difference is between the swagger and default strategy. Do you mind explaining how the swagger strategy works @antek-drzewiecki? |
Also, @calfzhou, right now, the protected strategy automatically protects all endpoints (similar to guard_all! is doing now). Protecting an entire class is interesting idea. Maybe we can add that as a method on the default strategy. |
@whatasunnyday , agree with you. The only problem for class level protection ( |
@antek-drzewiecki sorry to ping you again but what is the difference between swagger strategy and default? |
@whatasunnyday no problem. The difference is that the swagger strategy inject an authentication hash in the endpoint description that is compliant with grape-swagger. Grape-swagger will generate valid Swagger-UI json with the authentication options. Finally Swagger UI can parse the output and set authentication toggles. WineBouncer then uses this authentication hash to authenticate the scopes. Injecting the authentication hashes in the grape endpoints is the main purpose of the strategy. Currently the injection of the authentication hashes and and the authentication process are intertwined, but this could become separate methods. To summarize, the swagger strategy is default strategy + authentication hash injection. I hope you understand the goal of the swagger strategy now. Here are some link to the spec link and the actual endpoint spec. Since the spec is hard to read. Ill give you an example how the hash should look like:
Here are some more resources. |
@antek-drzewiecki Am I wrong thinking the documentation link should show the oauth calls in swagger? That's the reason I wanna use |
You are not wrong @penso. It should, but it relies on the |
@antek-drzewiecki I actually have |
@penso is your endpoint also tagged with scopes like: |
@antek-drzewiecki Sorry I meant I don't see any documentation about the |
Merry Christmas! swagger-ui doesn't give much information regarding the OAuth end points to be honest. You will be probably ending writing your own documentation for that part. As far as I know swagger ui only documents your endpoints. The scope part is indeed working then! If I'm delayed while writing back I am on a small holiday ;)
|
@antek-drzewiecki Don't you think wine_bouncer should generate the endpoint documentation so they appear in swagger? The only way for me to include those right now would probably to fake methods in Grape, as detailed in http://stackoverflow.com/questions/27661166/how-i-can-add-an-external-api-documentation-into-swagger-using-grape-swagger |
Hi @penso , its a good idea though. Do you mean it should generate an separate swagger (json) documentation for the authentication endpoints? Otherwise I still see some issues. Having a look at the OAuth2 spec the spec talks about an resource and an authentication server. The resource and authentication server can have different base urls. The resource can be api.website.xx and the authentication can be auth.website.xx. This will be really confusing when they are under one documentation scheme. |
I think on many projects you actually have the same base url, so you probably would like to be able to do either (two swagger files, or one) depending on your usage. Having all within the same swagger is nice when you have the same base url. |
@penso did you find a solution? I'm also hoping for the oauth endpoints to be in swagger documentation. If you've manually described them in your project, it would be great if you could share. |
Current strategies (default, protected, and swagger) are not very handy to use. I guess that
swagger
could be an additional configuration, injecting swagger specific syntax. And for theprotected
, maybe there could be a class method such asoauth_all
(see theguard!
andguard_all!
in this demo app) which could protect the entire class.The text was updated successfully, but these errors were encountered: