Migration of Gerrit users to link Azure AD users

297 views
Skip to first unread message

Kamil Kwiaton

unread,
Jul 28, 2022, 2:11:01 PM7/28/22
to Repo and Gerrit Discussion

Hello!

For Azure AD authentication Im using this provider: https://github.com/davido/gerrit-oauth-provider
Im currently in proces of implementing Azure AD login to my different tools. As I'm using Gerrit I'm trying to also implement it there, but I found one issue which is stopping me. I have around 15 users in Gerrit which are using it daily, all of them have Azure AD account. When I login with users which did not have account before, new users is created, great!

But when I tried to login with user which exist I got this error:

Unable to authenticate user "com.google.gerrit.extensions.auth.oauth.OAuthUserInfo@3bdcd754" com.google.gerrit.server.account.AccountException: Email 'exa...@email.com' in use by another account

So I change that user email, but then complete new user is created. It is not liked as I though it will do. Probably there is some identity difference, as I see normaly user have some identity like name.surname and Azure AD have whole clientID number from Azure?

Do you know if there is a way to migrate user, or maybe manually swap their identity? I don't have much knowledge how to even change that identity cause Gerrit don't have any members UI...

Kamil Kwiaton

unread,
Aug 17, 2022, 8:52:11 PM8/17/22
to Repo and Gerrit Discussion

Steps below if someone have same problem :)

Clone All-Users repo:
git clone "https://gerrit.example.com/a/All-Users"

Add rights to Admin group:

[capability]    accessDatabase = group Administrators
[access "refs/meta/*"]    push = +force group Administrators    forgeAuthor = group Administrators    forgeCommitter = group Administrators

Go to All-Users folder which you clone and do some git magic:

git fetch origin refs/meta/external-ids:refs/meta/external-ids
git checkout refs/meta/external-ids

Get new user ID via Rest API or user can tell you his ID and search it:

git grep -e 1000023

Edit file which you searched and changed accountId to the one you want to link with this externatId
Push changed to repo:

git add -A git commit --signoff git push origin HEAD:refs/meta/external-ids

Poonam Shinde

unread,
Jul 10, 2023, 6:25:22 AM7/10/23
to Repo and Gerrit Discussion
Hello Kamil,

Is your azure AD authentication work?

Thanks 
Poonam

Reply all
Reply to author
Forward
0 new messages