GithubHelp home page GithubHelp logo

joshuaboniface / matrix-synapse-rest-password-provider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ma1uta/matrix-synapse-rest-password-provider

0.0 2.0 0.0 44 KB

Password Provider for Synapse fetching data from a REST endpoint

License: GNU Affero General Public License v3.0

Python 100.00%

matrix-synapse-rest-password-provider's Introduction

Synapse REST Password provider

Overview

This synapse's password provider allows you to validate a password for a given username and return a user profile using an existing backend, like:

  • Forums (phpBB, Discourse, etc.)
  • Custom Identity stores (Keycloak, ...)
  • CRMs (Wordpress, ...)
  • self-hosted clouds (Nextcloud, ownCloud, ...)

It is mainly used with ma1sd, the Federated Matrix Identity Server, to provide missing features and offer a fully integrated solution (directory, authentication, search).

NOTE: This module doesn't provide direct integration with any backend. If you do not use mxisd, you will need to write your own backend, following the Integration section. This module simply translate an anthentication result and profile information into actionables in synapse, and adapt your user profile with what is given.

Install

Copy in whichever directory python can pick it up as a module.

sudo pip install git+https://github.com/ma1uta/matrix-synapse-rest-password-provider

If the command fail, double check that the python version still matches. If not, please let us know by opening an issue.

Configure

Add or amend the modules entry like so:

modules:
  - module: "rest_auth_provider.RestAuthProvider"
    config:
      endpoint: "http://change.me.example.com:12345"

Set endpoint to the value documented with the endpoint provider.

NOTE: This requires Synapse 1.46 or later! If you migrate from the legacy password_providers, make sure to remove the old RestAuthProvider entry. If the password_providers list is empty, you can also remove it completely or comment it out.

Use

  1. Install, configure, restart synapse
  2. Try to login with a valid username and password for the endpoint configured

Next steps

Lowercase username enforcement

NOTE: This is no longer relevant as synapse natively enforces lowercase.

To avoid creating users accounts with uppercase characters in their usernames and running into known issues regarding case sensitivity in synapse, attempting to login with such username will fail.

It is highly recommended to keep this feature enable, but in case you would like to disable it:

    config:
      policy:
        registration:
          username:
            enforceLowercase: false

Profile auto-fill

By default, on first login, the display name is set to the one returned by the backend.
If none is given, the display name is not set.
Upon subsequent login, the display name is not changed.

If you would like to change the behaviour, you can use the following configuration items:

    config:
      policy:
        registration:
          profile:
            name: true
        login:
          profile:
            name: false

3PIDs received from the backend are merged with the ones already linked to the account. If you would like to change this behaviour, you can use the following configuration items:

    config:
      policy:
        all:
          threepid:
            update: false
            replace: false

If update is set to false, the 3PIDs will not be changed at all. If replace is set to true, all 3PIDs not available in the backend anymore will be deleted from synapse.

Integrate

To use this module with your back-end, you will need to implement a single REST endpoint:

Path: /_matrix-internal/identity/v1/check_credentials
Method: POST
Body as JSON UTF-8:

{
  "user": {
    "id": "@matrix.id.of.the.user:example.com",
    "password": "passwordOfTheUser"
  }
}

If the credentials are accepted, the following JSON answer will be provided:

{
  "auth": {
    "success": true,
    "mxid": "@matrix.id.of.the.user:example.com",
    "profile": {
      "display_name": "John Doe",
      "three_pids": [
        {
          "medium": "email",
          "address": "[email protected]"
        },
        {
          "medium": "msisdn",
          "address": "123456789"
        }
      ]
    }
  }
}

auth.profile and any sub-key are optional.


If the credentials are refused, the following JSON answer will be provided:

{
  "auth": {
    "success": false
  }
}

matrix-synapse-rest-password-provider's People

Contributors

maxidorius avatar ma1uta avatar peerd avatar davidmehren avatar halkeye avatar devplayer0 avatar joshuaboniface avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.