forge
Explore
Log in

Don't you dare go Hollow

in_old

Clone
★ 0

0 watching0 forksRustGPL-3.01.1 MiB218b775Tahinli2 months ago90 commits

mint.rs36 lines, 1.4 KiBHistoryRawDownload
1//! Development helper: mints a session-cookie value for smoke runs against a
2//! fake im, without a browser dance. Requires the `test-seam` feature.
3//!
4//! ```text
5//! cargo run -p in-client --example mint --features test-seam -- \
6//! <path-to-in.key> <app-session-token> [cookie-name]
7//! ```
8//!
9//! Print the value, then hand it to the browser as the session cookie. Any
10//! token string works as long as the fake provider's introspection answers
11//! `active: true` for it.
12
13fn main() {
14 let mut args = std::env::args().skip(1);
15 let key_path = args.next().unwrap_or_else(|| {
16 eprintln!("usage: mint <in.key path> <app-session-token> [cookie-name]");
17 std::process::exit(2);
18 });
19 let token = args.next().expect("token");
20 let cookie_name = args.next().unwrap_or_else(|| "in_session".to_string());
21 let key: [u8; 32] = std::fs::read(&key_path)
22 .unwrap_or_else(|e| panic!("{key_path}: {e}"))
23 .try_into()
24 .expect("key file is not 32 bytes");
25 let config = in_client::Config {
26 issuer: String::new(),
27 client_id: String::new(),
28 client_secret: String::new(),
29 redirect_uri: String::new(),
30 cookie_name,
31 cookie_key: key,
32 logout_back: String::new(),
33 };
34 let exp = time::OffsetDateTime::now_utc() + time::Duration::days(1);
35 println!("{}", in_client::mint_session_cookie(&config, &token, exp));
36}