Autogenerated username using Google OpenID

How can I get the user’s username to be their full name or email address when using OpenID set to Google? It is generating these random name.

±—±--------------------------+
| ID | USERNAME |
±—±--------------------------+
| 2 | supposedly-divine-dane |
| 3 | awfully-new-quagga |
| 4 | terribly-integral-asp |
| 5 | personally-steady-spaniel |
| 6 | inherently-literate-fly |
| 8 | easily-prime-shrimp |
| 14 | unlikely-noted-gopher |
±—±--------------------------+

Hi, a very similar question has been answered recently and I’ve added details to the documentation.

In essence, you need to make sure that the preferred_username claim is included either in ID token or when querying the /userinfo endpoint.

I have read it and still not sure how to do it since I am using Google and not Authentik. How can I create a custom scope mapping on Vikunja side? I would just like to set the username to their email address.

You cannot do custom mapping in Vikunja currently. It will use the preferred_username claim as username, if that’s not available it will autogenerate one. Note that the preferred_username claim is part of the standard profile scope (see OpenID standard).

Is is also highlighted in the documentation:

Sets the username of the user. Taken from the userinfo endpoint if not present in ID token. If this also doesn’t contain the claim, use the nickname claim from userinfo instead. If that one is not available either, the username is auto-generated by Vikunja.

I’m not too familiar with what Google can do, based on some quick tests with their OAuth playground I could not find an easy way to include the preferred_username claim. As this is optional, that’s fine from a standard perspective, but doesn’t work particularly well with Vikunja.

Unless you find another option to include the claim, there’s currently no way to set the username to something more meaningful. It would probably make sense to make the claim configurable

1 Like

Vikunja should also use the name from the openid provider as display name. Does it do that in your case?

Using Google OAuth, the display name and email fields are correct. The only issue I have is with the username begin random generated. This makes it hard for people to search. Even with the option to allow searching by name or email address, the search result is by username. With a user name as easily-prime-shrimp, it is hard to know that is John Doe.

That sounds like a bug. Can you reproduce this on try?

I tried it and the search returns back their user name when you search by user name, email, or full name. This is not a problem when your user name make sense. However when the user name is some random auto generated names, it doesn’t help. Maybe the return back should include their email address, in addition to their user name. Example. easily-prime-shrimp (johndoe@email.com)

I do have a work around this by directly changing their username in the database with their email using this sql statement

.

update users set username=email where username <> email;

IMHO it should not return the email address. This would give other users the option to find out mail addresses of other users which they may not want to have exposed. Maybe the display name could be returned?

The api doesn’t even return the email address (for good reason and by desing) so it’s not possible to show them in the frontend.

I tried this with the last unstable build on try and it showed the display name. Here’s what I did:

  1. Set the display name in the settings to something else than the username
  2. open a task
  3. Click on “assign” or press a
  4. In the task dropdown, the user shows up with the display name

Can you reproduce it with those steps?

The “Assign to user” in a card is showing their Display Name. No issue at this level.

The area I am referring to is at the Project’s Share screen > “Shared with these users”. The search is using username, which is not helpful when they are auto-generated names.

Gotcha, that’s a bug. The user search should use the displayname everywhere. Will take a look.

This is now fixed in bf5088e546. Please check with the next unstable build (ready in ~45min, also on try by then).

I installed the latest unstable version of Vikunja, version v0.23.0+438-f0d695e789

The problem is still there where the username is returned back in the Shared this project. I have uploaded pictures to make this easier to understand. 2nd picture is the output of the users table under mysql. 1st picture is where I typed in the user’s display name and it returns back their user name. If we have multiple users with Mike, it would be hard to tell which one is the correct user by their username.


I cannot confirm that based on the same version Version: v0.23.0+438-f0d695e789. Its showing the display name for me

Does it work in a private browser tab?

Just noticed the front-end web interface was still on the old version. I have to restart the vikunja service and it is now displaying the display name instead of user name. I am all good now. Thank you!

1 Like