Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add authentication examples #3135

Merged
merged 17 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/src/modules/components/ExamplesGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ function layouts() {
href: 'https://github.com/mui/mui-toolpad/tree/master/examples/charts',
source: 'https://github.com/mui/mui-toolpad/tree/master/examples/charts',
},
{
title: 'Authentication',
description: 'An app that shows how to set up authentication in Toolpad.',
src: '/static/toolpad/marketing/authentication.png',
href: 'https://github.com/mui/mui-toolpad/tree/master/examples/auth',
source: 'https://github.com/mui/mui-toolpad/tree/master/examples/auth',
},
{
title: 'Custom server',
description: 'An app that shows how to use Toolpad with a custom server.',
Expand Down
7 changes: 7 additions & 0 deletions examples/auth/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TOOLPAD_AUTH_SECRET=u43rXwzRvl4PDZhAqeciOW4KLfYIl2Aa9B5Wet+rJSI=

TOOLPAD_GITHUB_CLIENT_ID=
TOOLPAD_GITHUB_CLIENT_SECRET=

TOOLPAD_GOOGLE_CLIENT_ID=
TOOLPAD_GOOGLE_CLIENT_SECRET=
29 changes: 29 additions & 0 deletions examples/auth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Authentication

<p class="description">An app that shows how to set up authentication in Toolpad.</p>

Example showcasing how to set up authentication providers in a Toolpad app. [The docs](https://mui.com/toolpad/concepts/authentication/).

<a target="_blank">
<img src="https://mui.com/static/toolpad/marketing/authentication.png" alt="Authentication" style="aspect-ratio: 131/88;" width="524">
</a>

## How to run
mbrookes marked this conversation as resolved.
Show resolved Hide resolved

Use `create-toolpad-app` to bootstrap the example:

```bash
npx create-toolpad-app@latest --example auth
```

```bash
yarn create toolpad-app --example auth
```

```bash
pnpm create toolpad-app --example auth
```

or:

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/fork/github/mui/mui-toolpad/tree/master/examples/auth)
13 changes: 13 additions & 0 deletions examples/auth/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "auth",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "toolpad dev",
"build": "toolpad build",
"start": "toolpad start"
},
"dependencies": {
"@mui/toolpad": "0.1.49"
}
}
1 change: 1 addition & 0 deletions examples/auth/toolpad/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.generated
8 changes: 8 additions & 0 deletions examples/auth/toolpad/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: application
spec:
{
authentication:
{ providers: [{ provider: github }, { provider: google }], restrictedDomains: [] },
apedroferreira marked this conversation as resolved.
Show resolved Hide resolved
authorization: {},
}
14 changes: 14 additions & 0 deletions examples/auth/toolpad/pages/protectedpage/page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/mui/mui-toolpad/v0.1.48/docs/schemas/v1/definitions.json#properties/Page

apiVersion: v1
kind: page
spec:
alias:
- sP_2TKM
title: Protected Page
displayName: Protected Page
content:
- component: Text
name: text
props:
value: Only authenticated users can see me.
Loading