Feature request: native OIDC / Keycloak SSO login
Summary
LoopForge currently supports local password accounts, GitHub device flow, Gongfeng OAuth, and gateway identity headers, but not generic OIDC. For self-hosted/enterprise deployments (Keycloak in our case), native OIDC authorization-code login would remove the need for an external forward-auth proxy and let teams reuse their existing IdP.
Environment
- LoopForge v0.4.0 (
ghcr.io/tencent/loopforge:0.4.0) - Docker Compose deployment, MySQL 8.4, reverse proxy in front
- Keycloak with an OIDC discovery endpoint
Why gateway identity headers are not sufficient
AGENTFLOW_TRUST_IDENTITY_HEADERS=true + AGENTFLOW_IDENTITY_HEADER_SECRET works only for requests whose RemoteAddr is loopback (internal/httpapi/auth.go, gatewayLoginName). In the published Compose stack, host/reverse-proxy requests reach the container through Docker port publishing (docker-proxy), so the app sees the bridge gateway (e.g. 172.29.0.1), not 127.0.0.1. We verified this by reading /proc/net/tcp6 inside the platform container while a connection was open. As a result, header SSO cannot be used without changing the deployment topology (host networking or a loopback sidecar), and an external oauth2-proxy would need that extra plumbing.
Request
Add a native OIDC provider for browser login, for example:
- issuer/discovery URL, client ID/secret, scopes (
openid profile email) - configurable claim mapping for login name / display name / email
- optional group/role to platform-admin mapping
- keep local password accounts as a break-glass option
- follow the same pattern as the existing GitHub/Gongfeng providers, so no external proxy is required
Contribution
We are happy to submit a PR if the maintainers are interested. We can implement and test the OIDC authorization-code flow against Keycloak. If there is a preferred design (for example, reusing an existing auth abstraction or a specific claim for the login name), please point us at it and we will follow it.
Thanks!
Thanks for the feedback.
My understanding is that you want native OIDC authorization-code login (for example with Keycloak), so a self-hosted deployment can sign in through the existing identity provider without an extra forward-auth proxy. You also noted that gateway identity headers do not apply in the published Compose setup, because the app does not see a loopback remote address.
This issue has been seen and will be reviewed along with the existing issue queue.
Following up after some research on our side, including something that may save everyone time.
While reading the repo we found feature/enterprise-sso (1df5111, "feat(auth): add enterprise OIDC sign-in", 2026-11-16), which already implements this request in a shape very close to what we would have proposed:
github.com/coreos/go-oidc/v3+golang.org/x/oauth2: discovery, authorization-code flow with PKCE S256,state/nonce, and real ID-token verification (signature, issuer, audience) rather than trusting/userinfo/api/auth/oidc/startand/api/auth/oidc/callback, withstatebound to a browser cookie and consumed exactly once- an
oidc_identities(issuer, subject) -> user_idlink to an existing LoopForge account, so platform role and project permissions come from the linked account instead of from claim mapping - local password login kept as break-glass
AGENTFLOW_OIDC_ISSUER/_CLIENT_ID/_CLIENT_SECRET/_REDIRECT_URL/_TOKEN_AUTH_METHOD
That is essentially the design we had in mind, so we would rather help land it than open a competing PR. Two concrete things we hit that may matter for merging it:
- Migration number collision. The branch adds
migrations/033_oidc_login.sql, butmaingainedmigrations/033_generic_sop_mr_node.sqlon 2026-11-17 (commit69e4bf0) and is now at040_*. The branch was cut from00d4f17on 2026-11-16, when 033 was still free, so it needs renumbering and a rebase. - The branch is about ten days behind
main(1df5111sits on00d4f17,mainis at2e38c9c). We tried applying it onto the v0.4.2 tag as a probe and it conflicts incompose.yaml,go.mod,go.sum,internal/httpapi/server.go,internal/repo/models.go,web/app.js,web/login.jsandweb/preferences.css— all ordinary drift, none of it in the new files themselves.
One design note for the maintainers: the original request above asked for configurable claim mapping and an optional group/role to platform-admin mapping. The branch deliberately does neither — an identity must be linked to an account by an administrator before it can sign in, and it then inherits that account's role. That behaviour suits us well (no auto-provisioning risk), but it is worth stating explicitly in docs/deployment.md so operators do not expect SSO to create accounts.
We have a Keycloak realm available and are happy to run the flow end to end against it — happy path, unlinked identity, replayed state, wrong Host, and expired/mismatched ID token — and report the results here.
Could a maintainer confirm whether feature/enterprise-sso is the intended path, and roughly when it might reach a release? If so we will hold off on a separate PR and contribute test coverage or fixes against that branch instead. If it has been parked, say so and we will pick it up from there.
我们把两条路线的调研整理成了一份设计提案,提在这里:#1655(docs/proposals/oidc-sign-in.md,纯文档,不含实现)。
提出它的原因是我们不确定应该走哪条线,而两条路线在上游都已经有人表态过:
- 内置 provider:
feature/enterprise-sso(1df5111f,yowucai)已经实现了这个请求的大部分内容,安全设计达标(PKCE S256、nonce、真实 ID token 校验、state一次性消费、__Host-cookie、同源return_url)。但这个分支没有开 PR,落后 main 205 个提交。 - 外部适配器:same issue queue 里的 #215 由
@Robert0622分诊,结论是「不要求内置具体协议实现,只提供稳定可测试的外部适配契约」。
如果我们现在提一个内置 provider 的 PR,很可能和 #215 的方向冲突;如果等 feature/enterprise-sso 合入,我们又不知道它是否还在推进。所以先来问路线,而不是先写代码。
调研中发现的两个事实,可能对推进有用
feature/enterprise-sso目前无法实际使用。 全仓库只有UserByOIDCIdentity的读路径,没有任何写入oidc_identities的代码;未关联身份会跳到oidc_error=unlinked,而没有任何界面或接口能建立关联。实际部署里唯一能登录的前提是管理员手工往数据库INSERT。- 迁移编号冲突。 该分支用
033_oidc_login.sql,但 main 的033已被033_generic_sop_mr_node.sql占用,当前 main 已到049。
如果 feature/enterprise-sso 仍是既定路线,这两项补起来并不难,我们很愿意接手;如果改走 #215 的外部适配器契约,我们也做完了可行性验证:internal/auth/client.go 的 AuthHost / AuthURI 全部来自环境变量,适配器只要实现 GET {AUTH_HOST}{AUTH_URI}?code=<票据> 并返回 IOAAuthResponse,就能接管登录,前端和登录页都不用改。
顺带一条安全提醒,无论走哪条路线都适用:AGENTFLOW_SESSION_SECRET 未设置时,NewClient 会回落用 AGENTFLOW_SSO_APP_TOKEN 作为会话签名密钥。适配器必须持有 AppToken 才能通过 RIO 签名校验,所以这两个值必须分离,否则适配器能伪造任意用户的会话。另外 AGENTFLOW_AUTH_REQUIRED 未设置时 authRequired() 返回 false,guest 仍可访问——适配器故障会等价于鉴权失效。
麻烦确认三件事(也写在提案末尾):
- 内置 provider(
feature/enterprise-sso)是否仍是既定路线,还是由 #215 的外部适配器契约取代? - 若是内置路线,是否接受「先合入 exchange 契约收敛,再在契约之上迭代 provider」?
feature/enterprise-sso是否希望由外部贡献者接手补齐身份关联与 rebase?
路线确定后我们可以提供对应实现和真实 Keycloak 验收,只是希望避免与已存在的分支重复投入。
@cocofhu00 @Robert0622