File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -10,4 +10,7 @@ services:
1010 - TZ=Asia/Shanghai
1111 - OAUTH_CLIENT_ID=your_client_id
1212 - OAUTH_CLIENT_SECRET=your_client_secret
13+ # 填写公网访问的地址, 需要跟CZL Connect保持一致.
14+ # 选填, 不填为自动获取
15+ - OAUTH_REDIRECT_URI=https://localhost:3336/admin/api/oauth/callback
1316 restart : always
Original file line number Diff line number Diff line change @@ -150,11 +150,15 @@ func (h *ProxyHandler) AuthMiddleware(next http.HandlerFunc) http.HandlerFunc {
150150
151151// getCallbackURL 从请求中获取回调地址
152152func getCallbackURL (r * http.Request ) string {
153- scheme := "http"
154- if r .TLS != nil || r .Header .Get ("X-Forwarded-Proto" ) == "https" {
155- scheme = "https"
153+ if os .Getenv ("OAUTH_REDIRECT_URI" ) != "" {
154+ return os .Getenv ("OAUTH_REDIRECT_URI" )
155+ } else {
156+ scheme := "http"
157+ if r .TLS != nil || r .Header .Get ("X-Forwarded-Proto" ) == "https" {
158+ scheme = "https"
159+ }
160+ return fmt .Sprintf ("%s://%s/admin/api/oauth/callback" , scheme , r .Host )
156161 }
157- return fmt .Sprintf ("%s://%s/admin/api/oauth/callback" , scheme , r .Host )
158162}
159163
160164// LoginHandler 处理登录请求,重定向到 OAuth 授权页面
You can’t perform that action at this time.
0 commit comments