Repository navigation
Conversation
Behind guard (GUARD_IDENTITY_ENABLED), the user comes only from the x-bastion-identity JWT, verified with platform-kit edgeauth against guard's JWKS. The OAuth callback's find-or-create and role mapping move into handlers.SignInExternalUser, shared by both paths: match by provider and subject (GUARD_IDENTITY_PROVIDER keeps the old custom provider's key so existing users keep their accounts), then by verified email, else create; fider-admin maps to administrator on every request with the last-administrator guard; no allowed role is 403, an invalid identity 401, unreachable keys 503. Fider's auth cookie is ignored and cleared, none is minted. /signin, /signout, the sign-in control and the user menu go to guard's /.well-known/bastion/ login and logout. Drops the OAUTH_CUSTOM_CLIENTID/SECRET override of the custom provider's secret; the OIDC provider code stays compiled. Go 1.26 (platform-kit), golangci-lint v2.12.2 config with node_modules excluded, and the findings the newer toolchain raises. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MwB9uUtkK8BFT7ZGoXwX9u
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.
Issue: Linear COR-1083 "Fider fork login through guard identity" (project "Central auth in guard", P-COR-63). This is a fork-only change, so nothing goes upstream.
When
GUARD_IDENTITY_ENABLED=true, Fider trusts the identity guard verified, and stops using its own OAuth sign in. Guard is the OIDC client and owns the session. Fider checks thex-bastion-identityJWT with platform-kitedgeauthagainst guard's JWKS.What changed
handlers.SignInExternalUsernow holds the OAuth callback's find-or-create and role logic, unchanged. BothOAuthTokenand the new guard path use it. It finds the user by provider + uid, then by email, or creates them. It applies the allowed-roles gate and maps admin/collaborator roles on every sign in. The last administrator is never demoted.middlewares.User(). With guard on, the user comes only from the verified identity (handlers.SignInGuardIdentity):GUARD_IDENTITY_PROVIDER(set to the old custom provider_c144tcijpa) plus the Zitadelsubmatch existing accounts.fider-adminmaps to administrator andfider-userto visitor. Both are env defaults (GUARD_IDENTITY_ADMIN_ROLES/_ALLOWED_ROLES/_COLLABORATOR_ROLES).authcookie is ignored and cleared, and no cookie is minted. Identity is checked on every request, so logout and revocation take effect on the next request./signinredirects to/.well-known/bastion/login?return_to=<sanitised path>and/signoutto/.well-known/bastion/logout. The sign-in control (modal and page) and the user menu link there directly, usingsettings.guardIdentity.OAUTH_CUSTOM_CLIENTID/OAUTH_CUSTOM_SECREToverride of the custom provider's secret, with its admin-form lock and its tests.JWT_SECRETis still needed (email verification, state).docs/GUARD_IDENTITY.md, plus guard settings in.example.env..golangci.yml, which excludesnode_modules(flatted ships Go files). I fixed the 7 findings the newer linter reports:reflect.Pointer,fmt.Fprintf, andecdsa.PublicKey.Bytesin an OIDC test.Needs the owner:
.github/workflows/build.ymlstill says Go1.25and golangci-lintv2.7.2. Bump them to1.26andv2.12.2. This session's token cannot push workflow changes (theworkflowspermission), and CI's lint fails until that is done.Tests
app/middlewares/user_guard_test.gouses edgeauthtest identities. Cases:/signinand/signoutredirects with guard on, and that a foreign redirect falls back to/.golangci-lintv2.12.2: 0 issues. eslint: 0 errors. jest: 127 passed.go test ./... -race -shortagainst a local Postgres 16 (no Docker): all green except 3 tests that need network or MinIO here:TestGravatarHandler(gravatar.com),TestWebhookURL_AllowedAddresses(DNS; it fails on main too), andTestBlobStorageS3 (no MinIO).Dependencies
Pins platform-kit at the COR-1076 branch commit; bump to v0.3.0 once MetsaApp/platform-kit#6 is released, before merging.
Depends on: guard COR-1074 (login, sessions), the deploy-repo guard config for this host.
Cutover
https://feedback.metsa.app/.well-known/bastion/callbackon thefiderZitadel client. AddREFRESH_TOKENand movefider-oidcto guard-production.fiderclient and a whole-host rule (auth: required,requireRoles: [fider-admin, fider-user]). The board is private.GUARD_IDENTITY_ENABLED=true,PLATFORM_KIT_EDGEAUTH_AUDIENCES=feedback.metsa.appandGUARD_IDENTITY_PROVIDER=_c144tcijpa. DropOAUTH_CUSTOM_*._c144tcijpaprovider row and drop the old redirect URI.Generated by Claude Code