feat: add Docker deployment and Microsoft OAuth support

This commit is contained in:
2026-04-18 14:02:24 +08:00
parent 6704cfb418
commit e69c0dd226
53 changed files with 5139 additions and 4029 deletions

View File

@@ -1,24 +1,24 @@
package middleware
import (
"net/http"
"strings"
"github.com/gin-gonic/gin"
)
// TokenAuth 校验请求头中的 X-Auth-Token 或 Authorization: Bearer <token>.
func TokenAuth(expected string) gin.HandlerFunc {
return func(c *gin.Context) {
got := c.GetHeader("X-Auth-Token")
if got == "" {
auth := c.GetHeader("Authorization")
got = strings.TrimPrefix(auth, "Bearer ")
}
if got == "" || got != expected {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "unauthorized"})
return
}
c.Next()
}
}
package middleware
import (
"net/http"
"strings"
"github.com/gin-gonic/gin"
)
// TokenAuth 校验请求头中的 X-Auth-Token 或 Authorization: Bearer <token>.
func TokenAuth(expected string) gin.HandlerFunc {
return func(c *gin.Context) {
got := c.GetHeader("X-Auth-Token")
if got == "" {
auth := c.GetHeader("Authorization")
got = strings.TrimPrefix(auth, "Bearer ")
}
if got == "" || got != expected {
c.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "unauthorized"})
return
}
c.Next()
}
}