I build websites and authentication/account management systems. In our database, we have an user table that (conceptually) looks
TABLE: USER
id | name | email_address (unique)
====|===========|=========================
88 | Ben Ghazi | bgazi@gmail.com
We wanted to allow Single-Sign-On from Google. So we added a Database table that (conceptually) looks like this:
TABLE: SSO_LINK
id | our_account_id | sso_provider_name | sso_provider_account_id
====|================|===================|=========================
99 | 88 | GOOGLE | xyz983
The row in the above table indicates that if Google account #xyz983 ever tries to login, we should log them in as our user #88.
I'm now implementing Google SSO on a new project from scratch. I'm designing how it will work. I am realizing that perhaps this SSO_LINK table was completely unnecessary. Instead of maintaining a list of linked accounts and checking against it, we could just match the email address that Google provides us. If that email matches any of our users, then simply log that user in. That should work. Right?
However, I suspect that most serious implementation of SSO maintain the SSO_LINK table. What is best practice in this case and why?