MCPcopy Create free account
hub / github.com/LumaAI-API/Luma-API / SecretAuth

Function SecretAuth

middleware/auth.go:10–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8)
9
10func SecretAuth() func(c *gin.Context) {
11 return func(c *gin.Context) {
12 if common.SecretToken == "" {
13 return
14 }
15 accessToken := c.Request.Header.Get("Authorization")
16 accessToken = strings.TrimLeft(accessToken, "Bearer ")
17 if accessToken == common.SecretToken {
18 c.Next()
19 } else {
20 c.JSON(http.StatusUnauthorized, gin.H{
21 "detail": map[string]any{
22 "reason": "unauthorized secret token",
23 "code": 1,
24 },
25 })
26 c.Abort()
27 return
28 }
29 }
30}

Callers 1

RegisterRouterFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected