Files
nezha_domains/cmd/dashboard/controller/api_token_read_only.go
T
2026-07-20 04:32:16 +00:00

20 lines
461 B
Go

package controller
import "github.com/gin-gonic/gin"
func suppressAPITokenAuthWrites(c *gin.Context) { c.Set(apiTokenReadOnlyCtxKey, true) }
func apiTokenAuthReadOnly(c *gin.Context) bool {
value, ok := c.Get(apiTokenReadOnlyCtxKey)
return ok && value == true
}
func apiTokenLastUsedOnce(c *gin.Context) bool {
value, seen := c.Get(apiTokenLastUsedCtxKey)
if seen && value == true {
return false
}
c.Set(apiTokenLastUsedCtxKey, true)
return true
}