Skip to content

Commit d8619ca

Browse files
committed
feat: ship CIMD auth for pages and local login
1 parent 50b2998 commit d8619ca

26 files changed

Lines changed: 2817 additions & 102 deletions

.env.local.example

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copy this file to `.env.local` for local website work.
2+
#
3+
# The client id is not secret. SeevoMap already defaults to the public CIMD
4+
# client id, so this file is only needed if you want to override it.
5+
#
6+
# If you override the client id, allow the actual local callback you use in the
7+
# Hugging Face OAuth app. Common examples:
8+
# - http://127.0.0.1:3456/oauth/callback/huggingface/
9+
# - http://localhost:3456/oauth/callback/huggingface/
10+
# - http://127.0.0.1:3457/oauth/callback/huggingface/
11+
# - http://localhost:3457/oauth/callback/huggingface/
12+
# - http://127.0.0.1:3458/oauth/callback/huggingface/
13+
# - http://localhost:3458/oauth/callback/huggingface/
14+
# - http://127.0.0.1:3459/oauth/callback/huggingface/
15+
# - http://localhost:3459/oauth/callback/huggingface/
16+
17+
VITE_SEEVOMAP_SPACE_URL=https://akiwatanabe-seevomap.hf.space
18+
VITE_SEEVOMAP_HF_CLIENT_ID=hf_your_oauth_client_id

.github/workflows/deploy-pages.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ concurrency:
1818
jobs:
1919
build:
2020
runs-on: ubuntu-latest
21+
env:
22+
VITE_SEEVOMAP_HF_CLIENT_ID: ${{ secrets.VITE_SEEVOMAP_HF_CLIENT_ID }}
2123
steps:
2224
- name: Checkout
2325
uses: actions/checkout@v4
@@ -39,6 +41,12 @@ jobs:
3941
- name: Build
4042
run: npm run build
4143

44+
- name: Verify Pages auth assets
45+
run: |
46+
test -f dist/.well-known/oauth-cimd
47+
test -f dist/.nojekyll
48+
test -f dist/oauth/callback/huggingface/index.html
49+
4250
- name: Upload artifact
4351
uses: actions/upload-pages-artifact@v3
4452
with:

.github/workflows/preview-pages.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ concurrency:
1818
jobs:
1919
build:
2020
runs-on: ubuntu-latest
21+
env:
22+
VITE_SEEVOMAP_HF_CLIENT_ID: ${{ secrets.VITE_SEEVOMAP_HF_CLIENT_ID }}
2123
steps:
2224
- name: Checkout preview branch
2325
uses: actions/checkout@v4
@@ -39,6 +41,9 @@ jobs:
3941
run: |
4042
npm ci
4143
npm run build
44+
test -f dist/.well-known/oauth-cimd
45+
test -f dist/.nojekyll
46+
test -f dist/oauth/callback/huggingface/index.html
4247
rm -rf ../preview-site
4348
mkdir -p ../preview-site/preview/docs-autoresearch-preview
4449
cp -R dist/. ../preview-site/preview/docs-autoresearch-preview/
@@ -49,6 +54,9 @@ jobs:
4954
cd ../main-site
5055
npm ci
5156
npm run build
57+
test -f dist/.well-known/oauth-cimd
58+
test -f dist/.nojekyll
59+
test -f dist/oauth/callback/huggingface/index.html
5260
cp -R dist/. ../preview-site/
5361
5462
- name: Add preview landing page

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,33 @@ Local preview convention:
3030
- Use `npm run dev:local` for frontend work.
3131
- The dev server is expected to run on port `3456` so changes can be checked
3232
immediately before any GitHub push.
33+
- For a production-like local check, run `npm run build` first and then serve
34+
the built site locally with `npm run preview -- --host 0.0.0.0 --port 3456`.
35+
- The local site can point at a different backend by setting
36+
`VITE_SEEVOMAP_SPACE_URL` before starting the dev server or preview server.
37+
- Website sign-in now defaults to the public SeevoMap CIMD client id at
38+
`https://internscience.github.io/SeevoMap-Home/.well-known/oauth-cimd`.
39+
- `VITE_SEEVOMAP_HF_CLIENT_ID` is now only an optional override if you want to
40+
point this deployment at a different Hugging Face OAuth app.
41+
42+
Local sign-in setup:
43+
44+
```bash
45+
cp .env.local.example .env.local
46+
```
47+
48+
- Local dev can reuse the default SeevoMap public client id.
49+
- If you keep the default, use one of the already-registered callbacks:
50+
- `http://127.0.0.1:3456/oauth/callback/huggingface/`
51+
- `http://localhost:3456/oauth/callback/huggingface/`
52+
- `http://127.0.0.1:3457/oauth/callback/huggingface/`
53+
- `http://localhost:3457/oauth/callback/huggingface/`
54+
- `http://127.0.0.1:3458/oauth/callback/huggingface/`
55+
- `http://localhost:3458/oauth/callback/huggingface/`
56+
- `http://127.0.0.1:3459/oauth/callback/huggingface/`
57+
- `http://localhost:3459/oauth/callback/huggingface/`
58+
- If you want to point the site at a different OAuth app, set
59+
`VITE_SEEVOMAP_HF_CLIENT_ID` in `.env.local`.
3360

