Skip to content

Commit 75e5dc3

Browse files
authored
Merge pull request #1 from SecureAuthCorp/feature/react-init
React login-pkce sample + extraction tooling
2 parents 4c4c2bb + f9208aa commit 75e5dc3

30 files changed

Lines changed: 5148 additions & 2 deletions

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# All files require review from the CIAM team
2+
* @SecureAuthCorp/team-eng-ciam-ui-write
3+
4+
# GitHub Actions and CI config
5+
.github/ @SecureAuthCorp/devops

.github/dependabot.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/samples/react/login-pkce"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 5
8+
labels:
9+
- "dependencies"
10+
commit-message:
11+
prefix: "deps"
12+
13+
- package-ecosystem: "npm"
14+
directory: "/scripts"
15+
schedule:
16+
interval: "weekly"
17+
open-pull-requests-limit: 3
18+
labels:
19+
- "dependencies"
20+
commit-message:
21+
prefix: "deps"
22+
23+
- package-ecosystem: "github-actions"
24+
directory: "/"
25+
schedule:
26+
interval: "weekly"
27+
labels:
28+
- "dependencies"

.github/workflows/extract.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Extract Snippets
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
paths:
8+
- "samples/**"
9+
- "scripts/**"
10+
- "placeholder-map.yaml"
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
validate:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: "22"
25+
26+
- name: Enable Corepack
27+
run: corepack enable
28+
29+
- name: Install dependencies
30+
run: yarn install --immutable
31+
32+
- name: Aggregate manifests
33+
working-directory: scripts
34+
run: yarn aggregate
35+
36+
- name: Extract snippets
37+
working-directory: scripts
38+
run: yarn extract
39+
40+
- name: Validate structure
41+
working-directory: scripts
42+
run: yarn validate
43+
44+
- name: Verify no drift (PR only)
45+
if: github.event_name == 'pull_request'
46+
run: |
47+
git diff --exit-code snippets.json snippet-manifest.yaml || \
48+
(echo "::error::Extracted artifacts are out of date. Run 'cd scripts && yarn all' and commit the results." && exit 1)
49+
50+
commit:
51+
needs: validate
52+
if: github.event_name == 'push'
53+
runs-on: ubuntu-latest
54+
permissions:
55+
contents: write
56+
steps:
57+
- uses: actions/checkout@v4
58+
59+
- uses: actions/setup-node@v4
60+
with:
61+
node-version: "22"
62+
63+
- name: Enable Corepack
64+
run: corepack enable
65+
66+
- name: Install dependencies
67+
run: yarn install --immutable
68+
69+
- name: Aggregate manifests
70+
working-directory: scripts
71+
run: yarn aggregate
72+
73+
- name: Extract snippets
74+
working-directory: scripts
75+
run: yarn extract
76+
77+
- name: Check for changes
78+
id: diff
79+
run: |
80+
git diff --quiet snippets.json snippet-manifest.yaml || echo "changed=true" >> "$GITHUB_OUTPUT"
81+
82+
- name: Commit updated artifacts
83+
if: steps.diff.outputs.changed == 'true'
84+
run: |
85+
git config user.name "github-actions[bot]"
86+
git config user.email "github-actions[bot]@users.noreply.github.com"
87+
git add snippets.json snippet-manifest.yaml
88+
git commit -m "chore: update extracted snippets and manifest"
89+
git push
90+
91+
# - name: Notify ciam-core of snippet changes
92+
# if: steps.diff.outputs.changed == 'true'
93+
# run: |
94+
# gh api repos/SecureAuthCorp/ciam-core/dispatches \
95+
# -f event_type=quickstart-snippets-updated \
96+
# -f 'client_payload[sha]=${{ github.sha }}'
97+
# env:
98+
# GH_TOKEN: ${{ secrets.CIAM_CORE_DISPATCH_TOKEN }}

