-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Victor Shneer
committed
Feb 16, 2023
1 parent
cadbee0
commit 7b49a87
Showing
30 changed files
with
1,150 additions
and
0 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 |
---|---|---|
|
@@ -38,8 +38,14 @@ nb-configuration.xml | |
.env | ||
env.sh | ||
|
||
# Daml | ||
*.daml/ | ||
|
||
# Logs | ||
*.log | ||
log/ | ||
|
||
# UI | ||
ui/build | ||
ui/daml.js | ||
ui/node_modules |
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,89 @@ | ||
# Sample 01 - Logging In and Gated Content | ||
|
||
This sample demonstrates: | ||
|
||
- Logging in to Auth0 using Redirect Mode | ||
- Accessing profile information that has been provided in the ID token | ||
- Gated content. The `/profile` route is not accessible without having first logged in | ||
|
||
## Project setup | ||
|
||
Use `yarn` or `npm` to install the project dependencies: | ||
|
||
```bash | ||
# Using npm.. | ||
npx npm-force-resolutions | ||
npm install | ||
|
||
# Using yarn.. | ||
yarn install | ||
``` | ||
|
||
### Configuration | ||
|
||
The project needs to be configured with your Auth0 domain and client ID in order for the authentication flow to work. | ||
|
||
To do this, first copy `src/auth_config.json.example` into a new file in the same folder called `src/auth_config.json`, and replace the values with your own Auth0 application credentials: | ||
|
||
```json | ||
{ | ||
"domain": "{YOUR AUTH0 DOMAIN}", | ||
"clientId": "{YOUR AUTH0 CLIENT ID}" | ||
} | ||
``` | ||
|
||
### Compiles and hot-reloads for development | ||
|
||
```bash | ||
npm run start | ||
``` | ||
|
||
## Deployment | ||
|
||
### Compiles and minifies for production | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
### Docker build | ||
|
||
To build and run the Docker image, run `exec.sh`, or `exec.ps1` on Windows. | ||
|
||
### Run your tests | ||
|
||
```bash | ||
npm run test | ||
``` | ||
|
||
## Frequently Asked Questions | ||
|
||
We are compiling a list of questions and answers regarding the new JavaScript SDK - if you're having issues running the sample applications, [check the FAQ](https://github.com/auth0/auth0-spa-js/blob/master/FAQ.md)! | ||
|
||
# What is Auth0? | ||
|
||
Auth0 helps you to: | ||
|
||
- Add authentication with [multiple authentication sources](https://docs.auth0.com/identityproviders), either social like **Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, among others**, or enterprise identity systems like **Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider**. | ||
- Add authentication through more traditional **[username/password databases](https://docs.auth0.com/mysql-connection-tutorial)**. | ||
- Add support for **[linking different user accounts](https://docs.auth0.com/link-accounts)** with the same user. | ||
- Support for generating signed [Json Web Tokens](https://docs.auth0.com/jwt) to call your APIs and **flow the user identity** securely. | ||
- Analytics of how, when and where users are logging in. | ||
- Pull data from other sources and add it to the user profile, through [JavaScript rules](https://docs.auth0.com/rules). | ||
|
||
## Create a Free Auth0 Account | ||
|
||
1. Go to [Auth0](https://auth0.com/signup) and click Sign Up. | ||
2. Use Google, GitHub or Microsoft Account to login. | ||
|
||
## Issue Reporting | ||
|
||
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues. | ||
|
||
## Author | ||
|
||
[Auth0](https://auth0.com) | ||
|
||
## License | ||
|
||
This project is licensed under the MIT license. See the [LICENSE](../LICENSE) file for more info. |
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,47 @@ | ||
{ | ||
"name": "auth0-react-01-login", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start", | ||
"build": "SKIP_PREFLIGHT_CHECK=true react-scripts build", | ||
"test": "SKIP_PREFLIGHT_CHECK=true react-scripts test", | ||
"eject": "SKIP_PREFLIGHT_CHECK=true react-scripts eject" | ||
}, | ||
"proxy": "http://localhost:4000", | ||
"dependencies": { | ||
"@auth0/auth0-spa-js": "^1.10.0", | ||
"@fortawesome/fontawesome-svg-core": "^1.2.29", | ||
"@fortawesome/free-solid-svg-icons": "^5.13.1", | ||
"@fortawesome/react-fontawesome": "^0.1.11", | ||
"express": "^4.16.4", | ||
"highlight.js": "^10.1.1", | ||
"morgan": "^1.10.0", | ||
"react": "^16.13.1", | ||
"react-dom": "^16.13.1", | ||
"react-router-dom": "^5.2.0", | ||
"react-scripts": "3.4.1", | ||
"reactstrap": "^8.4.1" | ||
}, | ||
"devDependencies": {}, | ||
"resolutions": { | ||
"webpack": "4.43.0", | ||
"webpack-dev-server": "3.11.0", | ||
"chokidar": "^3.4.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": "react-app" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,54 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" class="h-100"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.png" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, initial-scale=1, shrink-to-fit=no" | ||
/> | ||
<meta name="theme-color" content="#000000" /> | ||
<!-- | ||
manifest.json provides metadata used when your web app is installed on a | ||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
|
||
<link | ||
rel="stylesheet" | ||
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" | ||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" | ||
crossorigin="anonymous" | ||
/> | ||
|
||
<link | ||
rel="stylesheet" | ||
href="https://cdn.auth0.com/js/auth0-samples-theme/1.0/css/auth0-theme.min.css" | ||
/> | ||
|
||
<title>Login</title> | ||
</head> | ||
<body class="h-100"> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root" class="h-100"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
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,15 @@ | ||
{ | ||
"short_name": "React App", | ||
"name": "Create React App Sample", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
} | ||
], | ||
"start_url": ".", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
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,16 @@ | ||
/* eslint-disable no-console */ | ||
const express = require("express"); | ||
const { join } = require("path"); | ||
const morgan = require("morgan"); | ||
const app = express(); | ||
|
||
const port = process.env.SERVER_PORT || 3000; | ||
|
||
app.use(morgan("dev")); | ||
app.use(express.static(join(__dirname, "build"))); | ||
|
||
app.use((_, res) => { | ||
res.sendFile(join(__dirname, "build", "index.html")); | ||
}); | ||
|
||
app.listen(port, () => console.log(`Listening on port ${port}`)); |
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,31 @@ | ||
.next-steps .fa-link { | ||
margin-right: 5px; | ||
} | ||
|
||
/* Fix for use only flexbox in content area */ | ||
.next-steps .row { | ||
margin-bottom: 0; | ||
} | ||
|
||
.next-steps .col-md-5 { | ||
margin-bottom: 3rem; | ||
} | ||
|
||
@media (max-width: 768px) { | ||
.next-steps .col-md-5 { | ||
margin-bottom: 0; | ||
} | ||
} | ||
|
||
.spinner { | ||
position: absolute; | ||
display: flex; | ||
justify-content: center; | ||
height: 100vh; | ||
width: 100vw; | ||
background-color: white; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
} |
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,46 @@ | ||
import React from "react"; | ||
import { Router, Route, Switch } from "react-router-dom"; | ||
import { Container } from "reactstrap"; | ||
|
||
import PrivateRoute from "./components/PrivateRoute"; | ||
import Loading from "./components/Loading"; | ||
import NavBar from "./components/NavBar"; | ||
import Footer from "./components/Footer"; | ||
import Home from "./views/Home"; | ||
import Ledger from "./views/Ledger"; | ||
import Profile from "./views/Profile"; | ||
import { useAuth0 } from "./react-auth0-spa"; | ||
import history from "./utils/history"; | ||
|
||
// styles | ||
import "./App.css"; | ||
|
||
// fontawesome | ||
import initFontAwesome from "./utils/initFontAwesome"; | ||
initFontAwesome(); | ||
|
||
const App = () => { | ||
const { loading } = useAuth0(); | ||
|
||
if (loading) { | ||
return <Loading />; | ||
} | ||
|
||
return ( | ||
<Router history={history}> | ||
<div id="app" className="d-flex flex-column h-100"> | ||
<NavBar /> | ||
<Container className="flex-grow-1 mt-5"> | ||
<Switch> | ||
<Route path="/" exact component={Home} /> | ||
<PrivateRoute path="/ledger" component={Ledger} /> | ||
<PrivateRoute path="/profile" component={Profile} /> | ||
</Switch> | ||
</Container> | ||
<Footer /> | ||
</div> | ||
</Router> | ||
); | ||
}; | ||
|
||
export default App; |
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,9 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import App from './App'; | ||
|
||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<App />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
{ | ||
"domain": "dev-uswtyz53.eu.auth0.com", | ||
"clientId": "xNTS7sPWLpNoWzzyiDTuBuTklL7v3ScJ", | ||
"audience": "https://daml.com/ledger-api" | ||
} |
Oops, something went wrong.