Skip to content

Add DingTalk OAuth login provider #583

Description

@gtsz666

Motivation

Some enterprise SkillHub deployments use DingTalk as their primary identity provider. Adding an optional DingTalk OAuth login provider would make self-hosted deployments easier to adopt in DingTalk-centered organizations while preserving the existing GitHub/GitLab OAuth, local account, mock auth, API token, and session flows.

Proposed scope

  • Add a dingtalk OAuth provider that is disabled unless explicitly configured.
  • Reuse the existing Spring Security OAuth2 login flow, including state validation, success/failure handlers, session establishment, RBAC principal construction, and audit/session behavior.
  • Reuse the existing identity mapping model: identity_binding(provider_code, subject) remains the unique external identity key.
  • Map DingTalk user identity using the most stable returned identifier available, preferring unionId, then openId, then userId when applicable.
  • Do not assume DingTalk always returns email. Treat email/mobile as optional profile fields, not primary identity keys.
  • Surface the provider through the existing auth method/provider discovery so the frontend can render the login entry dynamically.
  • Document runtime configuration for local, Docker/Compose, and Kubernetes deployments.

Out of scope

  • No company-specific intranet configuration, tenant-specific organization rules, or real credentials in the repository.
  • No DingTalk contact synchronization, department-to-namespace automation, approval workflow, robot notification, mobile-only H5 login, or internal deployment scripts.
  • No replacement of existing authentication mechanisms.

Implementation direction

Current code already has the main extension points needed:

  • CustomOAuth2UserService delegates OAuth login to OAuthLoginFlowService.
  • OAuthClaimsExtractor handles provider-specific profile mapping.
  • IdentityBindingService binds or creates platform users from normalized OAuth claims.
  • AccountMergeService can consolidate identity bindings, API tokens, roles, namespace memberships, and local credentials.
  • /api/v1/auth/methods and /api/v1/auth/providers already advertise configured OAuth methods to the frontend.

The minimal contribution would add DingTalk-specific provider configuration and claims extraction/token-userinfo adaptation while keeping provider-specific logic behind the existing auth extension points.

Rollout and security

  • Default behavior remains unchanged unless the DingTalk client registration is configured.
  • client_id, client_secret, and tenant/app-specific values must be injected by environment variables or Kubernetes Secrets.
  • CI tests should mock DingTalk endpoints and must not depend on real DingTalk network credentials.
  • Sensitive tokens and secrets must not be logged.

If this direction looks acceptable, I can prepare a focused PR for the provider, tests, frontend entry behavior if needed, and deployment documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/m中等改动,存在一定协同成本 / Medium change with noticeable coordination cost.priority/p1高优先级 / High priority triage bucket.risk/high涉及安全、鉴权、迁移或公共契约 / Touches security, auth, migrations, or public contracts.triage/needs-info需要补充更多信息后才能分流 / Issue needs more detail before it can be routed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions