You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/strategy_switch_admin_backend.md
+7-6Lines changed: 7 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,8 @@ Goal: keep the open-source switch page public and read-only by default, while al
6
6
7
7
- Login method: GitHub OAuth 2.0.
8
8
- Public access: unsigned visitors can view the page, but cannot dispatch the workflow.
9
-
- Allowed switch users: `ALLOWED_GITHUB_LOGINS`, KV `auth_config.allowed_logins`, and all admins.
10
-
- Admin users: `STRATEGY_SWITCH_ADMIN_LOGINS` plus KV `auth_config.admin_logins`.
9
+
- Allowed switch users/orgs: `ALLOWED_GITHUB_LOGINS`, `ALLOWED_GITHUB_ORGS`, KV `auth_config.allowed_logins`, KV `auth_config.allowed_orgs`, and all admins.
10
+
- Admin users/orgs: `STRATEGY_SWITCH_ADMIN_LOGINS`, `STRATEGY_SWITCH_ADMIN_ORGS`, KV `auth_config.admin_logins`, and KV `auth_config.admin_orgs`.
11
11
- Account dropdowns: KV `account_options` first, falling back to `STRATEGY_SWITCH_ACCOUNT_OPTIONS_JSON`.
12
12
- Audit log: each admin save appends to KV `audit_log`, capped at 50 entries.
13
13
@@ -35,13 +35,14 @@ Without the KV binding, `/admin` is read-only and the Worker falls back to secre
35
35
36
36
- Not signed in: public read-only page.
37
37
- Signed in but not allowlisted: no switch and no admin page.
38
-
- Allowlisted: can dispatch switches.
39
-
- Admin-listed: can open `/admin` and manage allowed logins, admin logins, and account dropdown JSON.
40
-
-`STRATEGY_SWITCH_ADMIN_LOGINS`remains the break-glass admin source and is preserved on save.
38
+
- Allowlisted users or organization members: can dispatch switches.
39
+
- Admin users or admin organization members: can open `/admin` and manage allowed logins, allowed orgs, admin logins, admin orgs, and account dropdown JSON.
40
+
-`STRATEGY_SWITCH_ADMIN_LOGINS`and `STRATEGY_SWITCH_ADMIN_ORGS` remain break-glass admin sources and are preserved on save.
41
41
42
42
## Security Boundary
43
43
44
-
- The admin backend stores GitHub logins and account routing metadata only.
44
+
- The admin backend stores GitHub logins, GitHub organization names, and account routing metadata only.
45
+
- OAuth requests the `read:org` scope to verify membership in configured admin or allowlist organizations.
45
46
- Broker passwords, tokens, API keys, and cloud credentials stay out of this config.
46
47
- Admin writes use POST and same-origin checks.
47
48
- Sessions use HttpOnly, Secure, SameSite=Lax, and HMAC-signed cookies.
`ALLOWED_GITHUB_LOGINS`, `ALLOWED_GITHUB_ORGS`,`STRATEGY_SWITCH_ADMIN_LOGINS`, and `STRATEGY_SWITCH_ADMIN_ORGS`are comma-separated lists. Prefer the organization name for admin access:
30
32
31
33
```text
32
-
your-github-login
34
+
STRATEGY_SWITCH_ADMIN_ORGS=QuantStrategyLab
35
+
STRATEGY_SWITCH_ADMIN_LOGINS=your-github-login
33
36
```
34
37
35
38
The login entrypoint is `/login` on the Worker domain. The page header keeps a single Login Management entry. After sign-in, `/api/session` returns:
@@ -43,11 +46,11 @@ The login entrypoint is `/login` on the Worker domain. The page header keeps a s
43
46
}
44
47
```
45
48
46
-
`admin=true` means the login is listed in `STRATEGY_SWITCH_ADMIN_LOGINS`or the KV-backed admin list. Open `/admin` to manage allowed GitHub logins and account dropdown routes; non-admin users receive 403.
49
+
`admin=true` means the login or one of its GitHub organizations is listed in `STRATEGY_SWITCH_ADMIN_LOGINS`, `STRATEGY_SWITCH_ADMIN_ORGS`, or the KV-backed admin config. Open `/admin` to manage allowed GitHub logins, organizations, and account dropdown routes; non-admin users receive 403.
47
50
48
51
## Admin Management
49
52
50
-
GitHub OAuth 2.0 is the only login method. Keep your own GitHub login in `STRATEGY_SWITCH_ADMIN_LOGINS`; that secret is the break-glass admin source and cannot be removed from the UI.
53
+
GitHub OAuth 2.0 is the only login method. The Worker requests the `read:org` scope to verify GitHub organization membership. Put `QuantStrategyLab` in `STRATEGY_SWITCH_ADMIN_ORGS`, and keep your own GitHub login in `STRATEGY_SWITCH_ADMIN_LOGINS` as a break-glass admin.
51
54
52
55
For editable admin settings, bind a Cloudflare KV namespace named `STRATEGY_SWITCH_CONFIG`. The Worker uses these KV keys:
53
56
@@ -57,7 +60,7 @@ account_options
57
60
audit_log
58
61
```
59
62
60
-
Without the KV binding, `/admin` is read-only and the Worker falls back to `ALLOWED_GITHUB_LOGINS`, `STRATEGY_SWITCH_ADMIN_LOGINS`, and `STRATEGY_SWITCH_ACCOUNT_OPTIONS_JSON`.
63
+
Without the KV binding, `/admin` is read-only and the Worker falls back to `ALLOWED_GITHUB_LOGINS`, `ALLOWED_GITHUB_ORGS`, `STRATEGY_SWITCH_ADMIN_LOGINS`, `STRATEGY_SWITCH_ADMIN_ORGS`, and `STRATEGY_SWITCH_ACCOUNT_OPTIONS_JSON`.
61
64
62
65
## Page Asset
63
66
@@ -130,7 +133,9 @@ wrangler secret put GITHUB_CLIENT_SECRET
130
133
wrangler secret put SESSION_SECRET
131
134
wrangler secret put RUNTIME_SETTINGS_DISPATCH_TOKEN
132
135
wrangler secret put ALLOWED_GITHUB_LOGINS
136
+
wrangler secret put ALLOWED_GITHUB_ORGS
133
137
wrangler secret put STRATEGY_SWITCH_ADMIN_LOGINS
138
+
wrangler secret put STRATEGY_SWITCH_ADMIN_ORGS
134
139
wrangler secret put STRATEGY_SWITCH_ACCOUNT_OPTIONS_JSON < /tmp/strategy-switch-accounts.json
0 commit comments