3461
## Deploy
3562

@@ -69,6 +96,7 @@ Notes:
6996
```bash
7097
pip install seevomap
7198
seevomap search "optimize transformer pretraining" --top-k 10
99+
seevomap leaderboard --limit 10
72100
```
73101

74102
```python
@@ -77,6 +105,10 @@ svm = SeevoMap()
77105
results = svm.search("my task", top_k=5)
78106
```
79107

108+
The static website now includes a public `/leaderboard` route backed by the
109+
Space API, plus a Search-page flow that creates inject sessions and allows
110+
optional session-bound `helpful / not helpful` feedback.
111+
80112
## Tech Stack
81113

82114
React 19 + TypeScript + Vite + Tailwind CSS v4 + Plotly.js

public/.nojekyll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

public/.well-known/oauth-cimd

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"client_id": "https://internscience.github.io/SeevoMap-Home/.well-known/oauth-cimd",
3+
"client_name": "SeevoMap",
4+
"redirect_uris": [
5+
"https://internscience.github.io/SeevoMap-Home/oauth/callback/huggingface/",
6+
"https://internscience.github.io/preview/docs-autoresearch-preview/oauth/callback/huggingface/",
7+
"http://127.0.0.1:3456/oauth/callback/huggingface/",
8+
"http://localhost:3456/oauth/callback/huggingface/",
9+
"http://127.0.0.1:3457/oauth/callback/huggingface/",
10+
"http://localhost:3457/oauth/callback/huggingface/",
11+
"http://127.0.0.1:3458/oauth/callback/huggingface/",
12+
"http://localhost:3458/oauth/callback/huggingface/",
13+
"http://127.0.0.1:3459/oauth/callback/huggingface/",
14+
"http://localhost:3459/oauth/callback/huggingface/"
15+
],
16+
"token_endpoint_auth_method": "none",
17+
"client_uri": "https://internscience.github.io/SeevoMap-Home/"
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>SeevoMap Sign-In Callback</title>
7+
</head>
8+
<body>
9+
<p>Completing SeevoMap sign-in...</p>
10+
<script>
11+
(function () {
12+
var suffixPattern = /\/oauth\/callback\/huggingface(?:\/index\.html)?\/?$/;
13+
var pathname = window.location.pathname || "/";
14+
var basePath = pathname.replace(suffixPattern, "/");
15+
if (!basePath.endsWith("/")) {
16+
basePath += "/";
17+
}
18+
var target = window.location.origin + basePath + "#/auth/callback" + (window.location.search || "");
19+
window.location.replace(target);
20+
})();
21+
</script>
22+
</body>
23+
</html>

