user: Add name to app token

This commit is contained in:
Lennart
2025-02-09 17:28:15 +01:00
parent d0d7a6dc78
commit 1d103ea312
3 changed files with 9 additions and 3 deletions

View File

@@ -54,7 +54,7 @@ impl AuthenticationProvider for TomlPrincipalStore {
// Try app tokens first since they are cheaper to calculate
// They can afford less iterations since they can be generated with high entropy
for app_token in &user.app_tokens {
if password_auth::verify_password(token, app_token).is_ok() {
if password_auth::verify_password(token, &app_token.token).is_ok() {
return Ok(Some(user));
}
}

View File

@@ -34,6 +34,12 @@ impl ValueSerialize for PrincipalType {
}
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct AppToken {
pub name: String,
pub token: String,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
// TODO: Rename this to Principal
@@ -44,7 +50,7 @@ pub struct User {
pub principal_type: PrincipalType,
pub password: Option<String>,
#[serde(default)]
pub app_tokens: Vec<String>,
pub app_tokens: Vec<AppToken>,
#[serde(default)]
pub memberships: Vec<String>,
}