mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-16 12:12:35 -06:00
feat: setup github provider with generic trait, proper routes, session & jwt handling, errors & user agent
This commit is contained in:
28
pacman-server/src/app.rs
Normal file
28
pacman-server/src/app.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use dashmap::DashMap;
|
||||
use jsonwebtoken::{DecodingKey, EncodingKey};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{auth::AuthRegistry, config::Config};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AppState {
|
||||
pub config: Arc<Config>,
|
||||
pub auth: Arc<AuthRegistry>,
|
||||
pub sessions: Arc<DashMap<String, crate::auth::provider::AuthUser>>,
|
||||
pub jwt_encoding_key: Arc<EncodingKey>,
|
||||
pub jwt_decoding_key: Arc<DecodingKey>,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
pub fn new(config: Config, auth: AuthRegistry) -> Self {
|
||||
let jwt_secret = config.jwt_secret.clone();
|
||||
|
||||
Self {
|
||||
config: Arc::new(config),
|
||||
auth: Arc::new(auth),
|
||||
sessions: Arc::new(DashMap::new()),
|
||||
jwt_encoding_key: Arc::new(EncodingKey::from_secret(jwt_secret.as_bytes())),
|
||||
jwt_decoding_key: Arc::new(DecodingKey::from_secret(jwt_secret.as_bytes())),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user