mirror of
https://github.com/TECHNOFAB11/jwt-authorizer.git
synced 2025-12-12 16:10:06 +01:00
docs
This commit is contained in:
parent
dff56bf058
commit
141738419d
3 changed files with 41 additions and 3 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -7,7 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## Unreleased
|
||||
|
||||
## 0.3.2 - (2023-1-??)
|
||||
## 0.4.0 - (2023-1-21)
|
||||
|
||||
### Added
|
||||
|
||||
- claims checker (stabilisation, tests, documentation)
|
||||
|
||||
### Fixed
|
||||
|
||||
- added missing WWW-Authenticate header to errors
|
||||
|
||||
## 0.3.2 - (2023-1-18)
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ JWT authorizer Layer for Axum.
|
|||
- JWT token verification (Bearer)
|
||||
- Claims extraction
|
||||
- JWKS endpoint support (with refresh)
|
||||
- algoritms: ECDSA, RSA, EdDSA, HS
|
||||
- Algoritms: ECDSA, RSA, EdDSA, HS
|
||||
- Claims checker
|
||||
|
||||
## Usage
|
||||
|
||||
|
|
|
|||
|
|
@ -34,3 +34,30 @@ Example:
|
|||
.serve(app.into_make_service()).await.expect("server failed");
|
||||
# };
|
||||
```
|
||||
|
||||
## ClaimsChecker
|
||||
|
||||
A check function (mapping deserialized claims to boolean) can be added to the authorizer.
|
||||
|
||||
A check failure results in a 403 (WWW-Authenticate: Bearer error="insufficient_scope") error.
|
||||
|
||||
Example:
|
||||
|
||||
```rust
|
||||
|
||||
use jwt_authorizer::{JwtAuthorizer};
|
||||
use serde::Deserialize;
|
||||
|
||||
// Authorized entity, struct deserializable from JWT claims
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
struct User {
|
||||
sub: String,
|
||||
}
|
||||
|
||||
let authorizer = JwtAuthorizer::new()
|
||||
.from_rsa_pem("../config/jwtRS256.key.pub")
|
||||
.with_check(
|
||||
|claims: &User| claims.sub.contains('@') // must be an email
|
||||
);
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue