MCPcopy Create free account
hub / github.com/cosdata/cosdata / create_session

Function create_session

org/src/session_token.rs:77–91  ·  view source on GitHub ↗
(username: &str, server_key: &[u8], password: &str)

Source from the content-addressed store, hash-verified

75}
76
77fn create_session(username: &str, server_key: &[u8], password: &str) -> Session {
78 let master_key = derive_master_key(server_key, password);
79 let timestamp = get_current_timestamp();
80 let token_key = generate_token_key(&master_key, timestamp);
81
82 let payload = format!("{}|{}", username, timestamp);
83 let access_token = URL_SAFE_NO_PAD.encode(
84 hmac::sign(&token_key, payload.as_bytes()).as_ref()
85 );
86
87 Session {
88 access_token,
89 expires_at: timestamp + TOKEN_LIFETIME,
90 }
91}
92
93fn verify_token(token: &str, username: &str, server_key: &[u8], password: &str) -> bool {
94 let master_key = derive_master_key(server_key, password);

Callers

nothing calls this directly

Calls 3

derive_master_keyFunction · 0.85
get_current_timestampFunction · 0.70
generate_token_keyFunction · 0.70

Tested by

no test coverage detected