feat(ui): Benutzer mit Rollen, Anmeldung mit Passwort, erste Einrichtung (#1062)
Argon2id, Standard-Admin mit Einmalpasswort in Datei, eigener Admin bei der ersten Einrichtung, Rollen admin und nutzer, Benutzerverwaltung, Mein Konto, nexus user. Die Anmeldung mit API-Key an der Oberfläche entfällt. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GmHhg3osejhFSpUz472iQ1
This commit is contained in:
@ -10,6 +10,8 @@ use crate::{Store, db};
|
||||
pub struct RequestLogEntry {
|
||||
pub correlation: String,
|
||||
pub api_key_id: Option<i64>,
|
||||
/// Name des Benutzers (Anfragen aus dem Playground), sonst `None`.
|
||||
pub user: Option<String>,
|
||||
/// Name des Modells; wird zur ID aufgelöst, falls es das Modell gibt.
|
||||
pub model: Option<String>,
|
||||
pub status: u16,
|
||||
@ -77,8 +79,8 @@ impl Store {
|
||||
self.connection()
|
||||
.execute(
|
||||
"INSERT INTO anfrage_log (zeit, korrelation, api_key_id, model_id, status, wartezeit_ms, latenz_ms,
|
||||
dauer_ms, tokens_ein, tokens_aus, engine, instanz_id, abgebrochen)
|
||||
VALUES (?1, ?2, ?3, (SELECT id FROM model WHERE name = ?4), ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13)",
|
||||
dauer_ms, tokens_ein, tokens_aus, engine, instanz_id, abgebrochen, benutzer)
|
||||
VALUES (?1, ?2, ?3, (SELECT id FROM model WHERE name = ?4), ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14)",
|
||||
(
|
||||
now_iso8601(),
|
||||
&entry.correlation,
|
||||
@ -93,6 +95,7 @@ impl Store {
|
||||
&entry.engine,
|
||||
entry.instance_id.map(|v| v as i64),
|
||||
entry.aborted as i64,
|
||||
&entry.user,
|
||||
),
|
||||
)
|
||||
.map_err(db)?;
|
||||
@ -136,7 +139,7 @@ impl Store {
|
||||
let mut stmt = self
|
||||
.connection()
|
||||
.prepare(
|
||||
"SELECT a.zeit, a.korrelation, k.name, m.name, a.status, a.wartezeit_ms, a.latenz_ms,
|
||||
"SELECT a.zeit, a.korrelation, COALESCE(k.name, a.benutzer), m.name, a.status, a.wartezeit_ms, a.latenz_ms,
|
||||
a.dauer_ms, a.tokens_ein, a.tokens_aus, a.engine, a.abgebrochen
|
||||
FROM anfrage_log a
|
||||
LEFT JOIN api_key k ON k.id = a.api_key_id
|
||||
@ -271,6 +274,7 @@ mod tests {
|
||||
RequestLogEntry {
|
||||
correlation: "req_abc".to_string(),
|
||||
api_key_id: key,
|
||||
user: None,
|
||||
model: model.map(str::to_string),
|
||||
status: 200,
|
||||
wait_ms: Some(300),
|
||||
|
||||
Reference in New Issue
Block a user