.github/workflows/test-js.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Test JS Frameworks
2+
3+
on:
4+
push:
5+
paths:
6+
- "samples/react/**"
7+
pull_request:
8+
paths:
9+
- "samples/react/**"
10+
schedule:
11+
- cron: "0 8 * * 1"
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
find-projects:
19+
runs-on: ubuntu-latest
20+
outputs:
21+
matrix: ${{ steps.find.outputs.matrix }}
22+
steps:
23+
- uses: actions/checkout@v4
24+
- id: find
25+
run: |
26+
DIRS=$(find samples -name "package.json" -not -path "*/node_modules/*" -exec dirname {} \; 2>/dev/null | sort | jq -R -s -c 'split("\n") | map(select(. != ""))')
27+
echo "matrix=$DIRS" >> "$GITHUB_OUTPUT"
28+
29+
test:
30+
needs: find-projects
31+
if: ${{ needs.find-projects.outputs.matrix != '[]' }}
32+
runs-on: ubuntu-latest
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
project: ${{ fromJson(needs.find-projects.outputs.matrix) }}
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: actions/setup-node@v4
40+
with:
41+
node-version: "22"
42+
- name: Enable Corepack
43+
run: corepack enable
44+
- name: Install dependencies
45+
run: yarn install --immutable
46+
- name: Check formatting
47+
working-directory: ${{ matrix.project }}
48+
run: |
49+
if grep -q '"format:check"' package.json; then
50+
yarn format:check
51+
fi
52+
- name: Build
53+
working-directory: ${{ matrix.project }}
54+
run: yarn build
55+
- name: Test
56+
working-directory: ${{ matrix.project }}
57+
run: yarn test
58+
if: ${{ hashFiles(format('{0}/vitest.config.ts', matrix.project)) != '' }}

.yarn/releases/yarn-4.13.0.cjs

Lines changed: 940 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
nodeLinker: node-modules
2+
3+
npmRegistryServer: "https://registry.npmjs.org"
4+
5+
yarnPath: .yarn/releases/yarn-4.13.0.cjs

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
# ciam-quickstart-samples
1+
# CIAM Quickstart Samples
22

3+
Framework-specific sample apps demonstrating SecureAuth integration. Code is extracted from these samples and displayed in the SecureAuth admin dashboard's Quickstart tab.
34

4-
Repository for framework-specific integration sample apps
5+
## Structure
6+
7+
```
8+
samples/ # One folder per framework
9+
react/ # React sample apps
10+
login-pkce/ # Login with Auth Code + PKCE
11+
scripts/ # Extraction and validation tools
12+
```
13+
14+
## Adding a new sample
15+
16+
1. Create `samples/<framework>/<flow>/` with a minimal working app
17+
2. Add `@snippet:stepN:start/end` tags and `@description` comments in source files
18+
3. Add a `manifest.yaml` in `samples/<framework>/`
19+
4. Run `cd scripts && yarn all` to validate
20+
5. Open a PR — CI will test the app and validate extraction
21+
22+
## Contributing
23+
24+
This repo is maintained by the SecureAuth CIAM team. External contributions are welcome via pull request — all PRs require team review.

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"private": true,
3+
"packageManager": "yarn@4.13.0",
4+
"workspaces": [
5+
"samples/react/*",
6+
"scripts"
7+
]
8+
}

placeholder-map.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Maps env var patterns to placeholder tokens per language.
2+
# The extraction script uses these to replace real env var references
3+
# with generic {{PLACEHOLDER}} tokens in extracted snippets.
4+
5+
js:
6+
- pattern: "import.meta.env.VITE_ISSUER_URL"
7+
placeholder: "{{ISSUER_URL}}"
8+
- pattern: "import.meta.env.VITE_CLIENT_ID"
9+
placeholder: "{{CLIENT_ID}}"
10+
- pattern: "import.meta.env.VITE_REDIRECT_URI"
11+
placeholder: "{{REDIRECT_URI}}"
12+
- pattern: "import.meta.env.VITE_SCOPES"
13+
placeholder: "{{SCOPES}}"
14+
- pattern: "import.meta.env.VITE_POST_LOGOUT_URI"
15+
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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +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

0 commit comments

Comments
 (0)