All checks were successful
Frontend CI / build (push) Successful in 1m7s
### Description - Login with configured OIDC issuer, and then save the logged in information in server session. - Endpoints: - GET `/auth/login` - GET `/auth/callback` - GET `/auth/logout` ### Package Changes ```toml actix-session = { version = "0.10.1", features = ["redis-session"] } hex = "0.4.3" openidconnect = { version = "4.0.1", features = [ "reqwest", "reqwest-blocking", ] } ``` ### Screenshots <video src="attachments/8b15b576-61db-41b9-8587-b4b885018c93" title="Screencast From 2025-07-30 03-34-26.mp4" controls></video> ### Reference Resolves #85 ### Checklist - [x] A milestone is set - [x] The related issuse has been linked to this branch Reviewed-on: #93 Co-authored-by: SquidSpirit <squid@squidspirit.com> Co-committed-by: SquidSpirit <squid@squidspirit.com>
37 lines
1.0 KiB
Rust
37 lines
1.0 KiB
Rust
use actix_session::storage::RedisSessionStore;
|
|
use actix_web::cookie::Key;
|
|
|
|
#[derive(Clone)]
|
|
pub struct SessionConfiguration {
|
|
pub session_key: Key,
|
|
pub redis_url: String,
|
|
}
|
|
|
|
impl SessionConfiguration {
|
|
pub fn new() -> Self {
|
|
let session_key_hex = std::env::var("SESSION_KEY").expect("SESSION_KEY must be set");
|
|
let session_key_bytes =
|
|
hex::decode(session_key_hex).expect("Invalid SESSION_KEY format, must be hex encoded");
|
|
|
|
if session_key_bytes.len() != 64 {
|
|
panic!("SESSION_KEY must be 64 bytes long");
|
|
}
|
|
|
|
let session_key = Key::from(&session_key_bytes);
|
|
|
|
let redis_url =
|
|
std::env::var("REDIS_URL").unwrap_or_else(|_| "redis://127.0.1:6379".to_string());
|
|
|
|
Self {
|
|
session_key,
|
|
redis_url,
|
|
}
|
|
}
|
|
|
|
pub async fn create_session_store(&self) -> RedisSessionStore {
|
|
RedisSessionStore::new(self.redis_url.clone())
|
|
.await
|
|
.expect("Failed to create Redis session store")
|
|
}
|
|
}
|