Subramanya97 commited on
Commit
c760736
Β·
1 Parent(s): 2e57ac2

Deploy from markdownfs@6a91df8

Browse files
src/db.rs CHANGED
@@ -484,7 +484,7 @@ impl MarkdownDb {
484
  // ─── Auth helpers ───
485
 
486
  pub async fn login(&self, username: &str) -> Result<Session, VfsError> {
487
- let mut guard = self.inner.write().await;
488
  let uid = guard
489
  .registry_lookup_uid(username)
490
  .ok_or_else(|| VfsError::AuthError {
 
484
  // ─── Auth helpers ───
485
 
486
  pub async fn login(&self, username: &str) -> Result<Session, VfsError> {
487
+ let guard = self.inner.read().await;
488
  let uid = guard
489
  .registry_lookup_uid(username)
490
  .ok_or_else(|| VfsError::AuthError {
src/server/assets/app.js CHANGED
@@ -140,7 +140,7 @@ async function refreshWhoAmI() {
140
  const res = await api("GET", "/auth/whoami");
141
  const w = await res.json();
142
  state.user = w;
143
- state.isAdmin = w.is_root || (w.groups || []).includes(0);
144
  $("user-info").hidden = false;
145
  let label = w.authenticated ? w.username : `${w.username} (anon)`;
146
  if (w.on_behalf_of) {
 
140
  const res = await api("GET", "/auth/whoami");
141
  const w = await res.json();
142
  state.user = w;
143
+ state.isAdmin = w.is_root || w.is_wheel === true;
144
  $("user-info").hidden = false;
145
  let label = w.authenticated ? w.username : `${w.username} (anon)`;
146
  if (w.on_behalf_of) {
src/server/routes_auth.rs CHANGED
@@ -33,6 +33,7 @@ pub struct WhoAmI {
33
  pub gid: u32,
34
  pub groups: Vec<u32>,
35
  pub is_root: bool,
 
36
  pub authenticated: bool,
37
  pub on_behalf_of: Option<String>,
38
  }
@@ -99,12 +100,15 @@ async fn whoami(State(state): State<AppState>, headers: HeaderMap) -> impl IntoR
99
  .unwrap_or("");
100
  let authenticated = auth_header.starts_with("Bearer ") || auth_header.starts_with("User ");
101
 
 
 
102
  Json(WhoAmI {
103
  username: session.username.clone(),
104
  uid: session.uid,
105
  gid: session.gid,
106
  groups: session.groups.clone(),
107
  is_root: session.is_effectively_root(),
 
108
  authenticated,
109
  on_behalf_of: session.delegate.as_ref().map(|d| d.username.clone()),
110
  })
 
33
  pub gid: u32,
34
  pub groups: Vec<u32>,
35
  pub is_root: bool,
36
+ pub is_wheel: bool,
37
  pub authenticated: bool,
38
  pub on_behalf_of: Option<String>,
39
  }
 
100
  .unwrap_or("");
101
  let authenticated = auth_header.starts_with("Bearer ") || auth_header.starts_with("User ");
102
 
103
+ let (is_wheel, _) = state.db.principal_flags(session.uid).await;
104
+
105
  Json(WhoAmI {
106
  username: session.username.clone(),
107
  uid: session.uid,
108
  gid: session.gid,
109
  groups: session.groups.clone(),
110
  is_root: session.is_effectively_root(),
111
+ is_wheel,
112
  authenticated,
113
  on_behalf_of: session.delegate.as_ref().map(|d| d.username.clone()),
114
  })