Skip to content

Changes recommended to get the CircleCI emblem to go green #384

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

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
cc2b4bb
Sample code up and running
djbauch Mar 13, 2025
5648d50
Replaced use of custom Highlight component with ReactJson
djbauch Mar 14, 2025
05e5873
Removing Highlight.js from the project
djbauch Mar 15, 2025
d71aa48
Fixed bug on the call to the auth funcrtion from express-oauth2-jwt-…
djbauch Mar 15, 2025
72cbb66
Taking a stab at setting up Circle CI
djbauch Mar 15, 2025
16d06d1
Try trigger on push to default branch
djbauch Mar 15, 2025
ee5cc01
Try without the Docker orb
djbauch Mar 15, 2025
4758c77
Bump up docker version ini config.yml
djbauch Mar 15, 2025
2289d44
Try bumping up alpine version
djbauch Mar 15, 2025
c795a17
Upgrade from legacy version of yarn
djbauch Mar 15, 2025
c8c3136
rearrange Dockerfile
djbauch Mar 15, 2025
2be6e8e
Unoopsed the npm install command
djbauch Mar 15, 2025
88f242e
Updated to @auth0/auth0-react 2.3.0
djbauch Mar 16, 2025
e6e085e
Added auth0-react-sample from npm as a direct dependency
djbauch Mar 16, 2025
30bb768
Removed auth0-react-sample@workspace from the yarn.lock
djbauch Mar 16, 2025
9a4f2c3
Added yarn@4.0.0 to orbs in config.yml
djbauch Mar 16, 2025
1563a32
Specify yarn-version 3.2.4 to get yarnpkg
djbauch Mar 16, 2025
a4a071f
try installing yarn after nodejs
djbauch Mar 16, 2025
c969d1c
Try rolling back to the legacy yarn 1.22.22. This seems to eliminate …
djbauch Mar 16, 2025
5f11269
Removed yarn upgrade from Dockerfile
djbauch Mar 16, 2025
a726b99
Roll back Docker image from lts to 22.1.0
djbauch Mar 16, 2025
8c48cee
I missed the second reference to cimg/node!
djbauch Mar 16, 2025
7484b48
Try rolling back the node orb from 7.1.0 to 5.0.2
djbauch Mar 16, 2025
90bbd19
Try cimg/node:20.2.0 instead of 22.1.0
djbauch Mar 16, 2025
1ed7aec
Fixed type confusion for the environment variables
djbauch Mar 18, 2025
a791bcb
After yarn install, tests all pass
djbauch Mar 18, 2025
e25182c
Merge branch 'master' of http://github.com/djbauch/auth0-react-sample…
djbauch Mar 18, 2025
a098eb0
Try fix recommended by CircleCI Docs AI
djbauch Mar 18, 2025
4a65872
Even more fiddling with node version
djbauch Mar 18, 2025
277efd2
It's the Dockerfile, isn't it?
djbauch Mar 18, 2025
bfb9a85
Addressed all Snyk-reported issues
djbauch Mar 18, 2025
cb59e02
Removed auth0-react-sample from package.json
djbauch Mar 19, 2025
ef01adf
Updated version of bootstrap in index.html to match expectations of r…
djbauch Mar 19, 2025
01e7de4
Fixed incorrect use of RateLimit in server.js
djbauch Mar 19, 2025
9785a5d
Trying variations on the codeceptjs commands
djbauch Mar 19, 2025
46a2bc8
Added an npx command to the test setup
djbauch Mar 19, 2025
5d145ac
Separate the configuration run from the test run?
djbauch Mar 20, 2025
9bfe973
Make sure the configuration comes first!
djbauch Mar 20, 2025
3d0831b
Placed missing slash
djbauch Mar 20, 2025
2624a77
Switch to Playwright to see if that works better
djbauch Mar 20, 2025
add8d87
Put back the config file
djbauch Mar 20, 2025
7370c88
Try a login with invalid email or password
djbauch Mar 20, 2025
6828813
Merge branch 'master' into master
djbauch Mar 25, 2025
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
26 changes: 17 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -8,40 +8,45 @@ version: 2.1

orbs:
node: circleci/node@5.0.2
docker: circleci/docker@2.0.3
# docker: circleci/docker@2.8.2

