From 9499c195230a7d5adaebd46892b373c86c5248c2 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sat, 20 Jan 2024 14:47:39 +0100 Subject: seperate secrets config file --- common/src/config.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'common/src') diff --git a/common/src/config.rs b/common/src/config.rs index 7328d6e..1c1439e 100644 --- a/common/src/config.rs +++ b/common/src/config.rs @@ -5,6 +5,7 @@ */ use crate::{jhls::EncodingProfile, user::PermissionSet}; +use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use std::{collections::HashMap, path::PathBuf}; @@ -20,16 +21,47 @@ pub struct GlobalConfig { #[serde(default = "default::temp_path")] pub temp_path: PathBuf, #[serde(default = "default::cache_path")] pub cache_path: PathBuf, #[serde(default = "default::media_path")] pub media_path: PathBuf, + #[serde(default = "default::secrets_path")] pub secrets_path: PathBuf, #[serde(default = "default::transcoding_profiles")] pub transcoding_profiles: Vec, #[serde(default = "default::max_in_memory_cache_size")] pub max_in_memory_cache_size: usize, #[serde(default)] pub admin_username: Option, - #[serde(default)] pub admin_password: Option, - #[serde(default)] pub cookie_key: Option, - #[serde(default)] pub session_key: Option, #[serde(default = "default::login_expire")] pub login_expire: i64, - #[serde(default)] pub remote_credentials: HashMap, #[serde(default)] pub default_permission_set: PermissionSet, - #[serde(default)] pub tmdb_api_key: Option, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct SecretsConfig { + pub federation: HashMap, + pub api: ApiSecrets, + #[serde(default)] + pub cookie_key: Option, + #[serde(default)] + pub session_key: Option, + #[serde(default)] + pub admin_password: Option, +} +#[derive(Serialize, Deserialize, Debug)] +pub struct FederationAccount { + pub username: String, + pub password: String, + #[serde(default = "return_true")] + pub tls: bool, +} +#[derive(Serialize, Deserialize, Debug)] +pub struct ApiSecrets { + pub tmdb: Option, + pub imdb: Option, + pub omdb: Option, + pub fanart_tv: Option, + pub trakt: Option, +} +#[derive(Serialize, Deserialize, Debug)] +pub struct TraktApiSecrets { + pub client_id: String, + pub client_secret: String, + pub expire: DateTime, + pub access_token: String, + pub refresh_token: String, } mod default { @@ -54,6 +86,9 @@ mod default { pub fn media_path() -> PathBuf { "data/media".into() } + pub fn secrets_path() -> PathBuf { + "data/secrets.yaml".into() + } pub fn temp_path() -> PathBuf { "/tmp".into() } @@ -98,3 +133,7 @@ mod default { ] } } + +fn return_true() -> bool { + true +} -- cgit v1.2.3-70-g09d2