MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / issue_token

Function issue_token

mserver/MasterService/src/service.rs:403–410  ·  view source on GitHub ↗

Generate a fresh server token: `(plaintext, hash)`. The plaintext is returned to the server once on register; only the hash is persisted.

()

Source from the content-addressed store, hash-verified

401fn to_hex(bytes: &[u8]) -> String {
402 bytes.iter().map(|byte| format!("{byte:02x}")).collect()
403}
404
405/// SHA-256 hex of a server token (what the DB stores; never the token itself).
406pub fn token_hash(token: &str) -> String {
407 to_hex(&sha2::Sha256::digest(token.as_bytes()))
408}
409
410/// Generate a fresh server token: `(plaintext, hash)`. The plaintext is returned to the
411/// server once on register; only the hash is persisted.
412pub fn issue_token() -> Result<(String, String)> {
413 let mut bytes = [0u8; 32];

Callers 1

register_serverFunction · 0.85

Calls 2

to_hexFunction · 0.85
token_hashFunction · 0.85

Tested by

no test coverage detected