Helper application for testing OAuth clients
What is this?
fauxauth is a mock server for testing applications that are using OAuth
authentication. Specifically, it was created to pretend to be GitHub's OAuth
flow, as documented here.
How can I use it?
fauxauth is set up for two primary use cases:
Docker: if you're developing or testing your app using Docker containers, you can make
fauxauthpart of a multi-container network using Compose.
Assuming an app that will locate the OAuth provider via an
OAUTH_URLenvironment variable, your
docker-compose.ymlcould look something like:
version: '3' services: some_app: ... links: - oauth environment: OAUTH_URL: http://oauth ... oauth: image: textbook/fauxauth
Node Dependency: alternatively, you may want to run
fauxauthdirectly. You can install it from NPM as follows:npm install fauxauth --save-dev # or "yarn add fauxauth -D"
Once installed, you can add it to one of your
package.jsonscripts. I find
concurrentlyuseful for simplifying development tasks like this, e.g.
The compiled version of
fauxauth, as released to NPM, is tested against the
latest versions of three Node LTS releases: Carbon (8), Dubnium (10) and
Erbium (12). Compilation is carried out using TypeScript in the Node version
You can configure the port that the
fauxauth server runs on by setting the
PORT environment variable, e.g. using
cross-env in your scripts:
You can also set the OAuth configuration; it is initially hardcoded as follows:
||The access token to return (randomly generated otherwise)||
||The base URL to return or validate
||The client ID to be accepted by the
||The client secret required by the
||The array of valid codes accepted by
You can update this configuration by sending a
PATCH to the
endpoint, which accepts the changes as a JSON patch request. A
GET to the
same endpoint provides the current configuration. You can reset to the default
configuration using a
Alternatively, provide a JSON string as the
variable to override all or part of the initial configuration (note that a
DELETE reset will return to the combination of the hardcoded configuration
above and whatever is provided via this environment variable).