use jsonwebtoken::Algorithm;
use serde::Deserialize;

#[derive(Debug, Default, Deserialize)]
pub struct Auth {
    #[serde(default)]
    pub guard: Guard,
    #[serde(default)]
    pub jwt: Jwt,
}

#[derive(Debug, Deserialize, Default)]
pub enum Guard {
    #[default]
    #[serde(rename = "jwt")]
    Jwt,
}

#[derive(Debug, Deserialize, Default)]
pub struct Jwt {
    pub secret: String,
    pub expiration: u64,
    #[serde(default)]
    pub algorithm: Algorithm,
    pub location: Option<JwtLocation>,
}

#[derive(Debug, Deserialize)]
pub enum JwtLocation {
    #[serde(rename = "bearer")]
    Bearer,
    #[serde(rename = "query")]
    Query { name: String },
    #[serde(rename = "cookie")]
    Cookie { name: String },
}
