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

Make Synapse support username availability check #3605

Closed
lampholder opened this issue Apr 11, 2017 · 5 comments
Closed

Make Synapse support username availability check #3605

lampholder opened this issue Apr 11, 2017 · 5 comments
Assignees
Milestone

Comments

@lampholder
Copy link
Member

The details of the new guest experience for Riot are on the project plan: element-hq/riot-meta#59

I believe there are design decision reasons why this hasn't been implemented in the past. I'd like us to consider this because picking an available username is particularly tedious if checking availability isn't as painless as possible.

The scope of this task would be to deliver an API in Synapse that can be called to check username availability.

@ara4n - what are your thoughts on this existing?

@ara4n
Copy link
Member

ara4n commented Apr 23, 2017

sounds great to me. i'd expect the auth stuff would give us an API we could already prod for this...

@ara4n ara4n added S-Tolerable Low/no impact on users P2 and removed X-Needs-Info This issue is blocked awaiting information from the reporter labels Apr 23, 2017
@lampholder lampholder added this to the RW003 milestone Apr 24, 2017
@lukebarnard1 lukebarnard1 changed the title Improve Landing as Guest: Make Synapse support username availability check Make Synapse support username availability check Apr 25, 2017
@lukebarnard1
Copy link
Contributor

lukebarnard1 commented May 2, 2017

i'd expect the auth stuff would give us an API we could already prod for this...

Not quite true. We'll have to write a simple API for Synapse that does a SELECT in whichever table stores user IDs.

The API could look like

GET /_matrix/.../register/available
{
    "username" : "mylovelyusername"
}

Available looks like:

HTTP/1.1 200 OK
{
    "available" : true
}

Unavailable looks like

HTTP/1.1 400
User ID already taken

This would require modifying rest/client/v2_alpha/register.py to include this new endpoint. The endpoint could then hit check_username from handlers/register.py and if no errors are thrown, return the success response.

Rate limiting would have to be quite heavy so as to prevent people iterating over mxids.

@lukebarnard1 lukebarnard1 self-assigned this May 2, 2017
@Half-Shot
Copy link
Member

Half-Shot commented May 2, 2017

Could username be exchanged for any other field? If I wanted to see if a phone number was taken or something like that. Perhaps even allowing /avaliable to take multiple fields?

Jumped to conclusions about the purpose of the API. Ignore me :)

@erikjohnston
Copy link
Member

To what extent do we want to stop people from being able to iterate over lists of mxids? We probably want to have quite aggressive ratelimiting on the endpoint at least.

@lukebarnard1
Copy link
Contributor

lukebarnard1 commented May 2, 2017

Yep, it would be heavily rate-limited, I forgot to mention that.

lukebarnard1 pushed a commit to matrix-org/synapse that referenced this issue May 3, 2017
Outlined here: element-hq/element-web#3605 (comment)

```HTTP
GET /_matrix/.../register/available
{
    "username": "desiredlocalpart123"
}
```

If available, the response looks like
```HTTP
HTTP/1.1 200 OK
{
    "available": true
}
```

Otherwise,
```HTTP
HTTP/1.1 429
{
    "errcode": "M_LIMIT_EXCEEDED",
    "error": "Too Many Requests",
    "retry_after_ms": 2000
}
```
or
```HTTP
HTTP/1.1 400
{
    "errcode": "M_USER_IN_USE",
    "error": "User ID already taken."
}

```
or
```HTTP
HTTP/1.1 400
{
    "errcode": "M_INVALID_USERNAME",
    "error": "Some reason for username being invalid"
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants