feat: Switch to using kf-auth#3613
Open
isTravis wants to merge 10 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces PubPub's local password authentication with KF Auth via OIDC, adds community ownership via KF orgs, and exposes internal service-to-service APIs that KF Auth and KF Hubs consume.
What this does
Authentication — OIDC flow replacing local passwords
GET /auth/login— redirects to KF Auth with PKCE, encoding the community hostname + return path instateso we can redirect back across subdomains/custom domains after callbackGET /auth/callback— exchanges the code, upserts the User record from KF Auth's userinfo, creates an Express session, then redirects to the originating communityPOST /auth/logout— destroys local session + redirects to KF Auth's signout relayGET /sign-up,GET /login,GET /password-reset— thin redirects to the corresponding KF Auth pages withclient_idpre-filledCommunity ownership (
kfOrgId)kfOrgId TEXTcolumn onCommunities(migration:2026_05_15_addKfOrgIdToCommunities)POST /api/kf/transfer-community— lets community admins transfer ownership to a different KF org they belong to2026_06_15_makeKfOrgIdNotNull) makes the column NOT NULL after all communities are backfilledInternal APIs (authenticated via
KF_INTERNAL_API_KEY)POST /api/kf/profile-sync— webhook receiver for user profile updates from KF AuthGET /api/kf/branding?context=<subdomain>— returns community brand colors/logos for KF Auth's login screenGET /api/kf/summary?kf_org_id=<id>— returns owned communities for KF Hubs dashboardGET /api/kf/billing/usage?kf_org_id=<id>— usage stats placeholder for billingGET /api/kf/community/:id/detail— rich community detail (members, recent pubs, analytics, DOI counts) for HubsGET /api/kf/suggested-communities— domain-based community suggestions for Hubs onboardingGET /api/kf/suggested-pubs— full-text search for relevant pubs across communitiesGET /api/kf/graph-data— network graph data (communities + shared members) for Hubs visualizationSession-authenticated endpoints
GET /api/kf/my-orgs— returns the logged-in user's KF org memberships (used by the ownership picker)UI changes
Infra / env
.env.local.enc+ SOPS config for local dev environmentsecrets:encrypt:local/secrets:decrypt:localscripts.env.localfor local dev2026_06_15_removePasswordColumns) removeshash,salt,passwordDigest,sha3hashedPassword,resetHash,resetHashExpirationfrom UsersHow subdomains/custom domains work
The OAuth
redirect_uriis alwayshttps://<APP_URL>/auth/callback(e.g.https://www.duqduq.org/auth/callback). The originating community hostname is carried in thestateparameter. After the callback:.duqduq.org) — works for all subdomainsKF Auth only needs one registered redirect_uri per environment.
Migration plan
kfOrgIdto all communities.makeKfOrgIdNotNull+removePasswordColumnsmigrations.Files changed (23)
server/kf/api.ts,server/kf/auth.tsserver/routes/index.ts,login.kf.tsx,signup.kf.tsx,passwordReset.kf.tsx,communityCreate.tsxserver/community/model.ts,queries.ts,utils/api/schemas/community.ts2026_05_15_addKfOrgIdToCommunities,2026_06_15_makeKfOrgIdNotNull,2026_06_15_removePasswordColumnsCommunityCreate.tsx,TransferOwnership.tsx,CommunityAdminSettings.tsx.env.local.enc,.sops.yaml,docker-compose.dev.yml,package.json,confirm-encrypt.sh,.gitignore