Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping the existing Keycloak user to the existing synapse user, avoiding the creation of a new user #17472

Open
mohammadll opened this issue Jul 22, 2024 · 1 comment

Comments

@mohammadll
Copy link

Description

I have integrated Keycloak with Matrix Synapse, and the integration appears to be working correctly. However, I am encountering an issue with user mapping. Specifically, I want to map my existing Synapse users to their corresponding Keycloak users. When I attempt to log in using Keycloak, it seems to try to create a new user instead of mapping to the existing one. For instance, I have a user named mohammad in both Synapse and Keycloak, but when I log in with Keycloak, Synapse attempts to create a new user with a username like @mohammad1:matrix.myorg.com instead of mapping to the existing mohammad user.

My current Configuration:

oidc_providers:
  - idp_id: keycloak
    idp_name: "KeyCloak"
    issuer: "https://keycloak.example.com/realms/synapse"
    client_id: "synapse"
    client_secret: "9ejtUop8PUJh43weYtN8jGVBjGXwFFghVt"
    scopes: ["openid", "profile"]
    user_mapping_provider:
    config:
        localpart_template: "{{ user.preferred_username }}"
        display_name_template: "{{ user.name }}"

Steps to reproduce

  • Configured synapse client in keycloak
  • added a new block called oidc_providers within my homeserver.yaml
  • Restarted Docker-compose to apply new changes

Homeserver

matrix.myorg.com

Synapse Version

1.107.0

Installation Method

Docker (matrixdotorg/synapse)

Database

PostgreSQL

Workers

Single process

Platform

Running through Docker-Compose

Configuration

No response

Relevant log output

2024-07-22 17:39:05,701 - synapse.handlers.sso - 376 - INFO - GET-417 - Found existing mapping for IdP 'oidc-keycloak' and remote_user_id '77a8078a-5f24-4ae1-2195-a9c15f2fbe17': @mohammad1:matrix.myorg.com

Anything else that would be useful to know?

No response

@nitesh-habilelabs
Copy link

nitesh-habilelabs commented Jul 29, 2024

hi @mohammadll , i am also trying to login into matrix using keycloak….
but i am getting issue “M_FORBIDDEN: MatrixError: [403] Invalid login token (https://testmatrix.org.com/_matrix/client/v3/login)”

i have setup oidc_providers in matrix homeserver.yaml

can you please help

Edit - i already implemented login with keycloak into matrix and it works fine if i use element web but i need to integrate it in react native and i don’t want to use react native web.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants