feat(authentication): [DRAFT] Refactor Authentication and add Facebook Login#6720
feat(authentication): [DRAFT] Refactor Authentication and add Facebook Login#6720Neilk1021 wants to merge 24 commits into
Conversation
…lusion of front end components I forgot to add to the VCS.
# Conflicts: # config-service/src/test/scala/org/apache/texera/service/resource/ConfigResourceAuthSpec.scala # sql/changelog.xml
Automated Reviewer SuggestionsBased on the
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6720 +/- ##
==========================================
Coverage 74.65% 74.66%
+ Complexity 3438 3434 -4
==========================================
Files 1160 1165 +5
Lines 45793 45979 +186
Branches 5069 5085 +16
==========================================
+ Hits 34189 34328 +139
- Misses 9953 9988 +35
- Partials 1651 1663 +12
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
| config | throughput | MB/s | latency | max Δ latest / 7d | |
|---|---|---|---|---|---|
| 🔴 | bs=10 sw=10 sl=64 | 393 | 0.24 | 23,854/33,467/33,467 us | 🔴 +100.7% / 🔴 +111.6% |
| 🔴 | bs=100 sw=10 sl=64 | 792 | 0.483 | 127,499/153,267/153,267 us | 🔴 +56.6% / 🔴 +46.0% |
| 🔴 | bs=1000 sw=10 sl=64 | 916 | 0.559 | 1,099,026/1,123,124/1,123,124 us | 🔴 +22.8% / 🔴 +14.0% |
Baseline details
Latest main 0467c76 from 2026-07-21T13:20:34.790Z
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 393 tuples/sec | 802.41 tuples/sec | 769.76 tuples/sec | -51.0% | -48.9% |
| bs=10 sw=10 sl=64 | MB/s | 0.24 MB/s | 0.49 MB/s | 0.47 MB/s | -51.0% | -48.9% |
| bs=10 sw=10 sl=64 | p50 | 23,854 us | 11,884 us | 12,663 us | +100.7% | +88.4% |
| bs=10 sw=10 sl=64 | p95 | 33,467 us | 16,737 us | 15,813 us | +100.0% | +111.6% |
| bs=10 sw=10 sl=64 | p99 | 33,467 us | 17,893 us | 19,001 us | +87.0% | +76.1% |
| bs=100 sw=10 sl=64 | throughput | 792 tuples/sec | 1,086 tuples/sec | 1,009 tuples/sec | -27.0% | -21.5% |
| bs=100 sw=10 sl=64 | MB/s | 0.483 MB/s | 0.663 MB/s | 0.616 MB/s | -27.1% | -21.6% |
| bs=100 sw=10 sl=64 | p50 | 127,499 us | 91,919 us | 99,444 us | +38.7% | +28.2% |
| bs=100 sw=10 sl=64 | p95 | 153,267 us | 97,845 us | 105,012 us | +56.6% | +46.0% |
| bs=100 sw=10 sl=64 | p99 | 153,267 us | 105,973 us | 116,467 us | +44.6% | +31.6% |
| bs=1000 sw=10 sl=64 | throughput | 916 tuples/sec | 1,112 tuples/sec | 1,044 tuples/sec | -17.6% | -12.3% |
| bs=1000 sw=10 sl=64 | MB/s | 0.559 MB/s | 0.679 MB/s | 0.637 MB/s | -17.6% | -12.3% |
| bs=1000 sw=10 sl=64 | p50 | 1,099,026 us | 894,788 us | 964,034 us | +22.8% | +14.0% |
| bs=1000 sw=10 sl=64 | p95 | 1,123,124 us | 953,590 us | 1,007,497 us | +17.8% | +11.5% |
| bs=1000 sw=10 sl=64 | p99 | 1,123,124 us | 988,019 us | 1,040,936 us | +13.7% | +7.9% |
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,508.29,200,128000,393,0.240,23854.01,33466.88,33466.88
1,100,10,64,20,2525.22,2000,1280000,792,0.483,127499.01,153266.59,153266.59
2,1000,10,64,20,21832.22,20000,12800000,916,0.559,1099026.01,1123124.23,1123124.23|
Please separate the consolidated login page, the authentication refactor, and the Facebook Login implementation into three separate PRs. These changes are independent and can be developed and reviewed separately without any dependencies on one another. |
What changes were proposed in this PR?
Refactors authentication to decouple identity from credentials: all auth material moves out of the
"user"table into a dedicatedauth_providertable, external-provider login (Google, Facebook) is unified behind a single provisioning path, and Facebook OAuth is added as a new login option.Schema split — new
auth_providertable. The"user"table dropspassword,google_id,google_avatar, and the oldck_nulltestCHECK, and gains a provider-neutralavatarcolumn. A newprovider_type_enum ('LOCAL','GOOGLE','FACEBOOK')andauth_provider (uid, provider_type, provider_id, password, created_at)table are added, withPRIMARY KEY (uid, provider_type), an FK to"user"(uid) ON DELETE CASCADE,uq_provider_identity UNIQUE (provider_type, provider_id), andck_provider_credential(LOCAL ⇒ password set / provider_id null; non-LOCAL ⇒ provider_id set / password null) replacingck_nulltest. Liquibase migrationsql/updates/29.sql(registered insql/changelog.xml) creates the enum + table and backfillsLOCALrows fromuser.passwordandGOOGLErows fromuser.google_id. The jOOQAuthProvidertable/dao/pojo andProviderTypeEnumare regenerated from the new DDL.Shared
ExternalAuthProvisionerabstraction. Newobject ExternalAuthProvisionerthat both Google and Facebook login route through. Given anExternalProfile(providerType, providerId, name, email, avatar: Option[String]),loginOrProvisionruns a single transaction that resolves the user by provider identity → else by email → else creates anINACTIVEuser, then upserts the provider row (guarding the(uid, provider_type)PK against collision) and refreshesname/email/avatar.avataris optional so a Facebook login (no avatar) never clobbers an avatar set by Google.Facebook OAuth (new).
FacebookAuthResourceat/auth/facebook(GET /clientid,POST /login) verifies the access token via the Graph APIdebug_token+/meendpoints, falling back to{id}@facebook.localwhen Facebook returns no email. Config gainsfacebook.clientId/facebook.appSecret(envsUSER_SYS_FACEBOOK_CLIENT_ID/USER_SYS_FACEBOOK_APP_SECRET) with matchingUserSystemConfigaccessors.Google + local login retargeted to the new schema.
GoogleAuthResourcedrops its inline DAO logic and delegates toExternalAuthProvisioner. Local login (AuthResource) now joinsauth_provideronPROVIDER_TYPE = LOCALand checks the hashed password there; registration and admin bootstrap write theuserrow + aLOCALprovider row atomically via a new privateInsertUser.AdminUserResource/UserResourceand related resources rebindavatarontouser.JWT claims simplified.
JwtAuth.jwtClaimsemits a singleavatarclaim instead ofgoogleId/googleAvatar;JwtParserandSessionUserare updated to match (SessionUser.getGoogleIdremoved), constructingUservia setters rather than the old positional constructor.Frontend. New consolidated login page (
texera-login.component) with tabbed local sign-in/sign-up plus Google and Facebook buttons; newFacebookAuthService; theUsertype andauth.serviceJWT decode swapgoogleId/googleAvatarforavatar;app.moduleregisters aFacebookLoginProvideralongside Google, resolving both client ids in parallel.Tests. New:
ExternalAuthProvisionerSpec(embedded-Postgres integration over the full provisioning matrix),facebook-auth.service.spec.ts,texera-login.component.spec.ts. Updated:JwtAuth/JwtParser/SessionUser/UserAuthenticatorspecs for the avatar-claim change, plus a repo-wide sweep droppinguser.setPassword(...)from existing specs to match the new schema.Any related issues, documentation, discussions?
Closes #6718. The design rationale and coupling points that drove this split (the
jwtClaimsprovider fields, theck_nulltestCHECK, the DAO-per-resource pattern, and the frontendUsershape) are documented inauth-split-notes.md. No other tracked issues.How was this PR tested?
Auth-specific suites were run and are green:
sbt, ScalaTest):ExternalAuthProvisionerSpecruns against embedded Postgres (MockTexeraDBloads the realsql/texera_ddl.sql, so theauth_providerconstraints are live) — 7/7, covering new-identity provisioning, returning-identity idempotency, profile refresh, the Facebook-avatar-not-clobbered case, email-match linking, and provider-id upsert.JwtAuthSpec— 5/5, including the newavatarclaim.ng test/ Vitest):facebook-auth.service.spec.ts+texera-login.component.spec.ts— 22/22, covering local login/register validation and navigation, social sign-in routing (Google vs Facebook), the confirm-password validator, and error paths.Commands:
A full
sbt clean compile test+ complete frontend suite run is still recommended before merge (the schema-matching spec sweep touches many modules).Was this PR authored or co-authored using generative AI tooling?
Yes. This PR was co-authored with Claude Opus 4.8. The overall architecture and design decisions were the author's; Claude assisted with implementing much of the code and the accompanying tests.