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

add support for request guards #47

Closed
wants to merge 2 commits into from

Conversation

TotalKrill
Copy link
Contributor

This adds support for defining and getting request guards to define security schemes

result can look something like this:

image

Will add an example for this soon

…e otherwise there would be duplicate json fields called name, add example of a custom apikey implementation with openapi
@TotalKrill
Copy link
Contributor Author

TotalKrill commented Jun 15, 2021

Glad to see you are back on this lib @GREsau

This PR is a replacement for #44 and a continuation of #9

@svenstaro
Copy link

@ralpha I see you're maintaining this now, that's great! Any chance for a merge on this PR?

@TotalKrill
Copy link
Contributor Author

This PR should be updated ideally, some people has left some patches for this on my forked version

this: TotalKrill#3
this: TotalKrill#1

@ralpha ralpha self-assigned this Sep 9, 2021
@ralpha
Copy link
Collaborator

ralpha commented Sep 9, 2021

I'm currently working on integrating this into the current master. (so no need to change PR)
I'll also integrate TotalKrill#3 and TotalKrill#1.

@TotalKrill where there any other changes regarding this I need to take a look at?
And I see you have quite a few other changes in you master branch, does not look like there are any addition features added (is that correct?). But will also look over commits and see if there is anything that is needed.

And thanks for the PR :) This is a nice and needed feature to add.
P.S. if there is anything else you want to see in the next version, let me know, now is the time! (also for @svenstaro and anyone else)

@TotalKrill
Copy link
Contributor Author

@ralpha Very happy to see this original project getting some well deserved attention again, nice work!

there are no real new features otherwise in my fork, I just really needed that security_scheme thingy, and was tired of depending on the github repo.

I know user @mentaljam is working on some nice refactorings in a draft, TotalKrill#4, but nothing to merge as of yet.

Other than that there has not been any major changes, once this is in i will update my readme and publish a new version of my fork directing anyone who was using it back here again, as soon as these changes are pushed to crates.io that is. I know it takes a lot of effort maintaining this things, but if you feel like you are lagging behind,

I do think its good to ask for help as soon as you feel that happening, there are a lot of good developers around, and publishing to crates.io semi-often means that users have an easy way to stick to a working version, if one of said developers do a bit to heavy breaking changes. I do not want to maintain a branch, nor this library (no offense), but I will if i have to since I am using it :)

@ralpha
Copy link
Collaborator

ralpha commented Sep 10, 2021

This time I had the benefit that this update was needed for work, so I created it during my work. But I'll probably finish this PR after work so I can get it finished sooner.
I also look great care in making sure that the crate is prepared for future updates.
A lot of the changes also allow for things to be much easier to add/customized in the future.
See the full changelog for details, lot of nice things.

But updates will most likely come in bursts, like this time (at least from my side). But if I need help I'll ask!
Hope we can keep this crate maintained and reduce the fragmentation that happened because of inactivity.

@ralpha
Copy link
Collaborator

ralpha commented Sep 10, 2021

@TotalKrill In you code you have the RequestHeaderInput::Parameter() enum value. But I'm not sure about this.
It looks to my like this could never be used. If it takes a query or path parameter it would not be a Request Guard but a Query String.

So this could never be happen. Or am I wrong in assuming this? Could you please explain?

@TotalKrill
Copy link
Contributor Author

TotalKrill commented Sep 10, 2021

Which code are you looking at, my branch or this PR?

Edit, nevermind, i was to quick to ask, understood the question now. The parameter Enum is there so that the in the case of someone wanting to provide a method in the Header section of an HTTP request, that is not a security scheme like JWT or other token, they could do so, that was the original thought of that part of the enum.

Basically that would make a header value accessible inside of the route handler, and the swagger interface could provide this header positioned value.

ralpha added a commit that referenced this pull request Sep 12, 2021
- Added feature flag for `secrets`
(Re-exposing Rocket feature flag)
- Added support for Request Guards
and Security Scheme
(aka Authentication and Authorization) (Closes: #47, #9, #3)
- Added support for new `FromRequest`
  types (implemented `OpenApiFromRequest`).
- Added `OpenApiFromRequest` derive macro.
- Added `map!` macro for easy creation of `okapi::Map` objects.
- Change `OAuthFlows` to better represent the different flows and allowed values within them.
- Fixed casing in `SecuritySchemeData`.
@ralpha ralpha mentioned this pull request Sep 12, 2021
@ralpha ralpha closed this in #56 Sep 12, 2021
ralpha added a commit that referenced this pull request Sep 12, 2021
- Added feature flag for `secrets`
(Re-exposing Rocket feature flag)
- Added support for Request Guards
and Security Scheme
(aka Authentication and Authorization) (Closes: #47, #9, #3)
- Added support for new `FromRequest`
  types (implemented `OpenApiFromRequest`).
- Added `OpenApiFromRequest` derive macro.
- Added `map!` macro for easy creation of `okapi::Map` objects.
- Change `OAuthFlows` to better represent the different flows and allowed values within them.
- Fixed casing in `SecuritySchemeData`.
@ralpha
Copy link
Collaborator

ralpha commented Sep 12, 2021

Okay made a bunch of changes and restructured a bunch of things. Also added support for al currently (Rocket 0.5.0-rc.1) items that currently implement FromRequest.

Also added examples for all the most common authentication methods so people can easily figure out how to do this. Also allowed me to test everything.
Hope you like it :D

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.

3 participants