ci: 复用部署服务器缓存并支持 HTTPS 同源登录

This commit is contained in:
2026-10-09 21:11:44 +08:00
parent 2cad6d7533
commit ac936d2a1a
14 changed files with 158 additions and 47 deletions
+6
View File
@@ -35,10 +35,13 @@ type IdentityOptions struct {
Limiter LoginLimiter
DevelopmentLogin bool
SecureCookie bool
PublicOrigin string
}
const sessionCookie = "veyra_admin_session"
type publicOriginContextKey struct{}
func bindIdentity(r *gin.Engine, options IdentityOptions) {
r.SetTrustedProxies(nil)
adminAuth := func(c *gin.Context) { authenticate(c, options, "admin") }
@@ -210,6 +213,9 @@ func sameOrigin(r *http.Request) bool {
if err != nil || origin.Host == "" || origin.User != nil || origin.Path != "" || origin.RawQuery != "" || origin.Fragment != "" {
return false
}
if expected, _ := r.Context().Value(publicOriginContextKey{}).(string); expected != "" {
return origin.Host == r.Host && origin.Scheme+"://"+origin.Host == expected
}
scheme := "http"
if r.TLS != nil {
scheme = "https"