sfx 0.1.1

SFX is a streamlined, full-stack Rust framework for building small web services with integrated authentication, localization, and config-driven UI components
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
# SFX Auth Endpoint Alignment Plan


## Overview


Align sfx's auth endpoints with questboard's `/auth/v1/` API pattern, supporting:
1. **Local inline auth** - sfx's minimal `LOCAL_AUTH` for local users
2. **External auth servers** - questboard-style servers via HTTP proxy
3. **Server selection at login** - user/app chooses which auth server
4. **Unified user ID** - `u128` type for both local (`u32`) and external (`UUID`)

---

## Architecture


```
┌─────────────────────────────────────────────────────────────────┐
│                         SFX Application                          │
│                                                                   │
│   Login: { id: "user", password: "...", server: "..." }          │
│                              │                                    │
│              ┌───────────────┴───────────────┐                   │
│              ▼                               ▼                    │
│   ┌──────────────────────┐      ┌──────────────────────────────┐ │
│   │  server = "" (local)  │      │  server = "dept-a.local"    │ │
│   │                       │      │                              │ │
│   │  LOCAL_AUTH           │      │  HTTP Proxy to external      │ │
│   │  u128 from u32        │      │  POST {server}/auth/v1/...   │ │
│   └───────────┬───────────┘      └──────────────┬───────────────┘ │
│               │                                  │                │
│               ▼                                  ▼                │
│   ┌─────────────────────────────────────────────────────────────┐ │
│   │  Unified Session Storage                                     │ │
│   │                                                              │ │
│   │  UserRef { server: String, id: u128 }                       │ │
│   │  - Local:  "local@42"        (u32 as u128)                  │ │
│   │  - Remote: "dept.local@..."  (UUID as u128)                 │ │
│   │                                                              │ │
│   │  Token { value, server, user_id, expires }                  │ │
│   └─────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
```

**Key Design:**
- `u128` unifies both `u32` (local) and `UUID` (external)
- Same endpoints across all servers: `/auth/v1/login`, `/auth/v1/me`, etc.
- Server context stored with token for refresh/logout routing

---

## 1. Endpoint Migration


| Current | New | HTTP |
|---------|-----|------|
| `/auth/login` | `/auth/v1/login` | POST |
| `/auth/logout` | `/auth/v1/logout` | POST |
| `/auth/refresh` | `/auth/v1/refresh` | POST |
| `/users/me` | `/auth/v1/me` | GET |
| `/users/me/password` | `/auth/v1/change-password` | POST |
| `/users` | `/auth/v1/users` | POST |
| `/health` | `/auth/v1/health` | GET |

---

## 2. New Type: `UserRef` (unified user identification)


Create `src/local_auth/user_ref.rs`:

```rust
//! Unified user reference for cross-server identification.
//!
//! Format: "server@id" where id is u128 (hex for external, decimal for local)
//! Examples:
//! - "local@42" - local user with uid 42
//! - "dept-a.local@550e8400e29b41d4a716446655440000" - external UUID

/// Unified user reference across servers.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]

pub struct UserRef {
    pub server: String,  // "local" or server URL
    pub id: u128,
}

impl UserRef {
    /// Create a local user reference.
    pub fn local(uid: u32) -> Self {
        Self {
            server: "local".to_string(),
            id: uid as u128,
        }
    }

    /// Create an external user reference.
    pub fn external(server: impl Into<String>, uuid: u128) -> Self {
        Self {
            server: server.into(),
            id: uuid,
        }
    }

    /// Parse from string format "server@id".
    pub fn parse(s: &str) -> Option<Self> {
        let (server, id_str) = s.split_once('@')?;
        let id = if server == "local" {
            // Local IDs are decimal
            id_str.parse::<u32>().ok()? as u128
        } else {
            // External IDs are hex (UUID without dashes)
            u128::from_str_radix(id_str, 16).ok()?
        };
        Some(Self {
            server: server.to_string(),
            id,
        })
    }

    /// Check if this is a local user.
    pub fn is_local(&self) -> bool {
        self.server == "local"
    }

    /// Get as u32 (only valid for local users).
    pub fn as_local_uid(&self) -> Option<u32> {
        if self.is_local() && self.id <= u32::MAX as u128 {
            Some(self.id as u32)
        } else {
            None
        }
    }
}

impl std::fmt::Display for UserRef {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        if self.is_local() {
            write!(f, "local@{}", self.id)
        } else {
            write!(f, "{}@{:032x}", self.server, self.id)
        }
    }
}
```

