- Authenticate users with email.
- Restrict the email domain(s) / pattern(s) of the users.
- Support multiple applications.
- Asymmetric JWT signing.
- Fully serverless.
- A developer dashboard for managing applications.
- A public showboard for each developer.
Using PEA, all of your users' email addresses are verified by nature.
You can use D1 Manager to manage the underlying D1 database.
Requirements:
- A Cloudflare account (with a domain, so we can send emails)
- A Cloudflare D1 database
- Execute the SQL in here in your D1 database to create the tables.
- Fork this repository.
- Create a new Cloudflare Pages project with the forked repository.
- Setup the environment variables and D1 binding (
D1) in the Cloudflare Pages project. - Trigger
/api/sys/setupto check if the setup is successful.
PEA uses environment variables for some configurations.
| Name | Description | Example |
|---|---|---|
PEA_APP_EMAIL |
The email address of the system use for sending email. | [email protected] |
After creating an application on PEA, you can use the provided login page or the API to authenticate users.
The provided login page is located at /app/<your-app> and you can use the cb query parameters to customize the callback URL, for example /app/your-app?cb=https://your.app/callback/url.
You can also use the API to authenticate users. The API is located at /api/app/<your-app>/login and you can use the callback field in the request body to customize the callback URL.
curl -X POST \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "callback": "https://your.app/callback/url"}' \
https://pea.csie.cool/api/app/your-app-id/loginThen, PEA will send an email to the user with the callback URL and a JWT token in the following format:
https://your.app/callback/url?token=<JWT_TOKEN>Both methods require the callback URL matches the pattern in the application settings.
You can verify the JWT token using the public key provided by PEA.
Follows the JWT standard, the JWK sets can be found at jku field in the JWT token header.
{
"jku": "https://pea.csie.cool/jwks.json"
}Every JWT library should be able to verify the JWT token using the JWK sets.
If you are using SvelteKit, you can use the
sveltekit-jwtpackage to verify the JWT token.
### For Users
1. Open the application you want to log in to.
2. Enter your email address and click the login button (or something similar).
3. Receive an email from PEA and click the link in the email.
4. Done! You are now logged in to the application.