-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor ui and publish examples
- Loading branch information
1 parent
89c5269
commit c289400
Showing
9 changed files
with
119 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- prepare-examples-deployment | ||
|
||
env: | ||
OIDC_ISSUER: "https://testid.cerberauth.com" | ||
|
||
jobs: | ||
deploy-nodejs-cloudflare: | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
working-directory: ${{ matrix.workingDirectory }} | ||
|
||
strategy: | ||
matrix: | ||
include: | ||
- workingDirectory: ./examples/react-spa | ||
projectName: cerberauth-react-spa-oidc | ||
directory: ./dist | ||
- workingDirectory: ./examples/angular-spa | ||
projectName: cerberauth-angular-spa-oidc | ||
directory: ./dist/angular-spa/browser | ||
|
||
permissions: | ||
contents: read | ||
deployments: write | ||
|
||
steps: | ||
- name: Checkout 🛎 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup node env 🏗 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'npm' | ||
cache-dependency-path: '${{ matrix.workingDirectory }}/package-lock.json' | ||
|
||
- name: Install dependencies 👨🏻💻 | ||
run: npm ci | ||
|
||
- name: Run build | ||
run: npm run build | ||
|
||
- name: Publish | ||
uses: cloudflare/pages-action@1 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
projectName: ${{ matrix.projectName }} | ||
directory: ${{ matrix.directory }} | ||
gitHubToken: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
VITE_OIDC_ISSUER="" | ||
VITE_OIDC_CLIENT_ID="" | ||
VITE_OIDC_ISSUER="https://testid.cerberauth.com" | ||
VITE_OIDC_CLIENT_ID="c6c0c0ec-09e0-448e-a856-3e596c3bdd9d" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> { | ||
children: React.ReactNode | ||
} | ||
|
||
export const Button: React.FC<ButtonProps> = ({ children, ...props }) => { | ||
return ( | ||
<button | ||
className="inline-flex justify-center rounded-lg text-sm font-semibold py-3 px-4 bg-slate-900 text-white hover:bg-slate-700" | ||
{...props} | ||
> | ||
{children} | ||
</button> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
import { Button } from '../components/Button' | ||
import { useAuth } from '../lib/auth/useAuth' | ||
|
||
export function Home() { | ||
const { login, logout, isAuthenticated } = useAuth() | ||
|
||
return ( | ||
<div> | ||
<h1>Welcome to the home page</h1> | ||
<div className="bg-slate-100 min-h-screen"> | ||
<main role="main" className="flex flex-col items-center justify-center h-5/6 space-y-8 text-center px-4 py-16 lg:pt-32 md:pt-16 sm:pt-8"> | ||
<h1 className="mt-4 text-2xl font-extrabold tracking-tight text-slate-900 sm:text-5xl xl:max-w-[43.5rem]"> | ||
React SPA Example using OpenID Connect | ||
</h1> | ||
<p className="mt-4 max-w-lg text-lg text-slate-700"> | ||
This example demonstrates how to authenticate users in a React Single Page Application (SPA) using OpenID Connect Protocol. | ||
</p> | ||
{isAuthenticated ? ( | ||
<Button onClick={() => logout()}> | ||
Logout | ||
</Button> | ||
) : ( | ||
<Button onClick={() => login()}> | ||
Login with TestID | ||
</Button> | ||
)} | ||
<p className="mt-4 max-w-lg text-slate-700"> | ||
If you want to checkout out how to implement OpenID Connect in your React SPA, take a look at the <a className="text-indigo-600" href="https://github.com/cerberauth/openid-connect-examples/tree/main/examples/react-spa">source code</a>. | ||
</p> | ||
</main> | ||
|
||
<footer className="text-center py-4"> | ||
<p className="text-sm text-gray-500"> | ||
Proudly part of <a className="text-indigo-600" href="https://www.cerberauth.com">CerberAuth</a> community. | ||
</p> | ||
</footer> | ||
</div> | ||
) | ||
} |