https://github.com/stefanbohacek/auth-server
https://github.com/stefanbohacek/auth-server
authentication fediverse miauth oauth
Last synced: 12 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/stefanbohacek/auth-server
- Owner: stefanbohacek
- License: mit
- Created: 2023-03-19T23:32:00.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-19T14:51:54.000Z (6 months ago)
- Last Synced: 2025-03-26T21:06:46.648Z (29 days ago)
- Topics: authentication, fediverse, miauth, oauth
- Language: JavaScript
- Homepage: https://stefanbohacek.com/blog/making-fediverse-apps-for-everyone/
- Size: 95.7 KB
- Stars: 15
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Authentication server
This project is currently under active development and is intended to be self-hosted.
## How to use
Redirect your user to your authentication server while passing the following variables:
- `method`:
- `fediverse`: automatically detect the correct method (oauth or miauth) based on the domain
- `oauth`: tested with Mastodon, Friendica, Pleroma, Akkoma, and GoToSocial
- `miauth`: tested with Misskey and Calckey/Firefish
- `instance`: domain name of the server your user needs to authenticate with (eg. mastodon.social)
- `scope`: required scopes (eg: `scope=read:accounts+read:follows`)
- `app`: id of your app the user will be redirected to (see `modules/apps.js`)Example URL:
```
https://authserver.com/?method=fediverse&instance=mastodon.social&scope=read:accounts+read:follows&app=myapp
```Example URL for fediverse platforms that support OAuth:
```
https://authserver.com/?method=oauth&instance=mastodon.social&scope=read:accounts+read:follows&app=myapp
```Example URL for fediverse platforms that use MiAuth:
```
https://authserver.com/?method=miauth&instance=calckey.social&scope=read:account+read:following&app=myapp
```Your users will be redirect to the app's `redirect_url` (from `modules/apps.js`) with the `instance`
and `token` parameters passed in the URL.```
https://myapp.com?instance=mastodon.social&token=ABCDE12345
```If you're using the automatic `fediverse` method and an error occurs, the user will be instead redirected to `redirect_url_fail` and an `error` parameter will be passed.
Here's an example for when an instance that uses an unsuported fediverse platform is passed:
```
https://myapp.com?error=platform_not_supported
```
## Development1. Install dependencies with `npm install`.
2. Rename `.env-copy` to `.env` and update the contents of this file.```
ENCRYPTION_KEY="random text here to be used as your encryption key"
```3. Update `modules/apps.js`.
You can either redirect the user to your app that requires an authentication token:
```js
"my-app-1": {
"name": "This is my app #1",
"redirect_url": `https://myapp1.com/?instance=${options.instance}&token=${options.access_token}`
}
```Or you can display the token in the browser for the user to copy:
```js
"my-app-2": {
"name": "This is my app #2",
"showToken": true
}
```4. Run the authentication server locally:
```sh
npm run dev
```