---

## 3. New Module: `src/local_auth/proxy.rs` (external auth proxy)


```rust
//! HTTP proxy for external auth servers.
//!
//! Routes auth requests to external questboard-style servers.
//! Uses reqwest for outbound HTTP calls.

use hotaru::prelude::*;

/// Simple HTTP client for external auth calls.
/// (Could use reqwest or hotaru's built-in client)
async fn http_post(url: &str, body: Value, auth_token: Option<&str>) -> Result<Value, String> {
    let client = reqwest::Client::new();
    let mut req = client.post(url)
        .header("Content-Type", "application/json")
        .body(body.into_json());

    if let Some(token) = auth_token {
        req = req.header("Authorization", format!("Bearer {}", token));
    }

    match req.send().await {
        Ok(resp) => {
            let text = resp.text().await.map_err(|e| e.to_string())?;
            Value::from_json(&text).map_err(|e| e.to_string())
        }
        Err(e) => Err(format!("Connection failed: {}", e)),
    }
}

async fn http_get(url: &str, auth_token: &str) -> Result<Value, String> {
    let client = reqwest::Client::new();
    let resp = client.get(url)
        .header("Authorization", format!("Bearer {}", auth_token))
        .send()
        .await
        .map_err(|e| format!("Connection failed: {}", e))?;

    let text = resp.text().await.map_err(|e| e.to_string())?;
    Value::from_json(&text).map_err(|e| e.to_string())
}

/// Check if response is an error.
fn is_error(response: &Value) -> Option<String> {
    if response.try_get("error").is_ok() {
        Some(response.get("message").string())
    } else {
        None
    }
}

/// Proxy login to external auth server.
pub async fn proxy_login(server: &str, id: &str, password: &str) -> Result<Value, String> {
    let url = format!("{}/auth/v1/login", server);
    let body = object!({ id: id, password: password });

    let response = http_post(&url, body, None).await?;
    if let Some(msg) = is_error(&response) {
        Err(msg)
    } else {
        Ok(response)
    }
}

/// Proxy refresh to external auth server.
pub async fn proxy_refresh(server: &str, token: &str) -> Result<Value, String> {
    let url = format!("{}/auth/v1/refresh", server);
    let response = http_post(&url, object!({}), Some(token)).await?;
    if let Some(msg) = is_error(&response) {
        Err(msg)
    } else {
        Ok(response)
    }
}

/// Proxy logout to external auth server.
pub async fn proxy_logout(server: &str, token: &str) -> Result<(), String> {
    let url = format!("{}/auth/v1/logout", server);
    let response = http_post(&url, object!({}), Some(token)).await?;
    if let Some(msg) = is_error(&response) {
        Err(msg)
    } else {
        Ok(())
    }
}

/// Proxy get user info from external auth server.
pub async fn proxy_me(server: &str, token: &str) -> Result<Value, String> {
    let url = format!("{}/auth/v1/me", server);
    let response = http_get(&url, token).await?;
    if let Some(msg) = is_error(&response) {
        Err(msg)
    } else {
        Ok(response)
    }
}

/// Proxy introspect to external auth server.
pub async fn proxy_introspect(server: &str, token: &str) -> Result<Value, String> {
    let url = format!("{}/auth/v1/introspect", server);
    let body = object!({ token: token });
    http_post(&url, body, None).await
}
```

---

## 4. New File: `src/local_auth/response.rs`


