generated from PlexSheep/rs-base
refactor: each challenge has their own vault in meta
This commit is contained in:
parent
695edbb563
commit
7f1ec08976
|
@ -73,6 +73,7 @@ pub async fn select_and_start_single(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
// TODO: actually use different vaults for the challenges #7
|
||||
pub async fn start_all(config: Config, vault: VaultRef) -> anyhow::Result<()> {
|
||||
let c1 = challenge::c1::C1::new(config.clone(), vault.clone());
|
||||
let c2 = challenge::c2::C2::new(config.clone(), vault.clone());
|
||||
|
@ -84,11 +85,10 @@ pub async fn start_all(config: Config, vault: VaultRef) -> anyhow::Result<()> {
|
|||
|
||||
meta::serve(
|
||||
vec![
|
||||
challenge::c1::C1::text(),
|
||||
challenge::c2::C2::text(),
|
||||
challenge::c3::C3::text(),
|
||||
(challenge::c1::C1::text(), vault.clone()),
|
||||
(challenge::c2::C2::text(), vault.clone()),
|
||||
(challenge::c3::C3::text(), vault.clone()),
|
||||
],
|
||||
vault.clone(),
|
||||
config.clone(),
|
||||
)
|
||||
.await?;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
|
@ -20,17 +21,15 @@ pub mod errors;
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct Service<'tp> {
|
||||
vault: VaultRef,
|
||||
config: Config,
|
||||
env: Environment<'tp>,
|
||||
challenges: Vec<ChallengeDesc>,
|
||||
challenges: Vec<(ChallengeDesc, VaultRef)>,
|
||||
}
|
||||
impl<'tp> Service<'tp> {
|
||||
fn build(vault: VaultRef, config: Config, challenges: Vec<ChallengeDesc>) -> Result<Arc<Self>> {
|
||||
fn build(config: Config, challenges: Vec<(ChallengeDesc, VaultRef)>) -> Result<Arc<Self>> {
|
||||
let mut env = Environment::new();
|
||||
env.add_template("index", include_str!("../../data/www/admin.html"))?;
|
||||
Ok(Self {
|
||||
vault,
|
||||
config,
|
||||
env,
|
||||
challenges,
|
||||
|
@ -39,8 +38,8 @@ impl<'tp> Service<'tp> {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn serve(challenges: Vec<ChallengeDesc>, vault: VaultRef, config: Config) -> Result<()> {
|
||||
let service = Service::build(vault, config, challenges)?;
|
||||
pub async fn serve(challenges: Vec<(ChallengeDesc, VaultRef)>, config: Config) -> Result<()> {
|
||||
let service = Service::build(config, challenges)?;
|
||||
|
||||
let routes = Service::admin_routes(service.clone())
|
||||
.or(Service::ressources_routes())
|
||||
|
|
Loading…
Reference in New Issue