src/App.tsx

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { HashRouter, Navigate, Routes, Route } from "react-router-dom";
22
import { Suspense, lazy, useEffect, useState } from "react";
3+
import { AuthProvider } from "./auth/AuthContext";
34
import Navbar from "./components/Navbar";
45
import {
56
getInitialTheme,
@@ -10,11 +11,14 @@ import {
1011
const HomePage = lazy(() => import("./pages/HomePage"));
1112
const GraphPage = lazy(() => import("./pages/GraphPage"));
1213
const SearchPage = lazy(() => import("./pages/SearchPage"));
14+
const LeaderboardPage = lazy(() => import("./pages/LeaderboardPage"));
1315
const GuidePage = lazy(() => import("./pages/GuidePage"));
1416
const QuickstartPage = lazy(() => import("./pages/QuickstartPage"));
1517
const AutoresearchPage = lazy(() => import("./pages/AutoresearchPage"));
1618
const ParameterGolfPage = lazy(() => import("./pages/ParameterGolfPage"));
1719
const ReferencePage = lazy(() => import("./pages/ReferencePage"));
20+
const AuthCallbackPage = lazy(() => import("./pages/AuthCallbackPage"));
21+
const AccountPage = lazy(() => import("./pages/AccountPage"));
1822

1923
function LoadingFallback() {
2024
return (
@@ -45,31 +49,36 @@ export default function App() {
4549

4650
return (
4751
<HashRouter>
48-
<div className="app-shell min-h-screen">
49-
<Navbar
50-
theme={theme}
51-
onToggleTheme={() =>
52-
setTheme((current) => (current === "dark" ? "light" : "dark"))
53-
}
54-
/>
55-
<Suspense fallback={<LoadingFallback />}>
56-
<Routes>
57-
<Route path="/" element={<HomePage />} />
58-
<Route path="/graph" element={<GraphPage />} />
59-
<Route path="/search" element={<SearchPage />} />
60-
<Route path="/guide" element={<Navigate to="/docs" replace />} />
61-
<Route path="/docs" element={<GuidePage />} />
62-
<Route path="/docs/quickstart" element={<QuickstartPage />} />
63-
<Route path="/docs/integration" element={<AutoresearchPage />} />
64-
<Route path="/docs/examples" element={<ParameterGolfPage />} />
65-
<Route
66-
path="/docs/parameter-golf"
67-
element={<Navigate to="/docs/examples" replace />}
68-
/>
69-
<Route path="/docs/reference" element={<ReferencePage />} />
70-
</Routes>
71-
</Suspense>
72-
</div>
52+
<AuthProvider>
53+
<div className="app-shell min-h-screen">
54+
<Navbar
55+
theme={theme}
56+
onToggleTheme={() =>
57+
setTheme((current) => (current === "dark" ? "light" : "dark"))
58+
}
59+
/>
60+
<Suspense fallback={<LoadingFallback />}>
61+
<Routes>
62+
<Route path="/" element={<HomePage />} />
63+
<Route path="/graph" element={<GraphPage />} />
64+
<Route path="/search" element={<SearchPage />} />
65+
<Route path="/leaderboard" element={<LeaderboardPage />} />
66+
<Route path="/auth/callback" element={<AuthCallbackPage />} />
67+
<Route path="/account" element={<AccountPage />} />
68+
<Route path="/guide" element={<Navigate to="/docs" replace />} />
69+
<Route path="/docs" element={<GuidePage />} />
70+
<Route path="/docs/quickstart" element={<QuickstartPage />} />
71+
<Route path="/docs/integration" element={<AutoresearchPage />} />
72+
<Route path="/docs/examples" element={<ParameterGolfPage />} />
73+
<Route
74+
path="/docs/parameter-golf"
75+
element={<Navigate to="/docs/examples" replace />}
76+
/>
77+
<Route path="/docs/reference" element={<ReferencePage />} />
78+
</Routes>
79+
</Suspense>
80+
</div>
81+
</AuthProvider>
7382
</HashRouter>
7483
);
7584
}

0 commit comments

Comments
 (0)