fix(auth): exit immediately on terminal auth denial and unify denial page styles#122
Merged
PeterGuy326 merged 4 commits intoDingTalk-Real-AI:mainfrom Apr 17, 2026
Merged
Conversation
PeterGuy326
approved these changes
Apr 17, 2026
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.
Summary
Improves the
dws auth loginexperience when the organization or channelpolicy denies CLI access.
1. Exit immediately on terminal denial reasons
When
/cli/cliAuthEnabledreturns a terminal denial reason, thebrowser shows a page with no "apply" button (admin intervention
required), but the CLI was still entering the polling loop that waits
for the user to submit an apply request. This caused the terminal to
hang on
⏳ 等待提交申请中 (Xs/600s)until the 10-minute timeout,even though the browser already showed a clear terminal error.
After this change, the CLI exits right away with an error message
identical to the text on the HTML page, for the following reasons:
user_forbidden/user_not_allowedchannel_not_allowed/channel_requiredcli_not_enabled(org not enabled yet)Implementation: threaded
denialReasonthroughcallbackResultandadded an early-return switch before the polling loop in
OAuthProvider.Login. This mirrors the existing behavior indevice_flow.go, so the two login paths are now consistent.2. Unify denial page styles with the success page
accessDeniedHTML("无权限访问") andchannelDeniedHTML("渠道未授权")rendered as small square cards with different typography than
successHTML("授权成功"), which used a fixed480x600vertical card.All three pages now share the same card dimensions (
height: 600px; width: 480px), padding, icon class (.lock-icon), and full PingFangSC font stack. The message body was also collapsed from two
<p>tags into one, matching the structure of the success page.
3. Remove unused
DWS_CHANNEL_CLIENT_IDThe environment variable and its corresponding
x-dws-channel-client-idHTTP header had no observable effect on the MCP backend. Removing it:
dws config listoutputresolveIdentityHeadersconfigmeta.Registerentry inendpoints.goDWS_CHANNEL(→x-dws-channel) is kept unchanged, since it is stillused for channel-scope authorization checks.
Files changed
internal/auth/oauth_provider.go— early-exit switch for terminaldenial reasons, carry
denialReasonon the callback result.internal/auth/oauth_helpers.go— restyleaccessDeniedHTMLandchannelDeniedHTMLto matchsuccessHTML.internal/app/runner.go— dropDWS_CHANNEL_CLIENT_IDenv var andthe
x-dws-channel-client-idheader injection.internal/auth/endpoints.go— dropDWS_CHANNEL_CLIENT_IDregistration from
configmeta.Test plan
dws auth loginin an org where the current user isuserScope=forbidden→ CLI exits with the same message shownon the "无权限访问" page, no 10-minute hang.
dws auth loginwithDWS_CHANNEL=<not-allowed>→ CLI exitswith the "渠道未授权" message.
dws auth loginin an org that has not yet enabled CLI auth→ browser still shows the apply page, CLI still polls for apply
submission (behavior unchanged).
render as identical 480×600 vertical cards.
dws config listno longer showsDWS_CHANNEL_CLIENT_ID;DWS_CHANNELstill present.make build && make testpass.