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

OAuth2 support #42

Open
OleMchls opened this issue Oct 17, 2016 · 1 comment
Open

OAuth2 support #42

OleMchls opened this issue Oct 17, 2016 · 1 comment

Comments

@OleMchls
Copy link

Hey there,

I was wondering if you folks have a opinion on how swagger_yard should define OAuth2 based auth. Because with the current pattern of @authorization it seems to be very complicated. The OAuth2 SECURITY SCHEME OBJECT has a few more parameters to configure.

Excerpt from the 2.0 specs http://swagger.io/specification/#securitySchemeObject

petstore_auth:
  type: oauth2
  authorizationUrl: http://swagger.io/api/oauth/dialog
  flow: implicit
  scopes:
    write:pets: modify pets in your account
    read:pets: read your pets

I wanted to add support for it (first w/o support for scopes), but wanted to check your ideas first. Before I head in the wrong direction. Also having more complex yard tags seems not very common in this gem.

Two ideas I was thinking of:

1. Add it to @authorization tag

In order to implement this, there must be a way to integrate more parameters into the tag. Like flow and the flow dependent urls like authorizationUrl.

2. Add a securityDefinitions option to SwaggerYard::Configuration

This would be the easier solution. Adding a attribute to the config so it can be used with @authorize_with I image the config block look like this:

SwaggerYard.configure do |config|
  config.security_definitions['petstore_oauth'] = {
    type: "oauth2",
    authorizationUrl: "http://swagger.io/api/oauth/dialog",
    flow: :implicit
  }
  ....
end

If you have any more ideas, I'd love to hear your feedback! I'd also love to hear some thoughts on scopes.

cheers!

@nicksieger
Copy link
Collaborator

I think that the authorization support is not very well thought out and could use some rework. I like your second suggestion using @authorize_with as a starting point. Security definitions feel more global to me than could be declared in a controller with tags.

That said, if you have a way that you're leaning, you're in the driver's seat if you are willing to submit the work! Thanks for the suggestions.

@OleMchls OleMchls mentioned this issue Oct 18, 2016
2 tasks
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