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

Function verify_token

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

Source from the content-addressed store, hash-verified

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);
95 let timestamp = get_current_timestamp();
96 let token_key = generate_token_key(&master_key, timestamp);
97 let payload = format!("{}|{}", username, timestamp);
98
99 let expected_token = URL_SAFE_NO_PAD.encode(
100 hmac::sign(&token_key, payload.as_bytes()).as_ref()
101 );
102
103 token == expected_token
104}

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