GitHub user Neilk1021 added a comment to the discussion: Proposal - Migrating 
User Authentication to a new table to support multiple log-in sources.

@carloea2 @Yicong-Huang correcting myself, my last comment was wrong; 
provider_id should not be merged into secret. Let me answer directly.

**What is provider_id?** It's the stable id the provider assigns to the user's 
account there. For Google that's the `sub` claim, for Facebook it's the 
app-scoped user id. It's public. It shows up inside the ID token we hand to the 
browser, and both providers document it as safe to store and key lookups on:

- Google: "Only use the Google ID token's `sub` field as the unique identifier 
for the user... don't use email address as an identifier because a Google 
Account can have multiple email addresses at different points in time." 
(https://developers.google.com/identity/gsi/web/guides/verify-google-id-token)
- Facebook: app-scoped user ids are issued on first login to an app instance 
and stay stable for that app going forward. 
(https://developers.facebook.com/docs/facebook-login/guides/map-users)

Our own GoogleAuthResource already treats it this way: `payload.getSubject` is 
read *after* `verify(credential)` succeeds, then used to look up or provision 
the uid. It's an identifier for a completed lookup, not something that gets 
checked. The actual verification is the signature check against Google's JWKS 
inside `verify()`.

**Is email just metadata?** Yes, it's not used for auth lookups, useful for 
password recovery / contact later. This is why its its on the user table and 
not the auth table. 

**Is provider_id = email for local?** For local, provider_id should be whatever 
field we authenticate by, so following the current implementation, this would 
be the username. Provider_id and secret can't merged because they represent 
different things and I mistook provider_id as the credential when it's just the 
signed.

So:

```
auth_provider
  uid            FK -> user
  provider_type  'local' | 'google' | 'facebook' | ...
  provider_id    login handle/email for local, sub/ASID for oauth
  secret         password hash for local, NULL for oauth
  created_at
  PRIMARY KEY (uid, provider_type)
  UNIQUE (provider_type, provider_id)
```

Sorry for the back-and-forth on this, the original two-column split in the 
diagram (provider_id + password, separate) was correct, I talked myself out of 
it and shouldn't have.

GitHub link: 
https://github.com/apache/texera/discussions/6716#discussioncomment-17802067

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to