Compare commits

..

58 Commits

Author SHA1 Message Date
argoyle 488d3a8b7f feat: support patching of user info 2024-03-11 16:38:52 +01:00
Renovate a42c8c3251 fix(deps): update dependency express to v4.18.3 2024-02-29 11:54:02 +00:00
Renovate 411dd3d222 chore(deps): update dependency node to v20 2024-02-23 22:55:39 +00:00
Renovate acbea4996f Add renovate.json 2024-02-23 22:59:42 +01:00
argoyle e0df0465aa chore(deps): bump nodemon from 3.0.3 to 3.1.0
Bumps [nodemon](https://github.com/remy/nodemon) from 3.0.3 to 3.1.0.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v3.0.3...v3.1.0)
2024-02-23 06:53:00 +00:00
argoyle e7c4bfcdb7 chore(deps-dev): bump prettier from 3.2.4 to 3.2.5
Bumps [prettier](https://github.com/prettier/prettier) from 3.2.4 to 3.2.5.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.2.4...3.2.5)
2024-02-04 06:52:38 +00:00
argoyle 041b66a54e chore(deps-dev): bump prettier from 3.2.3 to 3.2.4
Bumps [prettier](https://github.com/prettier/prettier) from 3.2.3 to 3.2.4.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.2.3...3.2.4)
2024-01-18 06:52:57 +00:00
argoyle ce5467682e chore(deps-dev): bump prettier from 3.2.2 to 3.2.3
Bumps [prettier](https://github.com/prettier/prettier) from 3.2.2 to 3.2.3.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.2.2...3.2.3)
2024-01-17 10:12:35 +00:00
argoyle 860b658fd8 chore(deps): bump nodemon from 3.0.2 to 3.0.3
Bumps [nodemon](https://github.com/remy/nodemon) from 3.0.2 to 3.0.3.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v3.0.2...v3.0.3)
2024-01-17 06:53:12 +00:00
argoyle 5e0922d84f chore(deps-dev): bump prettier from 3.2.1 to 3.2.2
Bumps [prettier](https://github.com/prettier/prettier) from 3.2.1 to 3.2.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.2.1...3.2.2)
2024-01-14 06:52:40 +00:00
argoyle ce35c1eb50 chore(deps-dev): bump prettier from 3.1.1 to 3.2.1
Bumps [prettier](https://github.com/prettier/prettier) from 3.1.1 to 3.2.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.1.1...3.2.1)
2024-01-13 06:52:53 +00:00
argoyle 44047f88e4 chore(deps-dev): bump prettier from 3.1.0 to 3.1.1
Bumps [prettier](https://github.com/prettier/prettier) from 3.1.0 to 3.1.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.1.0...3.1.1)
2023-12-11 06:52:49 +00:00
argoyle a9633e9079 chore(deps): bump nodemon from 3.0.1 to 3.0.2
Bumps [nodemon](https://github.com/remy/nodemon) from 3.0.1 to 3.0.2.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v3.0.1...v3.0.2)
2023-12-02 06:52:34 +00:00
argoyle ef9654adfa chore(deps-dev): bump prettier from 3.0.3 to 3.1.0
Bumps [prettier](https://github.com/prettier/prettier) from 3.0.3 to 3.1.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.0.3...3.1.0)
2023-11-13 06:52:57 +00:00
argoyle e99a340485 chore(deps): bump jsonwebtoken from 9.0.1 to 9.0.2
Bumps [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) from 9.0.1 to 9.0.2.
- [Changelog](https://github.com/auth0/node-jsonwebtoken/blob/master/CHANGELOG.md)
- [Commits](https://github.com/auth0/node-jsonwebtoken/compare/v9.0.1...v9.0.2)
2023-08-31 06:53:06 +00:00
argoyle d362203165 chore(deps-dev): bump prettier from 3.0.2 to 3.0.3
Bumps [prettier](https://github.com/prettier/prettier) from 3.0.2 to 3.0.3.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.0.2...3.0.3)
2023-08-30 06:52:46 +00:00
argoyle afa1893f1a chore(deps-dev): bump prettier from 3.0.1 to 3.0.2
Bumps [prettier](https://github.com/prettier/prettier) from 3.0.1 to 3.0.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.0.1...3.0.2)
2023-08-16 06:52:54 +00:00
argoyle 791a29d5b8 chore(deps-dev): bump prettier from 3.0.0 to 3.0.1
Bumps [prettier](https://github.com/prettier/prettier) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/3.0.0...3.0.1)
2023-08-03 06:52:38 +00:00
argoyle d34a738b71 chore(deps): bump nodemon from 3.0.0 to 3.0.1
Bumps [nodemon](https://github.com/remy/nodemon) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v3.0.0...v3.0.1)
2023-07-10 06:52:57 +00:00
argoyle 6e0bb8e1ca chore(deps): bump nodemon from 2.0.22 to 3.0.0
Bumps [nodemon](https://github.com/remy/nodemon) from 2.0.22 to 3.0.0.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v2.0.22...v3.0.0)
2023-07-09 06:52:41 +00:00
argoyle c29f8be74c chore(deps-dev): bump prettier from 2.8.8 to 3.0.0
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.8 to 3.0.0.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.8...3.0.0)
2023-07-06 08:57:27 +00:00
argoyle 349989bb67 chore(deps): bump jsonwebtoken from 9.0.0 to 9.0.1
Bumps [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) from 9.0.0 to 9.0.1.
- [Changelog](https://github.com/auth0/node-jsonwebtoken/blob/master/CHANGELOG.md)
- [Commits](https://github.com/auth0/node-jsonwebtoken/commits)
2023-07-06 06:52:31 +00:00
peter d940a04d05 feat: initial users store 2023-06-01 15:00:26 +02:00
peter 192929229f fix: return empty array 2023-05-31 23:24:38 +02:00
peter 397d60361e feat: remember created users 2023-05-31 20:30:37 +02:00
argoyle bb8deb221e feat: add name and email to id token 2023-05-02 12:12:43 +02:00
argoyle a465ae543a chore(deps): bump node from 18 to 20
Bumps node from 18 to 20.
2023-04-24 07:01:58 +00:00
argoyle 8aad0d6308 chore(deps-dev): bump prettier from 2.8.7 to 2.8.8
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.7 to 2.8.8.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.7...2.8.8)
2023-04-24 06:52:34 +00:00
argoyle 0166537d2f chore(deps-dev): bump prettier from 2.8.6 to 2.8.7
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.6 to 2.8.7.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.6...2.8.7)
2023-03-27 14:04:03 +00:00
argoyle 9f6e63ea50 chore(deps): bump nodemon from 2.0.21 to 2.0.22
Bumps [nodemon](https://github.com/remy/nodemon) from 2.0.21 to 2.0.22.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v2.0.21...v2.0.22)
2023-03-23 06:52:58 +00:00
argoyle a30cb4b08c chore(deps-dev): bump prettier from 2.8.5 to 2.8.6
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.5 to 2.8.6.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.5...2.8.6)
2023-03-22 06:52:36 +00:00
argoyle abbc55ea6e chore(deps-dev): bump prettier from 2.8.4 to 2.8.5
Bumps [prettier](https://github.com/prettier/prettier) from 2.8.4 to 2.8.5.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.8.4...2.8.5)
2023-03-20 06:52:25 +00:00
argoyle 779d78cdc6 fix: remove session on logout 2023-03-10 15:10:36 +01:00
argoyle cf958ffa85 fix: handle response mode query 2023-03-10 13:50:38 +01:00
argoyle eb579289f0 chore: format code and add prettier 2023-03-10 13:49:33 +01:00
argoyle d1ff4ec278 chore(deps): bump nodemon from 2.0.20 to 2.0.21
Bumps [nodemon](https://github.com/remy/nodemon) from 2.0.20 to 2.0.21.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v2.0.20...v2.0.21)
2023-03-03 06:52:26 +00:00
argoyle 14c2c8f366 chore(deps): bump body-parser from 1.20.1 to 1.20.2
Bumps [body-parser](https://github.com/expressjs/body-parser) from 1.20.1 to 1.20.2.
- [Release notes](https://github.com/expressjs/body-parser/releases)
- [Changelog](https://github.com/expressjs/body-parser/blob/master/HISTORY.md)
- [Commits](https://github.com/expressjs/body-parser/compare/1.20.1...1.20.2)
2023-02-22 06:52:15 +00:00
argoyle 7177ba9516 ci: change Dependabot rebase strategy 2023-02-09 08:09:57 +01:00
argoyle 652483e2de ci: use Docker DinD version from variable 2023-02-09 08:09:35 +01:00
argoyle 4e43361217 fix: update image name to correct location 2022-12-28 20:02:21 +01:00
argoyle 6dda660e78 chore(deps): bump jsonwebtoken from 8.5.1 to 9.0.0
Bumps [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) from 8.5.1 to 9.0.0.
- [Release notes](https://github.com/auth0/node-jsonwebtoken/releases)
- [Changelog](https://github.com/auth0/node-jsonwebtoken/blob/master/CHANGELOG.md)
- [Commits](https://github.com/auth0/node-jsonwebtoken/compare/v8.5.1...v9.0.0)
2022-12-22 06:52:39 +00:00
argoyle 534772b315 chore(deps): bump express from 4.18.1 to 4.18.2
Bumps [express](https://github.com/expressjs/express) from 4.18.1 to 4.18.2.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.18.1...4.18.2)
2022-10-09 06:52:35 +00:00
argoyle 3bdfe7bf0e chore(deps): bump body-parser from 1.20.0 to 1.20.1
Bumps [body-parser](https://github.com/expressjs/body-parser) from 1.20.0 to 1.20.1.
- [Release notes](https://github.com/expressjs/body-parser/releases)
- [Changelog](https://github.com/expressjs/body-parser/blob/master/HISTORY.md)
- [Commits](https://github.com/expressjs/body-parser/compare/1.20.0...1.20.1)
2022-10-07 06:52:24 +00:00
argoyle edba76d0ab chore(deps): bump nodemon from 2.0.19 to 2.0.20
Bumps [nodemon](https://github.com/remy/nodemon) from 2.0.19 to 2.0.20.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v2.0.19...v2.0.20)
2022-09-17 06:52:27 +00:00
argoyle 5289b4fa23 chore(deps): bump nodemon from 2.0.18 to 2.0.19
Bumps [nodemon](https://github.com/remy/nodemon) from 2.0.18 to 2.0.19.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v2.0.18...v2.0.19)
2022-07-06 06:52:23 +00:00
argoyle eef7168f37 chore(deps): bump nodemon from 2.0.16 to 2.0.18
Bumps [nodemon](https://github.com/remy/nodemon) from 2.0.16 to 2.0.18.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v2.0.16...v2.0.18)
2022-06-24 06:52:29 +00:00
argoyle 596967ff72 Merge branch 'dependabot-npm_and_yarn-normalize-url-4.5.1' into 'main'
chore(deps): [security] bump normalize-url from 4.5.0 to 4.5.1

See merge request unboundsoftware/auth0mock!41
2022-05-02 07:01:46 +00:00
argoyle 5f2385a92f chore(deps): [security] bump normalize-url from 4.5.0 to 4.5.1
Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1. **This update includes a security fix.**
- [Release notes](https://github.com/sindresorhus/normalize-url/releases)
- [Commits](https://github.com/sindresorhus/normalize-url/commits)
2022-05-02 07:00:02 +00:00
argoyle a5653c8ea6 Merge branch 'dependabot-npm_and_yarn-ini-1.3.8' into 'main'
chore(deps): [security] bump ini from 1.3.5 to 1.3.8

See merge request unboundsoftware/auth0mock!39
2022-05-02 06:59:59 +00:00
argoyle 75ec899c99 chore(deps): [security] bump ini from 1.3.5 to 1.3.8
Bumps [ini](https://github.com/npm/ini) from 1.3.5 to 1.3.8. **This update includes a security fix.**
- [Release notes](https://github.com/npm/ini/releases)
- [Changelog](https://github.com/npm/ini/blob/main/CHANGELOG.md)
- [Commits](https://github.com/npm/ini/compare/v1.3.5...v1.3.8)
2022-05-02 06:58:19 +00:00
argoyle cb31381be2 Merge branch 'dependabot-npm_and_yarn-minimist-1.2.6' into 'main'
chore(deps): [security] bump minimist from 1.2.0 to 1.2.6

See merge request unboundsoftware/auth0mock!40
2022-05-02 06:58:17 +00:00
argoyle 9ee344311a chore(deps): [security] bump minimist from 1.2.0 to 1.2.6
Bumps [minimist](https://github.com/substack/minimist) from 1.2.0 to 1.2.6. **This update includes security fixes.**
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.0...1.2.6)
2022-05-02 06:56:54 +00:00
argoyle d7e3b10e80 Merge branch 'dependabot-npm_and_yarn-ansi-regex-4.1.1' into 'main'
chore(deps): [security] bump ansi-regex from 4.1.0 to 4.1.1

See merge request unboundsoftware/auth0mock!38
2022-05-02 06:56:51 +00:00
argoyle 7b306dd500 chore(deps): [security] bump ansi-regex from 4.1.0 to 4.1.1
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1. **This update includes a security fix.**
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v4.1.0...v4.1.1)
2022-05-02 06:52:21 +00:00
argoyle 22d096a2be Merge branch 'dependabot-npm_and_yarn-nodemon-2.0.16' into 'main'
chore(deps): bump nodemon from 2.0.15 to 2.0.16

See merge request unboundsoftware/auth0mock!37
2022-05-01 17:27:31 +00:00
argoyle 858cb96e10 chore(deps): bump nodemon from 2.0.15 to 2.0.16
Bumps [nodemon](https://github.com/remy/nodemon) from 2.0.15 to 2.0.16.
- [Release notes](https://github.com/remy/nodemon/releases)
- [Commits](https://github.com/remy/nodemon/compare/v2.0.15...v2.0.16)
2022-05-01 17:26:04 +00:00
argoyle e8dd55208c Merge branch 'dependabot-npm_and_yarn-express-4.18.1' into 'main'
chore(deps): bump express from 4.18.0 to 4.18.1

See merge request unboundsoftware/auth0mock!36
2022-05-01 17:25:57 +00:00
argoyle dbf5206c1b chore(deps): bump express from 4.18.0 to 4.18.1
Bumps [express](https://github.com/expressjs/express) from 4.18.0 to 4.18.1.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.18.0...4.18.1)
2022-04-30 06:52:18 +00:00
14 changed files with 386 additions and 820 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ image: buildtool/build-tools:${BUILDTOOLS_VERSION}
build:
stage: build
services:
- docker:dind
- docker:${DOCKER_DIND_VERSION}
script:
- build
- push
-17
View File
@@ -1,17 +0,0 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 20
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 20
+1
View File
@@ -0,0 +1 @@
20
+2
View File
@@ -0,0 +1,2 @@
*.yaml
*.yml
+9
View File
@@ -0,0 +1,9 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "always",
"quoteProps": "as-needed",
"bracketSpacing": true,
"bracketSameLine": false
}
+2 -2
View File
@@ -1,4 +1,4 @@
FROM node:18
FROM node:20
ENV AUDIENCE "https://shiny.unbound.se"
ENV ORIGIN_HOST "auth0mock"
ENV ORIGIN "https://auth0mock:3333"
@@ -6,7 +6,7 @@ EXPOSE 3333
WORKDIR /app
ADD package.json yarn.lock /app/
RUN yarn install --frozen-lockfile
ADD app.js cert.js /app/
ADD *.js /app/
ADD public /app/public
RUN mkdir -p /root/.config
ENTRYPOINT yarn start
+33 -12
View File
@@ -3,47 +3,68 @@
> This server helps you to simulate auth0 server locally. So, you are able to use the `/tokeninfo` endpoint to verify your token.
## Getting Started
### Prerequisites
* Install [Node.js](http://nodejs.org)
* on OSX use [homebrew](http://brew.sh) `brew install node`
* on Windows use [chocolatey](https://chocolatey.org/) `choco install nodejs`
### Prerequisites
- Install [Node.js](http://nodejs.org)
- on OSX use [homebrew](http://brew.sh) `brew install node`
- on Windows use [chocolatey](https://chocolatey.org/) `choco install nodejs`
## Installing
* `fork` this repo
* `clone` your fork
* `npm install` to install all dependencies
- `fork` this repo
- `clone` your fork
- `npm install` to install all dependencies
## Running the app
After you have installed all dependencies you can now run the app.
Run `npm start` to start a local server.
The port will be displayed to you as `http://0.0.0.0:3333` (or if you prefer IPv6, if you're using `express` server, then it's `http://[::1]:3333/`).
## Initial users
Adding a JSON file with the following layout will populate the users store when starting:
```json
{
"email@test.com": {
"given_name": "name",
"family_name": "family",
"user_id": "id"
}
}
```
By default `./users.json` will be read but this can be overridden by setting the environment variable `USERS_FILE`.
## API Documentation
### `GET` /token/:username
Returns a token with the given user(username). This token can the be used by your application.
### `POST` /tokeninfo
Returns the data of the token like the username.
**Body**
```
{
"id_token": "your-token-kjasdf6ashasl..."
}
```
## Related Projects
* [express-typescript-boilerplate](https://github.com/w3tecch/express-typescript-boilerplate) - Boilerplate for an restful express-apllication written in TypeScript
* [express-graphql-typescript-boilerplate](https://github.com/w3tecch/express-graphql-typescript-boilerplate) - A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
- [express-typescript-boilerplate](https://github.com/w3tecch/express-typescript-boilerplate) - Boilerplate for an restful express-apllication written in TypeScript
- [express-graphql-typescript-boilerplate](https://github.com/w3tecch/express-graphql-typescript-boilerplate) - A starter kit for building amazing GraphQL API's with TypeScript and express by @w3tecch
## License
[MIT](/LICENSE)
---
Made with ♥ by Gery Hirschfeld ([@GeryHirschfeld1](https://twitter.com/GeryHirschfeld1))
Made with ♥ by Gery Hirschfeld ([@GeryHirschfeld1](https://twitter.com/GeryHirschfeld1))
+129 -49
View File
@@ -10,17 +10,20 @@ const cors = require('cors')
const bodyParser = require('body-parser')
const favicon = require('serve-favicon')
const cert = require('./cert')
const initialUsers = require('./users')
let issuer = process.env.ISSUER || 'localhost:3333'
let jwksOrigin = `https://${issuer}/`
const audience = process.env.AUDIENCE || 'https://generic-audience'
const adminCustomClaim = process.env.ADMIN_CUSTOM_CLAIM || 'https://unbound.se/admin'
const emailCustomClaim = process.env.EMAIL_CUSTOM_CLAIM || 'https://unbound.se/email'
const adminCustomClaim =
process.env.ADMIN_CUSTOM_CLAIM || 'https://unbound.se/admin'
const emailCustomClaim =
process.env.EMAIL_CUSTOM_CLAIM || 'https://unbound.se/email'
const debug = Debug('app')
let { privateKey, certDer, thumbprint, exponent, modulus } = cert(jwksOrigin)
const users = initialUsers(process.env.USERS_FILE || './users.json')
const sessions = {}
const challenges = {}
@@ -37,7 +40,6 @@ const addCustomClaims = (email, customClaims, token) => {
...claim
}
}, token)
}
const signToken = (token) => {
@@ -48,7 +50,8 @@ const signToken = (token) => {
}
// Configure our small auth0-mock-server
app.options('*', cors(corsOpts))
app
.options('*', cors(corsOpts))
.use(cors())
.use(bodyParser.json({ strict: false }))
.use(bodyParser.urlencoded({ extended: true }))
@@ -91,26 +94,34 @@ app.post('/oauth/token', (req, res) => {
} else if (req.body.code) {
const code = req.body.code
const session = sessions[code]
let accessToken = signToken(addCustomClaims(session.email, session.customClaims, {
iss: jwksOrigin,
aud: [audience],
sub: 'auth0|' + session.email,
iat: date,
exp: date + 7200,
azp: session.clientId
}))
let accessToken = signToken(
addCustomClaims(session.email, session.customClaims, {
iss: jwksOrigin,
aud: [audience],
sub: 'auth0|' + session.email,
iat: date,
exp: date + 7200,
azp: session.clientId
})
)
let idToken = signToken(addCustomClaims(session.email, session.customClaims, {
iss: jwksOrigin,
aud: session.clientId,
nonce: session.nonce,
sub: 'auth0|' + session.email,
iat: date,
exp: date + 7200,
azp: session.clientId,
name: 'Example Person',
picture: 'https://cdn.playbuzz.com/cdn/5458360f-32ea-460e-a707-1a2d26760558/70bda687-cb84-4756-8a44-8cf735ed87b3.jpg'
}))
let idToken = signToken(
addCustomClaims(session.email, session.customClaims, {
iss: jwksOrigin,
aud: session.clientId,
nonce: session.nonce,
sub: 'auth0|' + session.email,
iat: date,
exp: date + 7200,
azp: session.clientId,
name: 'Example Person',
given_name: 'Example',
family_name: 'Person',
email: session.email,
picture:
'https://cdn.playbuzz.com/cdn/5458360f-32ea-460e-a707-1a2d26760558/70bda687-cb84-4756-8a44-8cf735ed87b3.jpg'
})
)
debug('Signed token for ' + session.email)
@@ -133,9 +144,12 @@ app.get('/token/:email', (req, res) => {
debug('No user was given!')
return res.status(400).send('user is missing')
}
const token = jwt.sign({
user_id: 'auth0|' + req.params.email
}, privateKey)
const token = jwt.sign(
{
user_id: 'auth0|' + req.params.email
},
privateKey
)
debug('Signed token for ' + req.params.email)
res.json({ token })
})
@@ -160,7 +174,9 @@ app.post('/code', (req, res) => {
codeChallenge: req.body.codeChallenge,
customClaims: [claim]
}
res.redirect(`${req.body.redirect}?domain=${issuer}&code=${code}&state=${encodeURIComponent(state)}`)
res.redirect(
`${req.body.redirect}?code=${code}&state=${encodeURIComponent(state)}`
)
})
app.get('/authorize', (req, res) => {
@@ -171,13 +187,26 @@ app.get('/authorize', (req, res) => {
const codeChallenge = req.query.code_challenge
const prompt = req.query.prompt
const responseMode = req.query.response_mode
if (responseMode === 'query') {
const code = req.cookies['auth0']
const session = sessions[code]
if (session) {
session.nonce = nonce
session.state = state
session.codeChallenge = codeChallenge
sessions[codeChallenge] = session
res.redirect(`${redirect}?code=${codeChallenge}&state=${state}`)
return
}
}
if (prompt === 'none' && responseMode === 'web_message') {
const code = req.cookies['auth0']
const session = sessions[code]
session.nonce = nonce
session.state = state
session.codeChallenge = codeChallenge
res.send(`
if (session) {
session.nonce = nonce
session.state = state
session.codeChallenge = codeChallenge
res.send(`
<!DOCTYPE html>
<html>
<body>
@@ -195,13 +224,16 @@ app.get('/authorize', (req, res) => {
</script>
</body>
</html>`)
} else {
res.cookie('auth0', codeChallenge, {
sameSite: 'None',
secure: true,
httpOnly: true
})
res.send(`
return
}
}
res.cookie('auth0', codeChallenge, {
sameSite: 'None',
secure: true,
httpOnly: true
})
res.send(`
<html lang='en'>
<head>
<meta charset='utf-8'>
@@ -242,21 +274,29 @@ app.get('/authorize', (req, res) => {
</body>
</html>
`)
}
})
app.get('/userinfo', (req, res) => {
res.contentType('application/json').send(JSON.stringify({ picture: 'https://cdn.playbuzz.com/cdn/5458360f-32ea-460e-a707-1a2d26760558/70bda687-cb84-4756-8a44-8cf735ed87b3.jpg' }))
res.contentType('application/json').send(
JSON.stringify({
picture:
'https://cdn.playbuzz.com/cdn/5458360f-32ea-460e-a707-1a2d26760558/70bda687-cb84-4756-8a44-8cf735ed87b3.jpg'
})
)
})
app.get('/v2/logout', (req, res) => {
res.redirect(`${req.query.returnTo}?domain=${issuer}`)
const code = req.cookies['auth0']
const session = sessions[code]
if (session) {
delete sessions[code]
}
res.redirect(req.query.returnTo)
})
app.get('/.well-known/jwks.json', (req, res) => {
res
.contentType('application/json')
.send(JSON.stringify({
res.contentType('application/json').send(
JSON.stringify({
keys: [
{
alg: 'RS256',
@@ -270,7 +310,8 @@ app.get('/.well-known/jwks.json', (req, res) => {
x5t: thumbprint
}
]
}))
})
)
})
// This route returns the inside of a jwt-token. Your main application
@@ -297,7 +338,13 @@ app.post('/issuer', (req, res) => {
}
issuer = req.body.issuer
jwksOrigin = `https://${issuer}/`
const { privateKey: key, certDer: der, thumbprint: thumb, exponent: exp, modulus: mod } = cert(jwksOrigin)
const {
privateKey: key,
certDer: der,
thumbprint: thumb,
exponent: exp,
modulus: mod
} = cert(jwksOrigin)
privateKey = key
certDer = der
thumbprint = thumb
@@ -308,11 +355,44 @@ app.post('/issuer', (req, res) => {
})
app.get('/api/v2/users-by-email', (req, res) => {
res.json([])
const email = req.query.email
console.log('users', users)
const user = users[email]
if (user === undefined) {
res.json([])
} else {
res.json([user])
}
})
app.patch('/api/v2/users/:userid', (req, res) => {
const email = req.params.userid.slice(6)
console.log('patching user with id', email)
const user = users[email]
if (!user) {
res.sendStatus(404)
return
}
users[email] = {
email: email,
given_name: req.body.given_name || user.given_name,
family_name: req.body.family_name || user.family_name,
user_id: email,
picture: req.body.picture || user.picture
}
res.json({
user_id: `auth0|${email}`
})
})
app.post('/api/v2/users', (req, res) => {
const email = req.body.email
users[email] = {
email: email,
given_name: 'Given',
family_name: 'Last',
user_id: email
}
res.json({
user_id: `auth0|${email}`
})
@@ -324,7 +404,7 @@ app.post('/api/v2/tickets/password-change', (req, res) => {
})
})
app.use(function(req, res, next) {
app.use(function (req, res, next) {
console.log('404', req.path)
res.status(404).send('error: 404 Not Found ' + req.path)
})
+1 -5
View File
@@ -43,11 +43,7 @@ const PUBLIC_KEY_PEM =
'HwIDAQAB\n' +
'-----END PUBLIC KEY-----\n'
const createCertificate = ({
publicKey,
privateKey,
jwksOrigin
}) => {
const createCertificate = ({ publicKey, privateKey, jwksOrigin }) => {
const cert = forge.pki.createCertificate()
cert.publicKey = publicKey
cert.serialNumber = '123'
+1 -1
View File
@@ -14,7 +14,7 @@ spec:
spec:
containers:
- name: auth0mock
image: registry.gitlab.com/unboundsoftware/shiny/auth0mock:${COMMIT}
image: registry.gitlab.com/unboundsoftware/auth0mock:${COMMIT}
imagePullPolicy: "IfNotPresent"
resources:
requests:
+11 -5
View File
@@ -6,23 +6,29 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "nodemon ./app.js",
"start": "node ./app.js"
"start": "node ./app.js",
"lint:prettier": "prettier --check .",
"lint": "yarn lint:prettier",
"lintfix": "prettier --write --list-different ."
},
"author": "",
"license": "MIT",
"dependencies": {
"base64-url": "^2.3.3",
"body-parser": "^1.20.0",
"body-parser": "^1.20.2",
"buffer": "^6.0.3",
"cookie-parser": "^1.4.6",
"cors": "^2.8.3",
"debug": "^4.3.4",
"express": "^4.18.0",
"express": "^4.18.2",
"https-localhost": "^4.7.1",
"jsonwebtoken": "^8.5.1",
"jsonwebtoken": "^9.0.2",
"node-forge": "^1.3.1",
"node-rsa": "^1.1.1",
"nodemon": "^2.0.15",
"nodemon": "^3.1.0",
"serve-favicon": "^2.4.2"
},
"devDependencies": {
"prettier": "^3.2.5"
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
]
}
+18
View File
@@ -0,0 +1,18 @@
const fs = require('fs')
const setup = (usersFile) => {
let users = {}
if (fs.existsSync(usersFile)) {
console.log(`initial users file "${usersFile}" exists, reading`)
const read = fs.readFileSync(usersFile, { encoding: 'utf8', flag: 'r' })
users = JSON.parse(read)
for (let key of Object.keys(users)) {
users[key] = { ...users[key], email: key }
}
console.log('users:', users)
} else {
console.log(`initial users file "${usersFile}" missing`)
}
return users
}
module.exports = setup
+172 -728
View File
File diff suppressed because it is too large Load Diff