WS-D: harden file modes, token names; more auth tests
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YShymaPrXmc3KYRUg2HMSs
This commit is contained in:
1 parent
b6c814a18f
commit
e25f0e83bf
3 files changed
+121
-4
No files matched your search
+5
-1
@@ -54,9 +54,13 @@ fn now_string() -> String {
|
||||
|
||||
/// Create a token and return the plaintext (shown once, never stored).
|
||||
pub async fn create(pool: &SqlitePool, name: &str) -> Result<String> {
|
||||
if name.trim().is_empty() {
|
||||
let name = name.trim();
|
||||
if name.is_empty() {
|
||||
bail!("token name must not be empty");
|
||||
}
|
||||
if name.chars().any(char::is_control) {
|
||||
bail!("token name must not contain control characters");
|
||||
}
|
||||
let mut bytes = [0u8; 32];
|
||||
SysRng
|
||||
.try_fill_bytes(&mut bytes)
|
||||
|
||||
Reference in new issue
Block a user