feat(auth): add Feishu OAuth2 login provider - #696
Open
yhd4711499 wants to merge 2 commits into
Open
Conversation
Feishu deviates from standard OAuth2: the authorize endpoint requires
app_id instead of client_id, userinfo returns a {code, msg, data}
envelope with errors reported as HTTP 200, and the token endpoint uses
client_secret_post. Reuse the Spring oauth2Login pipeline and override
only the userinfo loading step via a ProviderOAuth2UserService extension
point, keeping GitHub/GitLab behavior unchanged. Bindings use open_id
as subject; union_id is kept in extra for future cross-app migration.
The nginx template references this variable and envsubst leaves undefined variables untouched, causing nginx to fail with 'unknown skillhub_trust_forwarded_proto variable' when the staging web container starts.
|
|
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.
What
Adds Feishu (飞书/Lark) as an OAuth2 login provider alongside GitHub and GitLab. When
OAUTH2_FEISHU_CLIENT_ID/OAUTH2_FEISHU_CLIENT_SECRETare configured, the login page automatically shows a Feishu button (the provider catalog is config-driven).Why
Enterprise deployments need Feishu SSO. This was implemented and verified end-to-end against a real Feishu self-built app (QR login → callback → account provisioning → re-login dedup).
How
Feishu deviates from standard OAuth2, so the Spring
oauth2Loginpipeline is reused with three targeted customizations:app_idinstead ofclient_idand does not accept ascopeparameter (scopes are configured on the open-platform app).SkillHubOAuth2AuthorizationRequestResolverrebuilds the authorization URI for thefeishuregistration only.{code, msg, data}with errors reported as HTTP 200, whichDefaultOAuth2UserServicecannot consume. NewProviderOAuth2UserServiceextension point +FeishuOAuth2UserServiceunwrapdatainto flat attributes;OAuthLoginFlowServiceselects the loader per registrationId (GitHub/GitLab unchanged).client_secret_post.open_id(stable per app);union_idis kept inextrafor potential cross-app migration. Email prefersenterprise_emailoveremail; users without email are denied under the EMAIL_DOMAIN access policy (documented).Also includes:
web/public/feishu-logo.svg(the only frontend change; button rendering/i18n adapt automatically).env.release.exampleanddocs/03-authentication-design.mdupdates (Feishu as the non-standard provider integration template)SKILLHUB_TRUST_FORWARDED_PROTOwas undefined indocker-compose.staging.yml, breakingmake stagingwith an nginx "unknown variable" error (pre-existing on main)Testing
./mvnw -pl skillhub-auth -am test: green (newFeishuOAuth2UserServiceTest,FeishuClaimsExtractorTest, resolver app_id/no-scope assertions)make typecheck-web,make lint-web: greenmake staging: green after the compose env fixapp_id, callback provisions the account (display name + avatar synced), second login reuses the same binding (1 binding / 1 user)ApiAccessDeniedHandlerTesthas 2 pre-existing locale-dependent failures on this machine (fails on clean HEAD too, unrelated to this change)Impact
AuthMethodCatalog)OAUTH2_FEISHU_CLIENT_ID/OAUTH2_FEISHU_CLIENT_SECRET, grantcontact:user.base:readonly+contact:user.email:readonlyon the app, and register<base-url>/login/oauth2/code/feishuas a redirect URL