According to the phpbb developer wiki it is possible to write authentication plugins that use a custom user_id instead of the default sequence.
I did write an authentication plugin that uses an external id as user_id and removed the sequence from the user_id column in the phpbb_users table.
Here the code I use to generate a user_row returned by the login function of my authentication plugin upon successful authentication:
And indeed user profiles can be created using a custom user_id, but
unfortunately the group is not set correctly.
When looking into the phpbb_user_group table I realized that all new entries did look like the following rows:
As you can see the user_id column was always 0.
This pointed me to look into the add_user function to find the error.
It turns out that the add_user function ignores the user_id field in $user_row when adding the entry to the USER_GROUP_TABLE.
Instead it was using $db->sql_nextid() as user_id value, which is obviously fine when using the generated user_ids, but when using external ids breaks the link between user and group.
Here the questionable snippet from the add_user function: