diff options
author | metamuffin <metamuffin@disroot.org> | 2024-01-20 14:47:39 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-01-20 14:47:39 +0100 |
commit | 9499c195230a7d5adaebd46892b373c86c5248c2 (patch) | |
tree | ff652e9959dc2f0349a4e5aed75e8837b452e45f /common/src/config.rs | |
parent | 730353601db9818d148c85bfe1ecb119abaab7cc (diff) | |
download | jellything-9499c195230a7d5adaebd46892b373c86c5248c2.tar jellything-9499c195230a7d5adaebd46892b373c86c5248c2.tar.bz2 jellything-9499c195230a7d5adaebd46892b373c86c5248c2.tar.zst |
seperate secrets config file
Diffstat (limited to 'common/src/config.rs')
-rw-r--r-- | common/src/config.rs | 49 |
1 files changed, 44 insertions, 5 deletions
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<EncodingProfile>, #[serde(default = "default::max_in_memory_cache_size")] pub max_in_memory_cache_size: usize, #[serde(default)] pub admin_username: Option<String>, - #[serde(default)] pub admin_password: Option<String>, - #[serde(default)] pub cookie_key: Option<String>, - #[serde(default)] pub session_key: Option<String>, #[serde(default = "default::login_expire")] pub login_expire: i64, - #[serde(default)] pub remote_credentials: HashMap<String, (String, String, bool)>, #[serde(default)] pub default_permission_set: PermissionSet, - #[serde(default)] pub tmdb_api_key: Option<String>, +} + +#[derive(Serialize, Deserialize, Debug)] +pub struct SecretsConfig { + pub federation: HashMap<String, FederationAccount>, + pub api: ApiSecrets, + #[serde(default)] + pub cookie_key: Option<String>, + #[serde(default)] + pub session_key: Option<String>, + #[serde(default)] + pub admin_password: Option<String>, +} +#[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<String>, + pub imdb: Option<String>, + pub omdb: Option<String>, + pub fanart_tv: Option<String>, + pub trakt: Option<TraktApiSecrets>, +} +#[derive(Serialize, Deserialize, Debug)] +pub struct TraktApiSecrets { + pub client_id: String, + pub client_secret: String, + pub expire: DateTime<Utc>, + 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 +} |