MCPcopy Index your code
hub / github.com/cubefs/cubefs / authMiddleware

Method authMiddleware

objectnode/api_middleware.go:161–185  ·  view source on GitHub ↗

AuthMiddleware returns a pre-handle middleware handler to perform user authentication.

(next http.Handler)

Source from the content-addressed store, hash-verified

159
160// AuthMiddleware returns a pre-handle middleware handler to perform user authentication.
161func (o *ObjectNode) authMiddleware(next http.Handler) http.Handler {
162 return http.HandlerFunc(
163 func(w http.ResponseWriter, r *http.Request) {
164 // parse authentication
165 auth, err := NewAuth(r)
166 if err != nil && err == MissingSecurityElement {
167 // anonymous request will be authed in policy and acl check step
168 next.ServeHTTP(w, r)
169 return
170 }
171 if err != nil {
172 log.LogErrorf("authMiddleware: parse auth fail: requestID(%v) err(%v)",
173 GetRequestID(r), err)
174 o.errorResponse(w, r, err, nil)
175 return
176 }
177 // validate authentication information
178 if err = o.validateAuthInfo(r, auth); err != nil {
179 o.errorResponse(w, r, err, nil)
180 return
181 }
182
183 next.ServeHTTP(w, r)
184 })
185}
186
187// PolicyCheckMiddleware returns a pre-handle middleware handler to process policy check.
188func (o *ObjectNode) policyCheckMiddleware(next http.Handler) http.Handler {

Callers

nothing calls this directly

Calls 6

errorResponseMethod · 0.95
validateAuthInfoMethod · 0.95
LogErrorfFunction · 0.92
NewAuthFunction · 0.85
GetRequestIDFunction · 0.85
ServeHTTPMethod · 0.45

Tested by

no test coverage detected