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

Better Explanation for Security Middleware Section #67

Open
Leyart opened this issue May 10, 2015 · 10 comments
Open

Better Explanation for Security Middleware Section #67

Leyart opened this issue May 10, 2015 · 10 comments

Comments

@Leyart
Copy link

Leyart commented May 10, 2015

I cannot make the "Security Middleware" work for my specification.
My security definition is the following in YAML:

securityDefinitions:
myauth:
type: oauth2
authorizationUrl: "http://api.mywebsite.com/oauth/dialog"
flow: implicit
x-authorize: "authorize"
scopes:
"write:user": "modifies users' information"
"read:user": "reads users' information"
"write:request": "needed to write requests on the server"
"read:request": "authorization to read requests on the server"
"read:driver": "reads drivers' information"
"write:driver": "modifies drivers' information"

But I don't think I have added properly the x-authorize parameter.

What does "an appropriate authorize function exists (defined using x-authorize in the securityDefinitions as per swaggerize-routes)" mean? Could it be explained in a detailed way, possibly with an example?
Thank you in advance,

Luca

@tlivings
Copy link
Contributor

Noted. Will add more detail.

Basically, x-authorize should point at a path to a file that exports a single middleware (in the case of express) function.

@Leyart
Copy link
Author

Leyart commented Jun 8, 2015

The latest version of Generator Swaggerize is not using the proper swaggerize-express version. Part of my issues were due to this.

@tlivings
Copy link
Contributor

tlivings commented Jun 8, 2015

Yes - I mis-published something! Corrections coming.

@talvor
Copy link

talvor commented Feb 10, 2016

The path to the security function, is this relative to the project root, or to the API path?

@subeeshcbabu-zz
Copy link
Member

The path is relative to the project root.
https://github.com/krakenjs/swaggerize-routes/blob/master/lib/buildroutes.js#L161

subeeshcbabu-zz pushed a commit to subeeshcbabu-zz/swaggerize-express that referenced this issue Feb 13, 2016
tlivings added a commit that referenced this issue Mar 29, 2016
Better Explanation for Security Middleware Section #67
@djMax
Copy link

djMax commented Apr 26, 2016

What's the theory behind sticking project specific auth information into a swagger doc? I wouldn't want to expose that path in the external swagger doc, and I don't really want two separate docs for a single service right?

@tlivings
Copy link
Contributor

Yeah, probably makes sense to filter out x- vendor extensions from the exposes API definition.

@djMax
Copy link

djMax commented Apr 26, 2016

That's one option, but I'd vastly prefer being able to pass in named authorization handlers to the swaggerize function, because I don't like the idea of embedding "function calls" in what feels like an external facing API document... I'm not saying my approach is the only one, but it seems "reasonable." :)

@djMax
Copy link

djMax commented Apr 26, 2016

In the meantime, essentially I just load the JSON swagger doc myself and inject the authorization function into the securityDefinitions before passing to swaggerize.

@tlivings
Copy link
Contributor

tlivings commented May 1, 2016

Yeah might make sense to pass securityDefinitions as an explicit option so it isn't even in the document. Or pass named auth handlers.

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

No branches or pull requests

5 participants