feat: refresh configuration

This commit is contained in:
cduvray 2023-01-25 08:38:09 +01:00
parent 7b6f8fb4c5
commit 1203163b0c
9 changed files with 189 additions and 58 deletions

View file

@ -2,7 +2,7 @@ use axum::{
routing::{get, post},
Router,
};
use jwt_authorizer::{AuthError, JwtAuthorizer, JwtClaims};
use jwt_authorizer::{AuthError, JwtAuthorizer, JwtClaims, Refresh, RefreshStrategy};
use serde::Deserialize;
use std::{fmt::Display, net::SocketAddr};
use tower_http::trace::TraceLayer;
@ -30,7 +30,9 @@ async fn main() {
// User is a struct deserializable from JWT claims representing the authorized user
let jwt_auth: JwtAuthorizer<User> = JwtAuthorizer::
from_jwks_url("http://localhost:3000/oidc/jwks")
.with_check(claim_checker);
// .no_refresh()
.refresh(Refresh {strategy: RefreshStrategy::Interval, ..Default::default()})
.check(claim_checker);
let oidc = Router::new()
.route("/authorize", post(oidc_provider::authorize))

View file

@ -29,13 +29,6 @@ pub struct Keys {
}
impl Keys {
fn new(secret: &[u8]) -> Self {
Self {
alg: Algorithm::HS256,
encoding: EncodingKey::from_secret(secret),
decoding: DecodingKey::from_secret(secret),
}
}
fn load_rsa() -> Self {
Self {
alg: Algorithm::RS256,