Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add Mastodon SSO setup instructions to docs #14594

Merged
merged 17 commits into from
Dec 7, 2022
Merged
1 change: 1 addition & 0 deletions changelog.d/14594.doc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Mastodon and Fediverse Single-Sign On setup instructions for Synapse.
villepeh marked this conversation as resolved.
Show resolved Hide resolved
39 changes: 39 additions & 0 deletions docs/openid.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,42 @@ oidc_providers:
display_name_template: "{{ user.first_name }} {{ user.last_name }}"
email_template: "{{ user.email }}"
```

### Mastodon / Fediverse

Single-Sign On provided by [Mastodon](https://docs.joinmastodon.org/) and other Fediverse websites work with Synapse, provided they have implemented the [Mastodon OAuth API](https://docs.joinmastodon.org/spec/oauth/).
villepeh marked this conversation as resolved.
Show resolved Hide resolved

This example assumes:
* the Mastodon instance website URL is `https://your.mastodon.instance.url/`
* you want to create an App titled *my_synapse_app*

The first step is to create an App using the Mastodon's [Create an application API](https://docs.joinmastodon.org/methods/apps/#create). There are several ways to do this but in the example below we are using CURL.

villepeh marked this conversation as resolved.
Show resolved Hide resolved
Send the following request:
villepeh marked this conversation as resolved.
Show resolved Hide resolved
```sh
curl -d "client_name=my_synapse_app&redirect_uris=https://[synapse_public_baseurl]/_synapse/client/oidc/callback" -X POST https://your.mastodon.instance.url/api/v1/apps
```

You should get the following response, and you should write down:
villepeh marked this conversation as resolved.
Show resolved Hide resolved
```json
{"client_id":"someclientid_123","client_secret":"someclientsecret_123","id":"12345","name":"my_synapse_app","redirect_uri":"https://[synapse_public_baseurl]/_synapse/client/oidc/callback","website":null,"vapid_key":"somerandomvapidkey_123"}
DMRobertson marked this conversation as resolved.
Show resolved Hide resolved
```

As the Synapse login mechanism needs an attribute to uniquely identify users, and that endpoint does not return a sub property, an alternative subject_claim has to be set. Your Synapse configuration should be the following:
villepeh marked this conversation as resolved.
Show resolved Hide resolved

```yaml
oidc_providers:
- idp_id: fediverse
idp_name: "Fediverse Example"
villepeh marked this conversation as resolved.
Show resolved Hide resolved
discover: false
issuer: "https://your.mastodon.instance.url/@admin"
DMRobertson marked this conversation as resolved.
Show resolved Hide resolved
client_id: "someclientid_123"
client_secret: "someclientsecret_123"
authorization_endpoint: "https://your.mastodon.instance.url/oauth/authorize"
token_endpoint: "https://your.mastodon.instance.url/oauth/token"
userinfo_endpoint: "https://your.mastodon.instance.url/api/v1/accounts/verify_credentials"
scopes: ["read"]
user_mapping_provider:
config:
subject_claim: "id"
villepeh marked this conversation as resolved.
Show resolved Hide resolved
```
villepeh marked this conversation as resolved.
Show resolved Hide resolved