MCPcopy Create free account
hub / github.com/Illusionna/LocalTransfer / AuthorizeShareFileMiddleware

Function AuthorizeShareFileMiddleware

utils.go:91–100  ·  view source on GitHub ↗

授权文件传输服务中间件.

(next http.Handler)

Source from the content-addressed store, hash-verified

89
90// 授权文件传输服务中间件.
91func AuthorizeShareFileMiddleware(next http.Handler) http.Handler {
92 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
93 user := strings.Split(r.RemoteAddr, ":")[0] + "+" + r.Header.Get("User-Agent")
94 if AuthorizeUser(user) {
95 http.Redirect(w, r, "/login/", http.StatusMovedPermanently)
96 return
97 }
98 next.ServeHTTP(w, r)
99 })
100}
101
102
103// 禁止 API 使用 ".." 或绝对路径越界访问共享文件的夹祖父目录.

Callers 1

UpdateShareHandlerFunction · 0.85

Calls 2

AuthorizeUserFunction · 0.85
ServeHTTPMethod · 0.80

Tested by

no test coverage detected