Line data Source code
1 : use axum_extra::extract::cookie::Key;
2 : use clap::{Arg, Command};
3 : use std::fs;
4 :
5 0 : fn new_key_cmd() -> Command {
6 0 : Command::new("bliki-new-cookie-key")
7 0 : .about("Writes a random bytes to file and out. We can use these as the key to sign cookies with.")
8 0 : .arg(
9 0 : Arg::new("out")
10 0 : .short('f')
11 0 : .required(true)
12 0 : .help("The path to write the key to.")
13 : )
14 0 : }
15 :
16 0 : fn main() -> anyhow::Result<()> {
17 0 : let cmd = new_key_cmd();
18 0 : let args = cmd.get_matches();
19 0 : let outpath = args.get_one::<String>("out").unwrap();
20 0 : let key = Key::generate();
21 :
22 0 : fs::write(outpath, key.master())?;
23 0 : Ok(())
24 0 : }
|