# Casdoor 配置结构 ## 配置定义 ```go package config import "github.com/zeromicro/go-zero/rest" type Config struct { rest.RestConf MySQL MySQLConfig Casdoor CasdoorConfig JWT JWTConfig } type MySQLConfig struct { Host string Port int Database string Username string Password string } type CasdoorConfig struct { Endpoint string ClientId string ClientSecret string Organization string Application string RedirectUrl string JwtPublicKey string } type JWTConfig struct { Secret string Expire int64 } ``` ## YAML 配置示例 ```yaml Name: devops-api Host: 0.0.0.0 Port: 8888 Timeout: 30000 Log: Mode: console Level: info MySQL: Host: localhost Port: 3306 Database: devops Username: root Password: "" Casdoor: Endpoint: https://casdoor.example.com ClientId: your-client-id ClientSecret: your-client-secret Organization: built-in Application: devops-app RedirectUrl: http://localhost:8888/api/v1/auth/callback JwtPublicKey: | -----BEGIN CERTIFICATE----- MIIDXTCCAkWgAwIBAgIJAJC1HiIAZAiU... -----END CERTIFICATE----- JWT: Secret: your-32-char-secret-key-here Expire: 86400 ``` ## 获取 Casdoor 配置 ### Client ID / Client Secret 1. 登录 Casdoor 管理后台 2. 进入 Applications 菜单 3. 选择对应应用,复制 Client ID 和 Client Secret ### JWT Public Key 1. 进入 Certs 菜单 2. 找到 built-in/cert-built-in 3. 复制 Certificate 内容(包含 BEGIN/END) ### Organization - 默认使用 `built-in` - 或创建新的 Organization,使用其名称