jobs:
checkout:
docker:
- image: cimg/node:lts
- image: cimg/node:20.2.0
steps:
- checkout
- run: git clone https://github.com/auth0-samples/spa-quickstarts-tests scripts
#- run: git clone https://github.com/auth0-samples/spa-quickstarts-tests scripts
# Use the following line instead of the previous one if you want to use a fork of the tests repository
- run: git clone https://github.com/djbauch/spa-quickstarts-tests scripts
- persist_to_workspace:
root: ~/
paths:
- project
- scripts
sample-01:
docker:
- image: cimg/node:lts
- image: cimg/base:stable
environment:
- AUTH0_CFG: Sample-01/src/auth_config.json
- SAMPLE_PATH: Sample-01
AUTH0_CFG: Sample-01/src/auth_config.json
SAMPLE_PATH: Sample-01
steps:
- node/install:
node-version: "22.14.0"
install-yarn: true
- run: node --version
- attach_workspace:
at: ~/
- run:
name: Replace Auth0 test credentials
command: |
echo "{ \"domain\": \"$AUTH0_TEST_DOMAIN\", \"clientId\": \"$AUTH0_TEST_CLIENT_ID\", \"audience\": \"$AUTH0_TEST_API_IDENTIFIER\" }" > $AUTH0_CFG
- setup_remote_docker:
version: 19.03.13
version: 20.10.24
- run:
name: Build pull request
command: |
node --version
docker build -t $CIRCLE_JOB ./$SAMPLE_PATH
docker run -d -p 3000:3000 --name $CIRCLE_SHA1 $CIRCLE_JOB
- run:
@@ -61,9 +66,12 @@ jobs:
name: Run integration tests
command: |
docker create --network host --name tester codeceptjs/codeceptjs codeceptjs run-multiple --all --steps --verbose
docker cp $(pwd)/lock_login_spa_test.js tester:/tests/lock_login_test.js
docker cp $(pwd)/codecept.conf.js tester:/tests/codecept.conf.js
docker start -i tester
docker cp $(pwd)/cant_login_spa_test.js tester:/tests/cant_login_test.js
docker start -i tester


working_directory: scripts
- run:
name: Copy app container logs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ node_modules
**/auth0-variables.js
npm-debug.log
.editorconfig
.vscode/
15 changes: 9 additions & 6 deletions Sample-01/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM node:lts-alpine3.14 as build
ARG NODE_VERSION=22.14.0
ARG ALPINE_VERSION=3.21

FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS build

RUN apk update && \
apk upgrade && \
@@ -20,13 +23,13 @@ RUN yarn build

# ---------------

FROM node:lts-alpine3.14

RUN mkdir -p /app/build
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION}

