Skip to content

Commit 2a9524c

Browse files
authored
Merge pull request #13 from SecureAuthCorp/feat/AUT-13537-quickstart-improvements
UI quickstart improvements
2 parents 3763038 + 8d9b79d commit 2a9524c

11 files changed

Lines changed: 66 additions & 42 deletions

File tree

.github/workflows/extract.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
validate:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v6
2121

22-
- uses: actions/setup-node@v4
22+
- uses: actions/setup-node@v6
2323
with:
2424
node-version: "22"
2525

@@ -55,9 +55,9 @@ jobs:
5555
permissions:
5656
contents: write
5757
steps:
58-
- uses: actions/checkout@v4
58+
- uses: actions/checkout@v6
5959

60-
- uses: actions/setup-node@v4
60+
- uses: actions/setup-node@v6
6161
with:
6262
node-version: "22"
6363

placeholder-map.yaml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,13 @@
33
# with generic {{PLACEHOLDER}} tokens in extracted snippets.
44

55
js:
6-
- pattern: "import.meta.env.VITE_ISSUER_URL"
6+
- pattern: "import.meta.env.ISSUER_URL"
77
placeholder: "{{ISSUER_URL}}"
8-
- pattern: "import.meta.env.VITE_CLIENT_ID"
8+
- pattern: "import.meta.env.CLIENT_ID"
99
placeholder: "{{CLIENT_ID}}"
10-
- pattern: "import.meta.env.VITE_REDIRECT_URI"
10+
- pattern: "import.meta.env.REDIRECT_URI"
1111
placeholder: "{{REDIRECT_URI}}"
12-
- pattern: "import.meta.env.VITE_SCOPES"
12+
- pattern: "import.meta.env.SCOPES"
1313
placeholder: "{{SCOPES}}"
14-
- pattern: "import.meta.env.VITE_POST_LOGOUT_URI"
14+
- pattern: "import.meta.env.POST_LOGOUT_URI"
1515
placeholder: "{{POST_LOGOUT_URI}}"
16-
- pattern: "process.env.REACT_APP_ISSUER_URL"
17-
placeholder: "{{ISSUER_URL}}"
18-
- pattern: "process.env.REACT_APP_CLIENT_ID"
19-
placeholder: "{{CLIENT_ID}}"
20-
- pattern: "process.env.REACT_APP_REDIRECT_URI"
21-
placeholder: "{{REDIRECT_URI}}"
22-
- pattern: "process.env.SA_ISSUER_URL"
23-
placeholder: "{{ISSUER_URL}}"
24-
- pattern: "process.env.SA_CLIENT_ID"
25-
placeholder: "{{CLIENT_ID}}"
26-
- pattern: "process.env.SA_CLIENT_SECRET"
27-
placeholder: "{{CLIENT_SECRET}}"
28-
- pattern: "process.env.SA_REDIRECT_URI"
29-
placeholder: "{{REDIRECT_URI}}"
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
VITE_ISSUER_URL=https://your-tenant.us.secureauth.com/your-workspace
2-
VITE_CLIENT_ID=your-client-id
3-
VITE_REDIRECT_URI=http://localhost:3000/callback
4-
VITE_POST_LOGOUT_URI=http://localhost:3000
5-
VITE_SCOPES=openid profile email
1+
ISSUER_URL=https://your-tenant.us.secureauth.com/your-workspace
2+
CLIENT_ID=your-client-id
3+
REDIRECT_URI=http://localhost:3000/callback
4+
POST_LOGOUT_URI=http://localhost:3000
5+
SCOPES=openid profile email

samples/react/login-pkce/src/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { AuthProvider, useAuth } from "react-oidc-context";
66
// @snippet:step2:start
77
// @description Configure the OIDC client with your SecureAuth app settings
88
const oidcConfig = {
9-
authority: import.meta.env.VITE_ISSUER_URL,
10-
client_id: import.meta.env.VITE_CLIENT_ID,
11-
redirect_uri: import.meta.env.VITE_REDIRECT_URI,
12-
post_logout_redirect_uri: import.meta.env.VITE_POST_LOGOUT_URI,
13-
scope: import.meta.env.VITE_SCOPES,
9+
authority: import.meta.env.ISSUER_URL,
10+
client_id: import.meta.env.CLIENT_ID,
11+
redirect_uri: import.meta.env.REDIRECT_URI,
12+
post_logout_redirect_uri: import.meta.env.POST_LOGOUT_URI,
13+
scope: import.meta.env.SCOPES,
1414
};
1515
// @snippet:step2:end
1616

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
11
import react from "@vitejs/plugin-react";
2-
import { defineConfig } from "vite";
2+
import { defineConfig, loadEnv } from "vite";
33

