mirror of
https://github.com/yv1ing/MollyBlog.git
synced 2025-09-16 14:53:45 +08:00
new: Improve the automatic update module, add authentication, and fix some bugs
This commit is contained in:
21
internal/mApp/mMiddleware.go
Normal file
21
internal/mApp/mMiddleware.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package mApp
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"MollyBlog/config"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func (ma *MApp) AuthMiddleware(ctx *gin.Context) {
|
||||
if ctx.Request.URL.Path == config.MConfigInstance.UpdateEndpoint {
|
||||
secret := ctx.GetHeader("molly-secret")
|
||||
if secret != config.MConfigInstance.UpdateSecret {
|
||||
ctx.AbortWithStatus(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Next()
|
||||
}
|
||||
Reference in New Issue
Block a user