feat: load cookie secret in settings

This commit is contained in:
Aravinth Manivannan 2024-05-12 21:18:32 +05:30
parent 64a7e2e670
commit 92b83365e4
Signed by: realaravinth
GPG key ID: F8F50389936984FF
3 changed files with 11 additions and 0 deletions

View file

@ -1 +1,3 @@
export POSTGRES_DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"
export POSTGRES_DATABASE_URL="postgres://postgres:password@localhost:5432/postgres"
export FORGEFLUX_server_COOKIE_SECRET=""

View file

@ -13,6 +13,7 @@ port = 7000
ip= "0.0.0.0"
# enter your hostname, eg: example.com
domain = "localhost:7000"
#cookie_secret = ""
[database]
# This section deals with the database location and how to access it

View file

@ -7,6 +7,7 @@ pub struct Server {
pub port: u32,
pub domain: String,
pub ip: String,
pub cookie_secret: String,
}
impl Server {
@ -18,6 +19,7 @@ impl Server {
for (parameter, env_var_name) in [
("server.port", "PORT"),
("server.domain", "FORGEFLUX_server_DOMAIN"),
("server.cookie_secret", "FORGEFLUX_server_COOKIE_SECRET"),
("server.ip", "FORGEFLUX_server_IP"),
]
.iter()
@ -49,5 +51,11 @@ mod tests {
server.domain
);
env_helper!(init_settings, "FORGEFLUX_server_IP", "1.1.1.1", server.ip);
env_helper!(
init_settings,
"FORGEFLUX_server_COOKIE_SECRET",
"asdfasdflkjhasdlkfhalksdf",
server.cookie_secret
);
}
}