Skip to content

Commit bccf309

Browse files
Add a sample that uses standalone components (auth0-samples#359)
1 parent 0416aa7 commit bccf309

File tree

77 files changed

+26375
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+26375
-7
lines changed

.circleci/config.yml

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,16 @@ jobs:
2424
- project
2525
- scripts
2626
sample-01:
27+
parameters:
28+
app-directory:
29+
type: string
30+
default: "Sample-01"
31+
description: "The root directory of the application to run"
2732
machine:
2833
image: << pipeline.parameters.machine_image >>
2934
environment:
30-
- AUTH0_CFG: Sample-01/auth_config.json
31-
- AUTH0_EXAMPLE_CFG: Sample-01/auth_config.json.example
35+
- AUTH0_CFG: <<parameters.app-directory>>/auth_config.json
36+
- AUTH0_EXAMPLE_CFG: <<parameters.app-directory>>/auth_config.json.example
3237
steps:
3338
- attach_workspace:
3439
at: ~/
@@ -42,18 +47,23 @@ jobs:
4247
$AUTH0_EXAMPLE_CFG > $AUTH0_CFG
4348
- node/install-packages:
4449
pkg-manager: npm
45-
app-dir: Sample-01
50+
app-dir: <<parameters.app-directory>>
4651
- run:
4752
name: Run unit tests
48-
working_directory: Sample-01
53+
working_directory: <<parameters.app-directory>>
4954
command: npm run test:ci
5055
login:
56+
parameters:
57+
app-directory:
58+
type: string
59+
default: "Sample-01"
60+
description: "The root directory of the application to run"
5161
machine:
5262
image: << pipeline.parameters.machine_image >>
5363
environment:
54-
- AUTH0_CFG: Sample-01/auth_config.json
55-
- AUTH0_EXAMPLE_CFG: Sample-01/auth_config.json.example
56-
- SAMPLE_PATH: Sample-01
64+
- AUTH0_CFG: <<parameters.app-directory>>/auth_config.json
65+
- AUTH0_EXAMPLE_CFG: <<parameters.app-directory>>/auth_config.json.example
66+
- SAMPLE_PATH: <<parameters.app-directory>>
5767
steps:
5868
- attach_workspace:
5969
at: ~/
@@ -100,10 +110,23 @@ workflows:
100110
- checkout:
101111
context: Quickstart SPA Test
102112
- sample-01:
113+
app-directory: Sample-01
114+
requires:
115+
- checkout
116+
- sample-01:
117+
name: standalone
118+
app-directory: Standalone
119+
requires:
120+
- checkout
121+
- login:
103122
context: Quickstart SPA Test
123+
app-directory: Sample-01
104124
requires:
105125
- checkout
106126
- login:
127+
name: login-standalone
107128
context: Quickstart SPA Test
129+
app-directory: Standalone
108130
requires:
109131
- checkout
132+
- login

Standalone/.browserslistrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# You can see what browsers were selected by your queries by running:
6+
# npx browserslist
7+
8+
> 0.5%
9+
last 2 versions
10+
Firefox ESR
11+
not dead
12+
not IE 9-11 # For IE 9-11 support, remove 'not'.

Standalone/.dockerignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
dist/
3+
node_modules/
4+
exec.*
5+
npm-debug.log*
6+
yarn-error.log
7+
README.md
8+
9+
# testing
10+
/coverage
11+
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*%

Standalone/.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

Standalone/.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
auth_config.json
3+
4+
# compiled output
5+
/dist
6+
/tmp
7+
/out-tsc
8+
# Only exists if Bazel was run
9+
/bazel-out
10+
11+
# dependencies
12+
/node_modules
13+
14+
# profiling files
15+
chrome-profiler-events.json
16+
speed-measure-plugin.json
17+
18+
# IDEs and editors
19+
/.idea
20+
.project
21+
.classpath
22+
.c9/
23+
*.launch
24+
.settings/
25+
*.sublime-workspace
26+
27+
# IDE - VSCode
28+
.vscode/*
29+
!.vscode/tasks.json
30+
!.vscode/launch.json
31+
!.vscode/extensions.json
32+
.history/*
33+
34+
# misc
35+
/.angular/cache
36+
/.sass-cache
37+
/connect.lock
38+
/coverage
39+
/libpeerconnection.log
40+
npm-debug.log
41+
yarn-error.log
42+
testem.log
43+
/typings
44+
45+
# System Files
46+
.DS_Store
47+
Thumbs.db

Standalone/Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM node:16-alpine AS build
2+
3+
RUN apk update && apk add git
4+
5+
RUN mkdir -p /app
6+
7+
WORKDIR /app
8+
9+
COPY package.json .
10+
COPY package-lock.json .
11+
12+
RUN npm install --legacy-peer-deps
13+
14+
COPY . .
15+
16+
RUN npm run build
17+
18+
# -----------------
19+
20+
FROM node:16-alpine
21+
22+
RUN mkdir -p /app
23+
24+
WORKDIR /app
25+
26+
COPY package.json .
27+
COPY package-lock.json .
28+
29+
RUN npm install --production --legacy-peer-deps
30+
31+
COPY --from=build ./app/dist/login-demo ./dist
32+
COPY ./server.js .
33+
COPY ./api-server.js .
34+
COPY ./auth_config.json .
35+
36+
ENV NODE_ENV=production
37+
ENV SERVER_PORT=4200
38+
ENV API_SERVER_PORT=3001
39+
40+
EXPOSE 4200
41+
EXPOSE 3001
42+
43+
CMD ["npm", "run", "prod"]

Standalone/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Auth0 Angular SDK sample
2+
3+
This sample app demonstrates the integration of the [Auth0 Angular SDK](https://github.com/auth0/auth0-angular) into an Angular application created using the Angular CLI. This sample is a companion to the [Auth0 Angular SDK Quickstart](https://auth0.com/docs/quickstart/spa/angular).
4+
5+
This sample demonstrates the following use cases:
6+
7+
- Login
8+
- Log out
9+
- Showing the user profile
10+
- Protecting routes using the authentication guard
11+
- Calling APIs with automatically-attached bearer tokens
12+
13+
## Configuration
14+
15+
The sample needs to be configured with your Auth0 domain and client ID in order to work. In the root of the sample, copy `auth_config.json.example` and rename it to `auth_config.json`. Open the file and replace the values with those from your Auth0 tenant:
16+
17+
```json
18+
{
19+
"domain": "<YOUR AUTH0 DOMAIN>",
20+
"clientId": "<YOUR AUTH0 CLIENT ID>",
21+
"audience": "<YOUR AUTH0 API AUDIENCE IDENTIFIER>"
22+
}
23+
```
24+
25+
## Development server
26+
27+
Run `npm run dev` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
28+
29+
This will automatically start a Node + Express server as the backend on port `3001`. The Angular application is configured to proxy through to this on any `/api` route.
30+
31+
## Build
32+
33+
Run `npm build` to build the project. The build artifacts will be stored in the `dist/login-demo` directory. Use the `--prod` flag for a production build.
34+
35+
To build and run a production bundle and serve it, run `npm run prod`. The application will run on `http://localhost:3000`.
36+
37+
## Run Using Docker
38+
39+
You can build and run the sample in a Docker container by using the provided scripts:
40+
41+
```bash
42+
# In Linux / MacOS
43+
sh exec.sh
44+
45+
# Windows Powershell
46+
./exec.ps1
47+
```
48+
49+
## Further help
50+
51+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
52+
53+
## Frequently Asked Questions
54+
55+
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)!
56+
57+
# What is Auth0?
58+
59+
Auth0 helps you to:
60+
61+
- Add authentication with [multiple authentication sources](https://auth0.com/docs/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**.
62+
- Add authentication through more traditional **[username/password databases](https://auth0.com/docs/connections/database/custom-db/create-db-connection)**.
63+
- Add support for **[linking different user accounts](https://auth0.com/docs/users/user-account-linking)** with the same user.
64+
- Support for generating signed [Json Web Tokens](https://auth0.com/docs/tokens/json-web-tokens) to call your APIs and **flow the user identity** securely.
65+
- Analytics of how, when and where users are logging in.
66+
- Pull data from other sources and add it to the user profile, through [JavaScript rules](https://auth0.com/docs/rules).
67+
68+
## Create a Free Auth0 Account
69+
70+
1. Go to [Auth0](https://auth0.com/signup) and click Sign Up.
71+
2. Use Google, GitHub or Microsoft Account to login.
72+
73+
## Issue Reporting
74+
75+
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.
76+
77+
## Author
78+
79+
[Auth0](https://auth0.com)
80+
81+
## License
82+
83+
This project is licensed under the MIT license. See the [LICENSE](../LICENSE) file for more info.

0 commit comments

Comments
 (0)