mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore: fix doc lints (#4639)
This commit is contained in:
@ -48,7 +48,7 @@ where
|
||||
V: AuthValidator,
|
||||
V::ResponseBody: Body,
|
||||
{
|
||||
/// Creates an instance of [`AuthLayer`][crate::layers::AuthLayer].
|
||||
/// Creates an instance of [`AuthLayer`].
|
||||
/// `validator` is a generic trait able to validate requests (see [`AuthValidator`]).
|
||||
pub fn new(validator: V) -> Self {
|
||||
Self { validator }
|
||||
@ -66,10 +66,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// This type is the actual implementation of
|
||||
/// the middleware. It follows the [`Service`](tower::Service)
|
||||
/// specification to correctly proxy Http requests
|
||||
/// to its inner service after headers validation.
|
||||
/// This type is the actual implementation of the middleware. It follows the [`Service`]
|
||||
/// specification to correctly proxy Http requests to its inner service after headers validation.
|
||||
#[allow(missing_debug_implementations)]
|
||||
pub struct AuthService<S, V> {
|
||||
/// Performs auth validation logics
|
||||
|
||||
@ -9,7 +9,7 @@ use std::{
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
/// Errors returned by the [`JwtSecret`][crate::layers::JwtSecret]
|
||||
/// Errors returned by the [`JwtSecret`]
|
||||
#[derive(Error, Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum JwtError {
|
||||
@ -56,7 +56,7 @@ const JWT_SIGNATURE_ALGO: Algorithm = Algorithm::HS256;
|
||||
pub struct JwtSecret([u8; 32]);
|
||||
|
||||
impl JwtSecret {
|
||||
/// Creates an instance of [`JwtSecret`][crate::layers::JwtSecret].
|
||||
/// Creates an instance of [`JwtSecret`].
|
||||
///
|
||||
/// Returns an error if one of the following applies:
|
||||
/// - `hex` is not a valid hexadecimal string
|
||||
@ -138,8 +138,7 @@ impl JwtSecret {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Generates a random [`JwtSecret`][crate::layers::JwtSecret]
|
||||
/// containing a hex-encoded 256 bit secret key.
|
||||
/// Generates a random [`JwtSecret`] containing a hex-encoded 256 bit secret key.
|
||||
pub fn random() -> Self {
|
||||
let random_bytes: [u8; 32] = rand::thread_rng().gen();
|
||||
let secret = hex_encode(random_bytes);
|
||||
|
||||
@ -7,15 +7,13 @@ pub use auth_layer::AuthLayer;
|
||||
pub use jwt_secret::{Claims, JwtError, JwtSecret};
|
||||
pub use jwt_validator::JwtAuthValidator;
|
||||
|
||||
/// General purpose trait to validate Http Authorization
|
||||
/// headers. It's supposed to be integrated as a validator
|
||||
/// trait into an [`AuthLayer`][crate::layers::AuthLayer].
|
||||
/// General purpose trait to validate Http Authorization headers. It's supposed to be integrated as
|
||||
/// a validator trait into an [`AuthLayer`].
|
||||
pub trait AuthValidator {
|
||||
/// Body type of the error response
|
||||
type ResponseBody;
|
||||
|
||||
/// This function is invoked by the [`AuthLayer`][crate::layers::AuthLayer]
|
||||
/// to perform validation on Http headers.
|
||||
/// This function is invoked by the [`AuthLayer`] to perform validation on Http headers.
|
||||
/// The result conveys validation errors in the form of an Http response.
|
||||
fn validate(&self, headers: &HeaderMap) -> Result<(), Response<Self::ResponseBody>>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user