For a fully working example, checkout the serverless-indieauth repository which provides a basic working example for an IndieAuth server using Netlify functions.
npm install @benjifs/indieauth
import { AuthHandler } from '@benjifs/indieauth'
const { SECRET, PASSWORD_SECRET } = process.env
export const indieauth = new AuthHandler({
secret: SECRET,
passwordSecret: PASSWORD_SECRET,
})
export default async (req) => indieauth.authorizationEndpoint(req)The following variables are needed in order to create the access tokens and authenticate:
A random generated string which will be used to create the access token. You can generate it with:
openssl rand -hex 16- Generate a random string
Your password hashed with bcrypt. To do so you can either:
htpasswd -bnBC 10 "" toomanysecrets | cut -d : -f 2where "toomanysecrets" is the password- Use this website to create the hash
- create - create posts
- update - update existing posts
- delete - delete posts
- media - upload assets to your media endpoint
- profile - share basic profile data
- email - share your email address