Skip to content

feat: add Casdoor SSO integration as auth provider#57

Open
NicoBernardes wants to merge 2 commits into
occult:mainfrom
NicoBernardes:feat/casdoor-integration-pr
Open

feat: add Casdoor SSO integration as auth provider#57
NicoBernardes wants to merge 2 commits into
occult:mainfrom
NicoBernardes:feat/casdoor-integration-pr

Conversation

@NicoBernardes

Copy link
Copy Markdown

Summary

  • Integrate Casdoor as an external SSO/identity provider for Pagode
  • Login, registration, and logout are handled via Casdoor OAuth 2.0 flow
  • Callback handler creates or links local users by email, then establishes a session
  • Remove built-in auth pages (Login, Register, ForgotPassword, etc.) in favor of Casdoor-managed auth
  • Includes Docker Compose for local Casdoor development (docker compose up -d casdoor)
  • Added casdoor/README.md with full setup instructions and .env.example for configuration

Key changes

  • config/config.go & config/config.yaml — Auth configuration with Casdoor settings
  • pkg/services/casdoor.go — Casdoor SDK wrapper (signin/signup URLs, code exchange, reachability check)
  • pkg/handlers/casdoor.go — OAuth callback handler with find-or-create user flow
  • pkg/handlers/auth.go — Login/Register redirect to Casdoor, logout via Casdoor
  • pkg/handlers/router.go — SameSite=Lax cookie policy for OAuth redirects
  • pkg/middleware/inertia_props.go — Pass auth provider to frontend shared props
  • docker-compose.yml — Casdoor all-in-one container on port 8100

Test plan

  • Run docker compose up -d casdoor and configure a Pagode application in Casdoor admin (http://localhost:8100)
  • Copy .env.example to .env and fill in Casdoor credentials
  • Verify login redirects to Casdoor and callback creates a local user
  • Verify logout clears local session and redirects to Casdoor logout
  • Verify password settings page shows "managed by identity provider"
  • Verify go build -o /dev/null ./cmd/web compiles successfully

🤖 Generated with Claude Code

NicoBernardes and others added 2 commits March 19, 2026 17:45
Integrate Casdoor as an external identity provider while keeping
built-in auth as the default. When auth.provider=casdoor, login and
registration redirect to Casdoor via OAuth 2.0, and a callback handler
creates/links local users by email.

- Add CasdoorConfig and AuthConfig to configuration system
- Add godotenv for .env file loading with .env.example template
- Add Casdoor Go SDK service wrapper (signin/signup URLs, code exchange)
- Add OAuth callback handler with find-or-create user flow
- Redirect login/register to Casdoor with Inertia-compatible external redirects
- Use SameSite=Lax for cookies when Casdoor is active (required for OAuth)
- Pass auth provider to frontend via shared Inertia props
- Show "managed by identity provider" on password settings when using Casdoor
- Add Docker Compose for local Casdoor development
- Add casdoor/README.md with setup instructions
- Add .env to .gitignore, .env.example for developer reference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove all built-in login/register/password-reset/email-verification flows
- Login and Register now always redirect to Casdoor SSO
- Logout clears local session and redirects to Casdoor logout
- Strip AuthClient down to Login/Logout/GetAuthenticatedUser (session only)
- Remove LoadValidPasswordToken middleware and password-related route names
- Remove password change from profile settings (managed by Casdoor)
- Simplify account deletion (no password confirmation needed)
- Delete all frontend Auth pages (Login, Register, ForgotPassword, etc.)
- Add graceful error handling when Casdoor is unreachable
- Always use SameSite=Lax for cookies (required for OAuth redirects)
- Update tests to match simplified auth surface

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant