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

jwt token is not registering but, does login only #7604

@qalqi

Description

@qalqi

Description

jwt token is not registering new user. but, can login with jwt for m.login.jwt

Bug is here. As, user_id being overwritten with None and calling UserID.from_string(None).localpart

user_id = await self.auth_handler.check_user_exists(user_id)

localpart=UserID.from_string(user_id).localpart

Steps to reproduce

  1. Enable jwt token
jwt_config:
   enabled: true
   secret: "a secret"
   algorithm: "HS256"
  1. Generate a jwt token at HTTP://jwt.io
let cheeky_monkey_jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJjaGVla3lfbW9ua2V5IiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.qDmRJP1eZSKJsrq9fGI1qiOXT-ZDqTdgD4E8TN6oJ-A"

  1. Call using matrix-js-sdk
import Matrix from "matrix-js-sdk";

 const tempClient = Matrix.createClient({ baseUrl: hsUrl });

    let callback = (data) => console.log('login callback: ', data);
    const data = await tempClient.login(
        'm.login.jwt',
        {
            token: cheeky_monkey_jwt,
        },
        callback
    ).catch(console.log);
    const matrixClient = Matrix.createClient({
        baseUrl: hsUrl,
        accessToken: data.access_token,
        userId: data.user_id,
    });
    await matrixClient.startClient();

Version information

  • Homeserver:

If not matrix.org:

  • Version:
    1.14.0, Commit: 91a7c5ff6d3a4bc30d61da96e4923d391c6d2ed9
  • Install method:
    git clone
  • Platform:
    ubuntu 16

Fix is simple gotcha

        if create_non_existant_users:
            user_exists = await self.auth_handler.check_user_exists(user_id)
            if not user_exists :
                user_id = await self.registration_handler.register_user(
                    localpart=UserID.from_string(user_id).localpart
                )

Metadata

Metadata

Assignees

No one assigned

    Labels

    z-bug(Deprecated Label)z-p2(Deprecated Label)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions