mirror of
https://github.com/TECHNOFAB11/jwt-authorizer.git
synced 2025-12-11 23:50:07 +01:00
doc: multiple authorizers
This commit is contained in:
parent
cc7969db08
commit
cf6e3270b2
2 changed files with 9 additions and 1 deletions
|
|
@ -47,6 +47,11 @@ JWT authoriser Layer for Axum and Tonic.
|
||||||
# };
|
# };
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Multiple Authorizers
|
||||||
|
|
||||||
|
A layer can be built using multiple authorizers (`IntoLayer` is implemented for `[Authorizer<C>; N]` and for `Vec<Authorizer<C>>`).
|
||||||
|
The authorizers are sequentially applied until one of them validates the token. If no authorizer validates it the request is rejected.
|
||||||
|
|
||||||
## Validation
|
## Validation
|
||||||
|
|
||||||
Validation configuration object.
|
Validation configuration object.
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,9 @@ where
|
||||||
type RequestBody = B;
|
type RequestBody = B;
|
||||||
type Future = BoxFuture<'static, Result<Request<B>, AuthError>>;
|
type Future = BoxFuture<'static, Result<Request<B>, AuthError>>;
|
||||||
|
|
||||||
|
/// The authorizers are sequentially applied (check_auth) until one of them validates the token.
|
||||||
|
/// If no authorizer validates the token the request is rejected.
|
||||||
|
///
|
||||||
fn authorize(&self, mut request: Request<B>) -> Self::Future {
|
fn authorize(&self, mut request: Request<B>) -> Self::Future {
|
||||||
let tkns_auths: Vec<(String, Arc<Authorizer<C>>)> = self
|
let tkns_auths: Vec<(String, Arc<Authorizer<C>>)> = self
|
||||||
.auths
|
.auths
|
||||||
|
|
@ -244,7 +247,7 @@ where
|
||||||
|
|
||||||
Ok(request)
|
Ok(request)
|
||||||
}
|
}
|
||||||
Err(err) => Err(err), // TODO: error containing all errors (not just the last one)
|
Err(err) => Err(err), // TODO: error containing all errors (not just the last one) or to choose one?
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue