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

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

Closed
qalqi opened this issue May 30, 2020 · 1 comment
Closed

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

qalqi opened this issue May 30, 2020 · 1 comment
Labels
z-bug (Deprecated Label) z-p2 (Deprecated Label)

Comments

@qalqi
Copy link

qalqi commented May 30, 2020

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
                )
@qalqi qalqi changed the title jwt token for new user is not registering but, does login only jwt token is not registering but, does login only May 30, 2020
@erikjohnston erikjohnston added z-bug (Deprecated Label) Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p2 (Deprecated Label) labels Jun 1, 2020
@erikjohnston
Copy link
Member

erikjohnston commented Jun 1, 2020

This looks like it will be fixed by #7585

@erikjohnston erikjohnston removed the Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution label Jun 1, 2020
@clokep clokep closed this as completed Jun 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
z-bug (Deprecated Label) z-p2 (Deprecated Label)
Projects
None yet
Development

No branches or pull requests

3 participants