Sign inSign up

o1298098/dingtalk-auth

By o1298098

Updated 6 months ago

Image
0

1.1K

o1298098/dingtalk-auth repository overview

DingTalk OAuth Bridge

A lightweight DingTalk OAuth2 bridge service that exposes a standard OAuth2/OpenID Connect compatible interface.

It allows applications that support OAuth2 (such as Moodle, Authentik, Casdoor, or other SSO platforms) to authenticate users via DingTalk.

This service converts DingTalk authentication into a standard OAuth2 provider interface, making it easy for third-party systems to integrate DingTalk login.


Features

  • Provide standard OAuth2 endpoints
  • Bridge DingTalk SNS login
  • Compatible with common OAuth2 clients
  • Easy deployment with Docker
  • Stateless service

OAuth2 Endpoints

After the service starts, the following endpoints are available:

authorization_endpoint: http://localhost:8000/oauth2/authorize
token_endpoint:         http://localhost:8000/oauth2/token
userinfo_endpoint:      http://localhost:8000/userinfo

These endpoints can be used by OAuth clients for authentication.


Quick Start

Run with Docker

docker run -d \
  -p 8000:8000 \
  -e DINGTALK_AUTH_OAUTH2_ISSUER=http://localhost:8000 \
  -e DINGTALK_AUTH_OAUTH2_CLIENT_ID=example_client \
  -e DINGTALK_AUTH_OAUTH2_CLIENT_SECRET=example_secret \
  -e DINGTALK_AUTH_JWT_SECRET=change-me-in-production \
  -e DINGTALK_AUTH_DINGTALK_SNS_APP_ID=YOUR_SNS_APP_ID \
  -e DINGTALK_AUTH_DINGTALK_SNS_APP_SECRET=YOUR_SNS_APP_SECRET \
  -e DINGTALK_AUTH_DINGTALK_REDIRECT_BASE=http://localhost:8000 \
  o1298098/dingtalk-auth

Docker Compose Example

services:
  dingtalk-oauth-bridge:
    image: o1298098/dingtalk-auth
    container_name: dingtalk-oauth-bridge
    ports:
      - "8000:8000"

    environment:
      # OAuth2 server meta
      - DINGTALK_AUTH_OAUTH2_ISSUER=http://localhost:8000
      - DINGTALK_AUTH_OAUTH2_CLIENT_ID=example_client
      - DINGTALK_AUTH_OAUTH2_CLIENT_SECRET=example_secret
      - DINGTALK_AUTH_JWT_SECRET=change-me-in-production

      # DingTalk SNS config
      - DINGTALK_AUTH_DINGTALK_SNS_APP_ID=YOUR_SNS_APP_ID
      - DINGTALK_AUTH_DINGTALK_SNS_APP_SECRET=YOUR_SNS_APP_SECRET
      - DINGTALK_AUTH_DINGTALK_REDIRECT_BASE=http://localhost:8000

Environment Variables

VariableDescription
DINGTALK_AUTH_OAUTH2_ISSUEROAuth2 issuer URL
DINGTALK_AUTH_OAUTH2_CLIENT_IDOAuth2 client ID
DINGTALK_AUTH_OAUTH2_CLIENT_SECRETOAuth2 client secret
DINGTALK_AUTH_JWT_SECRETSecret used to sign JWT tokens
DINGTALK_AUTH_DINGTALK_SNS_APP_IDDingTalk SNS App ID
DINGTALK_AUTH_DINGTALK_SNS_APP_SECRETDingTalk SNS App Secret
DINGTALK_AUTH_DINGTALK_REDIRECT_BASERedirect base URL

OAuth2 Client Configuration Example

Example configuration for an OAuth2 client:

Authorization URL:
http://localhost:8000/oauth2/authorize

Token URL:
http://localhost:8000/oauth2/token

User Info URL:
http://localhost:8000/userinfo

Use Cases

  • Moodle OAuth2 login
  • Casdoor integration
  • Authentik integration
  • Self-hosted SSO
  • Enterprise DingTalk login gateway

Security Notes

For production deployment:

  • Use HTTPS
  • Set a strong JWT_SECRET
  • Restrict OAuth client credentials
  • Deploy behind a reverse proxy (Nginx / Traefik / Caddy)

Tag summary

Content type

Image

Digest

sha256:d751c0490

Size

64 MB

Last updated

6 months ago

docker pull o1298098/dingtalk-auth