How to import pre-sso discourse users?

To clarify: There is no difference between “SSO users” and “regular users”.

The only difference is in whether Discourse knows the external id of the user. When logging in a users, Discourse proceeds like this:

  1. Do I know a user with this external id? If so, log him in, and possibly update his email.
  2. Otherwise, do I know a user with this email? If so, remember his external id, and log him in.
  3. Otherwise, create a new account.