```rust
//! Standardized error responses aligned with questboard format.
//!
//! Error format: { "error": "<category>", "reason": "<code>", "message": "<text>" }

use hotaru::prelude::*;
use hotaru::http::*;
use super::fop::FopError;

/// Create a structured error response.
pub fn error_response(error: &str, reason: &str, message: &str, status: u16) -> HttpResponse {
    akari_json!({
        error: error,
        reason: reason,
        message: message
    }).status(status)
}

/// Convert FopError to structured HTTP response.
pub fn from_fop_error(err: FopError) -> HttpResponse {
    match err {
        FopError::TokenInvalid => error_response(
            "unauthorized",
            "token_invalid",
            "Token is invalid or expired",
            401
        ),
        FopError::PasswordMismatch => error_response(
            "unauthorized",
            "invalid_credentials",
            "Invalid credentials",
            401
        ),
        FopError::UserNotFound => error_response(
            "not_found",
            "user_not_found",
            "User not found",
            404
        ),
        FopError::UserNameNotValid => error_response(
            "validation",
            "invalid_username",
            "Username is not valid",
            400
        ),
        FopError::EmailNotValid => error_response(
            "validation",
            "invalid_email",
            "Email is not valid",
            400
        ),
        FopError::TooManyRequest => error_response(
            "rate_limit",
            "too_many_requests",
            "Too many requests",
            429
        ),
        FopError::UserTooBig => error_response(
            "server_error",
            "internal_error",
            "Internal server error",
            500
        ),
        FopError::Other(msg) => error_response(
            "server_error",
            "unknown_error",
            &msg,
            500
        ),
    }
}

/// Unauthorized error (missing/invalid auth header).
pub fn unauthorized(reason: &str, message: &str) -> HttpResponse {
    error_response("unauthorized", reason, message, 401)
}

/// Forbidden error (authenticated but not allowed).
pub fn forbidden(reason: &str, message: &str) -> HttpResponse {
    error_response("forbidden", reason, message, 403)
}

/// Validation error.
pub fn validation_error(reason: &str, message: &str) -> HttpResponse {
    error_response("validation", reason, message, 400)
}

/// Method not allowed error.
pub fn method_not_allowed() -> HttpResponse {
    error_response("method_error", "method_not_allowed", "Method not allowed", 405)
}
```

---

## 3. Update `src/local_auth/mod.rs`


```rust
pub mod fop;
pub mod endpoints;
pub mod analyze;
pub mod response;   // Error response helpers
pub mod user_ref;   // UserRef type for cross-server IDs
pub mod proxy;      // External auth server proxy

use std::time::Duration;
use once_cell::sync::Lazy;

pub static LOCAL_AUTH: Lazy<fop::AuthManager> =
    Lazy::new(|| fop::AuthManager::new("programfiles/local_auth/users", Duration::from_secs(180)));
```

---

## 4. Update `src/local_auth/endpoints.rs` (Hotaru + Multi-Server)


```rust
use hotaru::prelude::*;
use hotaru::http::*;
use crate::op::APP;
use super::analyze::get_auth_token;
use super::response::{from_fop_error, unauthorized, forbidden, method_not_allowed, error_response};
use super::proxy;
use super::user_ref::UserRef;
use super::LOCAL_AUTH;
use crate::admin::check_is_admin;

endpoint! {
    APP.url("/auth/v1/users"),

    /// POST - Register new user (admin only, local only)
    pub create_user <HTTP> {
        if req.method() != POST {
            return method_not_allowed();
        }
        if !check_is_admin(&req).await {
            return forbidden("unauthorized", "Admin access required");
        }
        let json = req.json().await.unwrap_or(&Value::Null);
        let username = json.get("username").string();
        let email = json.get("email").string();
        let password = json.get("password").string();
        match LOCAL_AUTH.register_user(&username, &email, &password).await {
            Ok(_) => akari_json!({ success: true, username: &username }),
            Err(err) => from_fop_error(err),
        }
    }
}

endpoint! {
    APP.url("/auth/v1/me"),

    /// GET - Get current user info (routes to local or external)
    pub user_me <HTTP> {
        let token = match get_auth_token(&req) {
            Some(t) => t,
            None => return unauthorized("token_missing", "Authorization header required"),
        };

        let server = req.locals.get::<String>("auth_server")
            .map(|s| s.clone())
            .unwrap_or_else(|| "local".to_string());

        if server == "local" {
            match LOCAL_AUTH.get_user_info(token).await {
                Ok(mut user) => {
                    user += object!({ is_active: true, is_verified: true, server: "local" });
                    akari_json!({ success: true, user: user })
                }
                Err(err) => from_fop_error(err),
            }
        } else {
            match proxy::proxy_me(&server, &token).await {
                Ok(mut user) => {
                    user += object!({ server: &server });
                    akari_json!({ success: true, user: user })
                }
                Err(msg) => error_response("unauthorized", "external_auth_failed", &msg, 401),
            }
        }
    }
}

endpoint! {
    APP.url("/auth/v1/change-password"),

    /// POST - Change password (local users only)
    pub change_password <HTTP> {
        if req.method() != POST {
            return method_not_allowed();
        }
        let token = match get_auth_token(&req) {
            Some(t) => t,
            None => return unauthorized("token_missing", "Authorization header required"),
        };

        let server = req.locals.get::<String>("auth_server")
            .map(|s| s.clone())
            .unwrap_or_else(|| "local".to_string());

        if server != "local" {
            return error_response(
                "forbidden", "external_user",
                "External users must change password on their auth server", 403
            );
        }

        let json = req.json().await.unwrap_or(&Value::Null);
        let old_password = json.get("old_password").string();
        let new_password = json.get("new_password").string();
        if old_password.is_empty() || new_password.is_empty() {
            return super::response::validation_error(
                "invalid_input", "Both old_password and new_password are required"
            );
        }
        match LOCAL_AUTH.change_password(&token, &old_password, &new_password).await {
            Ok(_) => akari_json!({ success: true }),
            Err(err) => from_fop_error(err),
        }
    }
}

endpoint! {
    APP.url("/auth/v1/refresh"),

    /// POST - Refresh token (routes based on session)
    pub refresh_token <HTTP> {
        if req.method() != POST {
            return method_not_allowed();
        }
        let token = match get_auth_token(&req) {
            Some(t) => t,
            None => return unauthorized("token_missing", "Authorization header required"),
        };

        let server = req.locals.get::<String>("auth_server")
            .map(|s| s.clone())
            .unwrap_or_else(|| "local".to_string());

        if server == "local" {
            match LOCAL_AUTH.refresh_token(&token).await {
                Ok(new_token) => akari_json!({
                    success: true,
                    access_token: &new_token,
                    token_type: "Bearer"
                }),
                Err(err) => from_fop_error(err),
            }
        } else {
            match proxy::proxy_refresh(&server, &token).await {
                Ok(response) => akari_json!({ ..response }),
                Err(msg) => error_response("unauthorized", "refresh_failed", &msg, 401),
            }
        }
    }
}

endpoint! {
    APP.url("/auth/v1/login"),

    /// POST - Login with server selection
    /// Request: { id, password, server? }
    /// - server="" or "local" → LOCAL_AUTH
    /// - server="https://..." → proxy to external
    pub login <HTTP> {
        if req.method() != POST {
            return method_not_allowed();
        }
        let json = req.json().await.unwrap_or(&Value::Null);
        let id = match json.try_get("id") {
            Ok(value) => value.string(),
            Err(_) => json.get("username").string(),
        };
        let password = json.get("password").string();
        let server = json.get("server").string();

        if server.is_empty() || server == "local" {
            // === LOCAL AUTH ===
            let uid = match LOCAL_AUTH.uid_from_username_or_email_or_uid(id).await {
                Ok(uid) => uid,
                Err(err) => return from_fop_error(err),
            };
            match LOCAL_AUTH.login_user(uid, &password).await {
                Ok(token) => {
                    req.locals.set("auth_server", "local".to_string());
                    req.locals.set("auth_uid", uid);
                    let user_ref = UserRef::local(uid);
                    akari_json!({
                        success: true,
                        access_token: &token,
                        token_type: "Bearer",
                        server: "local",
                        user_ref: user_ref.to_string()
                    })
                }
                Err(err) => from_fop_error(err),
            }
        } else {
            // === EXTERNAL AUTH ===
            match proxy::proxy_login(&server, &id, &password).await {
                Ok(response) => {
                    req.locals.set("auth_server", server.clone());
                    let uid_str = response.get("user").get("uid").string();
                    let user_ref = if let Ok(uuid) = u128::from_str_radix(&uid_str.replace("-", ""), 16) {
                        UserRef::external(&server, uuid).to_string()
                    } else {
                        format!("{}@{}", server, uid_str)
                    };
                    akari_json!({
                        success: true,
                        access_token: response.get("access_token").string(),
                        token_type: "Bearer",
                        server: &server,
                        user_ref: &user_ref
                    })
                }
                Err(msg) => error_response("unauthorized", "invalid_credentials", &msg, 401),
            }
        }
    }
}

endpoint! {
    APP.url("/auth/v1/logout"),

    /// POST - Logout (routes based on session)
    pub logout <HTTP> {
        if req.method() != POST {
            return method_not_allowed();
        }
        let token = match get_auth_token(&req) {
            Some(t) => t,
            None => return unauthorized("token_missing", "Authorization header required"),
        };

        let server = req.locals.get::<String>("auth_server")
            .map(|s| s.clone())
            .unwrap_or_else(|| "local".to_string());

        let result = if server == "local" {
            LOCAL_AUTH.logout_user(&token).await.map_err(|e| e.to_string())
        } else {
            proxy::proxy_logout(&server, &token).await
        };

        // Clear session
        req.locals.remove::<String>("auth_server");
        req.locals.remove::<u32>("auth_uid");

        match result {
            Ok(_) => akari_json!({ success: true, message: "Logged out" }),
            Err(msg) => error_response("unauthorized", "logout_failed", &msg, 401),
        }
    }
}

endpoint! {
    APP.url("/auth/v1/health"),

    /// GET - Health check
    pub health_check <HTTP> {
        akari_json!({ status: "ok" })
    }
}

endpoint! {
    APP.url("/auth/v1/introspect"),

    /// POST - Validate token (for external apps calling sfx)
    /// Request: { token }
    /// Response: { active: true/false, user_ref, ... }
    pub introspect <HTTP> {
        if req.method() != POST {
            return method_not_allowed();
        }
        let json = req.json().await.unwrap_or(&Value::Null);
        let token = json.get("token").string();

        if token.is_empty() {
            return akari_json!({ active: false, reason: "missing_token" });
        }

        match LOCAL_AUTH.authenticate_user(&token).await {
            Ok(user) => {
                let uid = user.get("uid").as_u32().unwrap_or(0);
                let user_ref = UserRef::local(uid);
                akari_json!({
                    active: true,
                    user_ref: user_ref.to_string(),
                    uid: uid,
                    username: user.get("username").string(),
                    email: user.get("email").string()
                })
            }
            Err(_) => akari_json!({ active: false, reason: "token_invalid" }),
        }
    }
}
```