4-
export default defineConfig({
5-
plugins: [react()],
6-
server: {
7-
port: 3000,
8-
},
4+
const exposedEnvVars = [
5+
"ISSUER_URL",
6+
"CLIENT_ID",
7+
"REDIRECT_URI",
8+
"POST_LOGOUT_URI",
9+
"SCOPES",
10+
];
11+
12+
export default defineConfig(({ mode, command }) => {
13+
const env = loadEnv(mode, process.cwd(), "");
14+
if (command === "serve") {
15+
const missing = exposedEnvVars.filter((key) => !env[key]);
16+
if (missing.length > 0) {
17+
throw new Error(
18+
`Missing required env vars: ${missing.join(", ")}. Copy .env.example to .env and fill in the values.`,
19+
);
20+
}
21+
}
22+
return {
23+
plugins: [react()],
24+
define: Object.fromEntries(
25+
exposedEnvVars.map((key) => [
26+
`import.meta.env.${key}`,
27+
JSON.stringify(env[key] ?? ""),
28+
]),
29+
),
30+
server: {
31+
port: 3000,
32+
},
33+
};
934
});

samples/react/manifest.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ scenarios:
1111
grant: "Auth Code + PKCE"
1212
description: "Redirect users to SecureAuth for login. PKCE protects against code interception."
1313
callout: "Uses PKCE — no client secret needed. The browser generates a code_verifier/code_challenge pair."
14+
run_command: "yarn install && yarn dev"
1415
config_rows:
1516
- label: "Client ID"
1617
value: "{{CLIENT_ID}}"

scripts/aggregate-manifests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface ScenarioManifest {
1616
description: string;
1717
callout?: string;
1818
extends?: string;
19+
run_command?: string;
1920
config_rows: ConfigRow[];
2021
}
2122

scripts/extract-snippets.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ interface FrameworkSnippet {
2929
lib_version: string;
3030
install: string;
3131
repo_path: string;
32+
run_command?: string;
33+
}
34+
35+
interface ScenarioMeta {
36+
run_command?: string;
37+
[key: string]: unknown;
3238
}
3339

3440
interface FrameworkManifest {
@@ -37,7 +43,7 @@ interface FrameworkManifest {
3743
lang: string;
3844
lib: string;
3945
docs_url: string;
40-
scenarios: Record<string, unknown>;
46+
scenarios: Record<string, ScenarioMeta>;
4147
}
4248

4349
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
@@ -200,13 +206,15 @@ async function main() {
200206
snippets[scenarioId] = {};
201207
}
202208

209+
const runCommand = manifest.scenarios[scenarioId]?.run_command;
203210
snippets[scenarioId][fw] = {
204211
steps: allSteps,
205212
framework: fw,
206213
lib: manifest.lib,
207214
lib_version: getLibVersion(scenarioDir, frameworkDir),
208215
install: getInstallCommand(scenarioDir),
209216
repo_path: `samples/${path.relative(SAMPLES, scenarioDir)}`,
217+
...(runCommand ? { run_command: runCommand } : {}),
210218
};
211219
}
212220
}

scripts/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"esModuleInterop": true,
88
"skipLibCheck": true,
99
"outDir": "dist",
10-
"resolveJsonModule": true
10+
"resolveJsonModule": true,
11+
"types": ["node"]
1112
},
1213
"include": ["*.ts"]
1314
}

snippet-manifest.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ scenarios:
1212
grant: Auth Code + PKCE
1313
description: Redirect users to SecureAuth for login. PKCE protects against code interception.
1414
callout: Uses PKCE — no client secret needed. The browser generates a code_verifier/code_challenge pair.
15+
run_command: yarn install && yarn dev
1516
config_rows:
1617
- label: Client ID
1718
value: "{{CLIENT_ID}}"

0 commit comments

Comments
 (0)