rocket-authorization 1.0.0

Library for Rocket.rs web servers to easily access and parse Authorization headers from requests.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::parse::Authorization;
use rocket::{http::Status, response::Response};

pub fn request_authorization<'a, AuthorizationType: Authorization>(realm: &'a str) -> Response<'a> {
    Response::build()
        .status(Status::Unauthorized)
        .raw_header(
            "WWW-Authenticate",
            format!(
                r#"{} realm="{realm}", charset="UTF-8""#,
                AuthorizationType::KIND
            ),
        )
        .finalize()
}