---

## 5. Update `src/user/fetch.rs`


Update endpoint paths at these locations:

```rust
// Line ~81: fetch_user_info()
// OLD: HttpStartLine::request_get("/users/me")
// NEW:
HttpStartLine::request_get("/auth/v1/me")

// Line ~154: get_new_token()
// OLD: HttpStartLine::request_get("/auth/refresh")
// NEW:
HttpStartLine::request_post("/auth/v1/refresh")

// Line ~165: Response check
// OLD: if json.get("success").boolean() {
// NEW:
if json.try_get("error").is_err() {

// Line ~197: auth_server_health()
// OLD: HttpStartLine::request_get("/health")
// NEW:
HttpStartLine::request_get("/auth/v1/health")

// Line ~246: disable_token()
// OLD: HttpStartLine::request_post("/auth/logout")
// NEW:
HttpStartLine::request_post("/auth/v1/logout")
```

---

## 6. Update `src/user/endpoints.rs`


```rust
// Line ~45: login()
// OLD: HttpStartLine::request_post("/auth/login")
// NEW:
HttpStartLine::request_post("/auth/v1/login")

// Line ~253: change_password()
// OLD: json_request("/users/me/password", ...)
// NEW:
json_request("/auth/v1/change-password", ...)
```

---

## 7. Update `src/admin/api.rs` (Optional)


Align admin error responses:

```rust
// Line ~11
// OLD: json_response(object!({ success: false, message: "Unauthorized" }))
// NEW:
json_response(object!({
    error: "forbidden",
    reason: "unauthorized",
    message: "Unauthorized"
})).status(StatusCode::FORBIDDEN)

// Line ~29
// OLD: json_response(object!({ success: false, message: e.to_string() }))
// NEW:
json_response(object!({
    error: "server_error",
    reason: "internal_error",
    message: e.to_string()
})).status(StatusCode::INTERNAL_SERVER_ERROR)

// Line ~33
// OLD: json_response(object!({ success: false, message: "Method not allowed" }))
// NEW:
json_response(object!({
    error: "method_error",
    reason: "method_not_allowed",
    message: "Method not allowed"
})).status(StatusCode::METHOD_NOT_ALLOWED)
```

---

## 8. Verification Checklist


### New Files

- [ ] Create `src/local_auth/response.rs` - Error response helpers
- [ ] Create `src/local_auth/user_ref.rs` - Unified user ID type (u128)
- [ ] Create `src/local_auth/proxy.rs` - External auth server proxy

### Module Updates

- [ ] Update `src/local_auth/mod.rs` - Export new modules
- [ ] Update `src/local_auth/endpoints.rs` - Multi-server login flow
- [ ] Update `src/user/fetch.rs` - New paths + response check
- [ ] Update `src/user/endpoints.rs` - New paths
- [ ] Optional Update `src/admin/api.rs` - Error format

### Testing

- [ ] Run `cargo check` - Verify compilation
- [ ] Test local login: `{ id: "user", password: "...", server: "" }`
- [ ] Test external login: `{ id: "user", password: "...", server: "https://..." }`
- [ ] Verify refresh/logout routes to correct server
- [ ] Verify user_ref format: `local@42` or `server@uuid`