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

Support for request guards #8

Closed
tdymel opened this issue Dec 22, 2019 · 3 comments
Closed

Support for request guards #8

tdymel opened this issue Dec 22, 2019 · 3 comments

Comments

@tdymel
Copy link

tdymel commented Dec 22, 2019

Hey!
First of all: Amazing crate! Thank you very much for this!

I am using request guards to add authentication to my application. This requires the user to add the Authorization header to a number of requests.

I would like to specify this in the API documentation.

An example function can look like this:

#[openapi]
#[get("/get")]
pub fn get_account_information(me: State<Account>, auth: Authenticate) -> Result<Json<AccountInformation>, Failure>
{
  me.get(auth.0)
    .and_then(|acc_info| Ok(Json(acc_info)))
}

The authentication guard returns 401 if the token does not match any user and adds the header requirement to the request.

@tdymel tdymel changed the title Specify optional parameters Support for request guards Dec 22, 2019
@tdymel tdymel closed this as completed Dec 22, 2019
@tdymel tdymel reopened this Dec 22, 2019
@tdymel
Copy link
Author

tdymel commented Dec 22, 2019

FromRequest is missing

@tdymel
Copy link
Author

tdymel commented Dec 22, 2019

Note: For headers like "Authorization", a security component needs to be added instead.

@ralpha
Copy link
Collaborator

ralpha commented Sep 12, 2021

Added support for Request Guards in #56.

@ralpha ralpha closed this as completed Sep 12, 2021
@ralpha ralpha mentioned this issue Sep 12, 2021
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