This repository demonstrates how to integrate Authlete, an "Identity Component as a Service," with Supertokens, acting as an "Authentication Component." Authlete serves as the OAuth/OIDC compliant token issuer in this scenario.
The sample project showcases the integration of Authlete with Supertokens using the Authlete Node SDK. The SDK facilitates easy integration into the Node.js Express framework.
Before running the sample, ensure you have the following installed:
- Node.js
- Authlete Node SDK (Currently embedded in the sample)
To set up the project, follow these steps:
- Clone this repository to your local machine.
- Install dependencies using
npm install
. - Extend the Supertokens project to use the Authlete Node SDK.
- Integrate the SDK into the Node.js Express framework as follows:
import { createDefaultBackend, useSuperTokenAuthentication } from "./lib";
// Configure authentication handler
const authenticationHandler = useSuperTokenAuthentication(getWebsiteDomain());
// Create default backend with authentication handler
const defaultBackend = createDefaultBackend(authenticationHandler);
// Mount backend on the app
app.use(defaultBackend);
Authlete requires the redirect_uri
to use HTTPS. Even localhost without HTTPS is not allowed. Therefore, to run the Authlete sample, we need to set up a reverse proxy like Caddy.
brew install caddy
Ensure that you have a Caddyfile
configured properly in the same directory where you'll run Caddy.
caddy run
This setup will proxy https://localhost
to the backend server, allowing the Authlete sample to run with the required HTTPS redirect URI.