Keycloak oauth configuration code not cleared
@Damans227 已经在做这个了。
开始于 2026年8月12日。
评估
这个 Issue 还没有评估数据。
描述
problem
No response
versions
ACS 4.23 RC
The keycloak oauth was introduced with the pr
https://github.com/apache/cloudstack/pull/13033
The steps to reproduce the bug
Steps to reproduce the behaviour
- Run a keycloack service using a docker container
docker run -d --name keycloak -p 8081:8080 \
-e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin \
quay.io/keycloak/keycloak:latest start-dev
- Login to the keycloak ui and create client
Example : create a client name cloudstack
- Valid redirect URIs: http://mgmtip:8080/*
- Web origins: http://mgmtip:8080
- In CloudStack (Settings → OAuth Settings, registering the keycloak provider
- Redirect URI: http://mgmtip:8080/client/#/verifyOauth (must match the Keycloak client's registered value exactly)
- Authorize URL: http://keycloakip:8081/realms//protocol/openid-connect/auth
- Token URL: http://keycloakip:8081/realms//protocol/openid-connect/token
-
Create a matching CloudStack user (username == the Keycloak test user's email).
-
Try login with keycloak provider flow end to end > Login works fine
Issue to reproduce the bug
- Cause one failure attempt with keycloak oauth attempt
Rename a CloudStack username so it no longer matches an OAuth-configured account (or use an IdP account with no matching CloudStack user).
-
Log in via the IdP with valid credentials: the code exchange succeeds (verifyOAuthCodeAndGetUser returns the correct email), but oauthlogin fails downstream because OAuth2UserAuthenticator.authenticate() can't find a matching account (userAccountDao.getUserAccount() returns null) — note this returns false before verifyUser() is ever called, so the cached token is never cleared.
-
Do not restart the management server.
-
Fix the mismatch, then perform a genuinely fresh IdP login (new authorization code) and retry.
-
Issue gets resolved if the management server is restarted
Logs
root@Cloudstack-422-before:/home/ubuntu# cat /var/log/cloudstack/management/management-server.log |grep -i "logid:84fb4f98"
2026-08-12 08:05:42,795 DEBUG [c.c.a.ApiServlet] (qtp659590237-697:[ctx-95f375f8]) (logid:84fb4f98) ===START=== 192.168.55.207 -- GET provider=keycloak&secretcode=031a66aa-7525-b93e-3757-73350343db82.XbFFhkc0E7t7nZJ_7joLuMwU.5ed14f93-3977-4527-9649-c88da3e7be55&domain=d1&command=verifyOAuthCodeAndGetUser&response=json
2026-08-12 08:05:42,796 DEBUG [c.c.a.ApiServlet] (qtp659590237-697:[ctx-95f375f8]) (logid:84fb4f98) Authentication failure: Unable to verify the code provided
2026-08-12 08:05:42,796 DEBUG [c.c.a.ApiServlet] (qtp659590237-697:[ctx-95f375f8]) (logid:84fb4f98) ===END=== 192.168.55.207 -- GET provider=keycloak&secretcode=031a66aa-7525-b93e-3757-73350343db82.XbFFhkc0E7t7nZJ_7joLuMwU.5ed14f93-3977-4527-9649-c88da3e7be55&domain=d1&command=verifyOAuthCodeAndGetUser&response=json
root@Cloudstack-422-before:/home/ubuntu# cat /var/log/cloudstack/management/management-server.log |grep -i "logid:2a077ac1"
2026-08-12 08:06:03,408 DEBUG [c.c.a.ApiServlet] (qtp659590237-694:[ctx-9bb94840]) (logid:2a077ac1) ===START=== 192.168.55.207 -- GET provider=keycloak&secretcode=a51ebc47-eac5-a5b2-ccc5-c38f10a6a3c1.XbFFhkc0E7t7nZJ_7joLuMwU.5ed14f93-3977-4527-9649-c88da3e7be55&domain=d1&command=verifyOAuthCodeAndGetUser&response=json
2026-08-12 08:06:03,409 DEBUG [c.c.a.ApiServlet] (qtp659590237-694:[ctx-9bb94840]) (logid:2a077ac1) Authentication failure: Unable to verify the code provided
2026-08-12 08:06:03,409 DEBUG [c.c.a.ApiServlet] (qtp659590237-694:[ctx-9bb94840]) (logid:2a077ac1) ===END=== 192.168.55.207 -- GET provider=keycloak&secretcode=a51ebc47-eac5-a5b2-ccc5-c38f10a6a3c1.XbFFhkc0E7t7nZJ_7joLuMwU.5ed14f93-3977-4527-9649-c88da3e7be55&domain=d1&command=verifyOAuthCodeAndGetUser&response=json
What to do about it?
Expected: The new code is validated against the IdP's token endpoint independently.
Actual: The plugin never makes a second token-exchange call — it serves the result off the token cached in st
- 主要语言
- Java
- 星标
- 3.1k
- 派生
- 1.4k
- 平均合并
- 6 天 20 小时
- 30 天内合并 PR
- 27
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/cloudstack 的其他 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
bug component:kubernetes
难度 1/5 1 小时以内 新手友好度 88/100
apache/cloudstack#14180 ·
-
bug component:projects component:UI
难度 1/5 1 小时以内 新手友好度 88/100
apache/cloudstack#14070 · 5 条评论 ·
-
component:backup
难度 2/5 1-3 小时 新手友好度 76/100
apache/cloudstack#14013 ·
-
KVM agent fails to connect to Ceph RBD storage pool after upgrading Ceph client to Tentacle 20.2.4 未关闭bug component:ceph
难度 2/5 1-3 小时 新手友好度 78/100
apache/cloudstack#13989 · 3 条评论 ·
查看 apache/cloudstack 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 1/5 1 小时以内 新手友好度 88/100
checkstyle/test-configs#263 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
-
1.0.0-alpha2 Type/Improvement
难度 2/5 1-3 小时 新手友好度 68/100
wso2/dpdp-accelerator#272 ·
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
apache/rocketmq-dashboard#4860 · 1 条评论 ·