Order of OIDC multiple account list

yakatz9

Well-Known Member
Mar 16, 2010
73
9
58
cPanel Access Level
DataCenter Provider
We use cPanel for academic projects in a university department.
We recently changed to require all of our cPanel users to log in with OIDC to our university authentication system (and we pre-register the users). This allows easy access and adds Multi-Factor Authentication. When users have multiple linked cPanel accounts, it seems like the accounts show up in a random order and it changes on every login. Is there any way to make it always show up in the same order, preferably alphabetical?

During the transition period, we also noticed that the OIDC buttons on the login page also change order randomly.

Both of those annoy users and break muscle-memory.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
13,382
2,106
363
cPanel Access Level
Root Administrator
Hey there! Just so we're on the same page, we're talking about this tool, correct?

 

yakatz9

Well-Known Member
Mar 16, 2010
73
9
58
cPanel Access Level
DataCenter Provider
Hey there! Just so we're on the same page, we're talking about this tool, correct?

Yes, but it applies to the built-ins like cPanelID and Google too. I submitted a Feature Request that had screenshots showing the issue with Log in with Google, but it is still in moderation and I no longer have the screenshots.
 

yakatz9

Well-Known Member
Mar 16, 2010
73
9
58
cPanel Access Level
DataCenter Provider
So the feature request is marked as "Not Planned". I finally got annoyed and checked what would be involved in making this happen - we are talking about a one or two line code change to make the users be always sorted alphabetically...

I know cPanel isn't open source, but I'm just going to put what I did here and hope in gets added. In the mean time, I will just make the change on my own servers (and fix it every time there is an update).

In the file /usr/local/cpanel/Cpanel/Server/Handlers/OpenIdConnect.pm, in _handle_openid_need_to_select_user (line 441 for me), just before the call to show the login page, I added:
Perl:
my $linked_users_sorted;
@{$linked_users_sorted} = sort { $a->{username} cmp $b->{username} } @{$linked_users_};
and just below that
Perl:
'linked_users'                 => $linked_users_sorted,
It looks like the same code could be used for a simple alphabetical sort for the providers in /usr/local/cpanel/Cpanel/Security/Authn/OpenIdConnect.pm, in get_available_openid_connect_providers.
 
Last edited:

yakatz9

Well-Known Member
Mar 16, 2010
73
9
58
cPanel Access Level
DataCenter Provider
I see "Fixed case CPANEL-40510: Sort authentication providers on login page." in the EDGE release notes. Is that talking about this?