RUN apk update && \
RUN mkdir -p /app/build && \
apk update && \
apk upgrade && \
apk add git
apk add git && \
rm -rf /var/cache/apk/*

WORKDIR /app

8 changes: 4 additions & 4 deletions Sample-01/api-server.js
Original file line number Diff line number Diff line change
@@ -7,9 +7,9 @@ const authConfig = require("./src/auth_config.json");

const app = express();

const port = process.env.API_PORT || 3001;
const appPort = process.env.SERVER_PORT || 3000;
const appOrigin = authConfig.appOrigin || `http://localhost:${appPort}`;
const port = +(process.env.API_PORT ?? 3001)
const appPort = +(process.env.SERVER_PORT || 3000)
const appOrigin =('appOrigin' in authConfig) ? authConfig.appOrigin : `http://localhost:${appPort}`;

if (
!authConfig.domain ||
@@ -30,7 +30,7 @@ app.use(cors({ origin: appOrigin }));
const checkJwt = auth({
audience: authConfig.audience,
issuerBaseURL: `https://${authConfig.domain}/`,
algorithms: ["RS256"],
tokenSigningAlg: "RS256",
});

app.get("/api/external", checkJwt, (req, res) => {
12 changes: 7 additions & 5 deletions Sample-01/package.json
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
"prod": "npm-run-all --parallel server api-server"
},
"dependencies": {
"@auth0/auth0-react": "^2.2.0",
"@auth0/auth0-react": "^2.3.0",
"@babel/core": "^7.23",
"@babel/plugin-syntax-flow": "^7.23",
"@babel/plugin-transform-react-jsx": "^7.23",
@@ -26,17 +26,18 @@
"autoprefixer": "^10.4",
"cors": "^2.8",
"express": "^4.18",
"express-oauth2-jwt-bearer": "^1.6.0",
"express-oauth2-jwt-bearer": "^1.6.1",
"express-rate-limit": "^7.5.0",
"helmet": "^4.4",
"highlight.js": "^10.0",
"morgan": "^1.9",
"npm-run-all": "^4.1",
"postcss": "^8.4",
"react": "^18",
"react-dom": "^18",
"react-json-view": "^1.21.3",
"react-router-dom": "^5.3",
"react-scripts": "^5.0",
"reactstrap": "^9.2",
"reactstrap": "9.2.3",
"typescript": "^4.9"
},
"devDependencies": {
@@ -60,5 +61,6 @@
"last 1 firefox version",
"last 1 safari version"
]
}
},
"packageManager": "yarn@1.22.22"
}
11 changes: 10 additions & 1 deletion Sample-01/public/index.html
Original file line number Diff line number Diff line change
@@ -22,13 +22,22 @@
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://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
crossorigin="anonymous"
>
<!-- reactstrap library now uses bootstrap v5 rather than v4>
<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"
/>

-->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.min.js"
integrity="sha384-0pUGZvbkm6XF6gxjEnlmuGrJXVbNuzT9qBBavbLwCsOGabYfZo0T0to5eqruptLy"
crossorigin="anonymous"></script>
<link
rel="stylesheet"
href="https://cdn.auth0.com/js/auth0-samples-theme/1.0/css/auth0-theme.min.css"
11 changes: 10 additions & 1 deletion Sample-01/server.js
Original file line number Diff line number Diff line change
@@ -2,10 +2,19 @@ const express = require("express");
const morgan = require("morgan");
const helmet = require("helmet");
const { join } = require("path");
const RateLimit = require("express-rate-limit");

const app = express();

const port = process.env.SERVER_PORT || 3000;
const port = +(process.env.SERVER_PORT ?? '3000');

// Limit to 100 requests per 15 minutes
const limiter = RateLimit({
windowMs: 15 * 60 * 1000,
max: 100,
});

app.use(limiter);

app.use(morgan("dev"));

73 changes: 0 additions & 73 deletions Sample-01/src/components/Highlight.js

This file was deleted.

22 changes: 13 additions & 9 deletions Sample-01/src/serviceWorker.js
Original file line number Diff line number Diff line change
@@ -44,8 +44,10 @@ export function register(config) {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
);
});
)
}).catch((error) => {
console.error('Error during service worker registration:', error);
})
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
@@ -75,19 +77,15 @@ function registerValidSW(swUrl, config) {
);

// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
config?.onUpdate?.(registration);
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');

// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
config?.onSuccess?.(registration);
}
}
};
@@ -112,7 +110,11 @@ function checkValidServiceWorker(swUrl, config) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
}).catch(error => {
console.error('Error during service worker unregistration:', error);
} );
}).catch(error => {
console.error('Error waiting for serviceWorker.ready:', error);
});
} else {
// Service worker found. Proceed as normal.
@@ -130,6 +132,8 @@ export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
}).catch(error => {
console.error('Error during service worker unregistration:', error);
});
}
}
20 changes: 14 additions & 6 deletions Sample-01/src/views/ExternalApi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from "react";
import { Button, Alert } from "reactstrap";
import Highlight from "../components/Highlight";
import ReactJson from "react-json-view";
import { useAuth0, withAuthenticationRequired } from "@auth0/auth0-react";
import { getConfig } from "../config";
import Loading from "../components/Loading";
@@ -89,7 +89,7 @@ export const ExternalApiComponent = () => {
You need to{" "}
<a
href="#/"
class="alert-link"
className="alert-link"
onClick={(e) => handle(e, handleConsent)}
>
consent to get access to users api
@@ -102,7 +102,7 @@ export const ExternalApiComponent = () => {
You need to{" "}
<a
href="#/"
class="alert-link"
className="alert-link"
onClick={(e) => handle(e, handleLoginAgain)}
>
log in again
@@ -117,7 +117,7 @@ export const ExternalApiComponent = () => {

<p>
This will call a local API on port 3001 that would have been started
if you run <code>npm run dev</code>. An access token is sent as part
if you run <code>yarn run dev</code>. An access token is sent as part
of the request's `Authorization` header and the API will validate it
using the API's audience value.
</p>
@@ -182,9 +182,17 @@ export const ExternalApiComponent = () => {
{state.showResult && (
<div className="result-block" data-testid="api-result">
<h6 className="muted">Result</h6>
<Highlight>
{/* <Highlight>
<span>{JSON.stringify(state.apiMessage, null, 2)}</span>
</Highlight>
</Highlight> */}
<ReactJson
src={state.apiMessage}
theme="monokai"
name={false}
displayObjectSize={false}
displayDataTypes={false}
style={{ fontSize: "1.1rem", lineHeight: 1.1 }}
/>
</div>
)}
</div>
Loading