Block POST requests from unknown origins

This commit is contained in:
2022-04-03 15:48:45 +02:00
parent 9f5fdd65ab
commit 9236b91f12
3 changed files with 35 additions and 10 deletions

View File

@ -5,7 +5,7 @@ use clap::Parser;
use crate::constants::USERS_LIST_FILE;
/// Basic OIDC provider
#[derive(Parser, Debug)]
#[derive(Parser, Debug, Clone)]
#[clap(author, version, about, long_about = None)]
pub struct AppConfig {
/// Listen address
@ -20,12 +20,16 @@ pub struct AppConfig {
#[clap(short, long, env, default_value = "")]
pub token_key: String,
/// Should the auth cookie be secure
#[clap(long, env)]
pub secure_auth_cookie: bool,
/// Website origin
#[clap(short, long, env, default_value = "http://localhost:8000")]
pub website_origin: String,
}
impl AppConfig {
pub fn secure_cookie(&self) -> bool {
self.website_origin.starts_with("https:")
}
pub fn storage_path(&self) -> &Path {
self.storage_path.as_ref()
}