mirror of https://github.com/minio/minio.git
				
				
				
			Profiling does not required object layer to be initialized (#11133)
This commit is contained in:
		
							parent
							
								
									5434088c51
								
							
						
					
					
						commit
						e63a10e505
					
				|  | @ -49,7 +49,7 @@ func validateAdminReqConfigKV(ctx context.Context, w http.ResponseWriter, r *htt | |||
| 	} | ||||
| 
 | ||||
| 	// Validate request signature.
 | ||||
| 	cred, adminAPIErr := checkAdminRequestAuthType(ctx, r, iampolicy.ConfigUpdateAdminAction, "") | ||||
| 	cred, adminAPIErr := checkAdminRequestAuth(ctx, r, iampolicy.ConfigUpdateAdminAction, "") | ||||
| 	if adminAPIErr != ErrNone { | ||||
| 		writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(adminAPIErr), r.URL) | ||||
| 		return cred, nil | ||||
|  |  | |||
|  | @ -42,7 +42,7 @@ func validateAdminUsersReq(ctx context.Context, w http.ResponseWriter, r *http.R | |||
| 	} | ||||
| 
 | ||||
| 	// Validate request signature.
 | ||||
| 	cred, adminAPIErr = checkAdminRequestAuthType(ctx, r, action, "") | ||||
| 	cred, adminAPIErr = checkAdminRequestAuth(ctx, r, action, "") | ||||
| 	if adminAPIErr != ErrNone { | ||||
| 		writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(adminAPIErr), r.URL) | ||||
| 		return nil, cred | ||||
|  |  | |||
|  | @ -461,8 +461,15 @@ func (a adminAPIHandlers) StartProfilingHandler(w http.ResponseWriter, r *http.R | |||
| 
 | ||||
| 	defer logger.AuditLog(w, r, "StartProfiling", mustGetClaimsFromToken(r)) | ||||
| 
 | ||||
| 	objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.ProfilingAdminAction) | ||||
| 	if objectAPI == nil { | ||||
| 	// Validate request signature.
 | ||||
| 	_, adminAPIErr := checkAdminRequestAuth(ctx, r, iampolicy.ProfilingAdminAction, "") | ||||
| 	if adminAPIErr != ErrNone { | ||||
| 		writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(adminAPIErr), r.URL) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	if globalNotificationSys == nil { | ||||
| 		writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
|  | @ -559,8 +566,15 @@ func (a adminAPIHandlers) DownloadProfilingHandler(w http.ResponseWriter, r *htt | |||
| 
 | ||||
| 	defer logger.AuditLog(w, r, "DownloadProfiling", mustGetClaimsFromToken(r)) | ||||
| 
 | ||||
| 	objectAPI, _ := validateAdminReq(ctx, w, r, iampolicy.ProfilingAdminAction) | ||||
| 	if objectAPI == nil { | ||||
| 	// Validate request signature.
 | ||||
| 	_, adminAPIErr := checkAdminRequestAuth(ctx, r, iampolicy.ProfilingAdminAction, "") | ||||
| 	if adminAPIErr != ErrNone { | ||||
| 		writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(adminAPIErr), r.URL) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
| 	if globalNotificationSys == nil { | ||||
| 		writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(ErrServerNotInitialized), r.URL) | ||||
| 		return | ||||
| 	} | ||||
| 
 | ||||
|  | @ -900,7 +914,7 @@ func validateAdminReq(ctx context.Context, w http.ResponseWriter, r *http.Reques | |||
| 	} | ||||
| 
 | ||||
| 	// Validate request signature.
 | ||||
| 	cred, adminAPIErr = checkAdminRequestAuthType(ctx, r, action, "") | ||||
| 	cred, adminAPIErr = checkAdminRequestAuth(ctx, r, action, "") | ||||
| 	if adminAPIErr != ErrNone { | ||||
| 		writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(adminAPIErr), r.URL) | ||||
| 		return nil, cred | ||||
|  | @ -1032,7 +1046,7 @@ func (a adminAPIHandlers) TraceHandler(w http.ResponseWriter, r *http.Request) { | |||
| 	trcErr := r.URL.Query().Get("err") == "true" | ||||
| 
 | ||||
| 	// Validate request signature.
 | ||||
| 	_, adminAPIErr := checkAdminRequestAuthType(ctx, r, iampolicy.TraceAdminAction, "") | ||||
| 	_, adminAPIErr := checkAdminRequestAuth(ctx, r, iampolicy.TraceAdminAction, "") | ||||
| 	if adminAPIErr != ErrNone { | ||||
| 		writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(adminAPIErr), r.URL) | ||||
| 		return | ||||
|  | @ -1431,7 +1445,7 @@ func (a adminAPIHandlers) BandwidthMonitorHandler(w http.ResponseWriter, r *http | |||
| 	defer logger.AuditLog(w, r, "BandwidthMonitor", mustGetClaimsFromToken(r)) | ||||
| 
 | ||||
| 	// Validate request signature.
 | ||||
| 	_, adminAPIErr := checkAdminRequestAuthType(ctx, r, iampolicy.BandwidthMonitorAction, "") | ||||
| 	_, adminAPIErr := checkAdminRequestAuth(ctx, r, iampolicy.BandwidthMonitorAction, "") | ||||
| 	if adminAPIErr != ErrNone { | ||||
| 		writeErrorResponseJSON(ctx, w, errorCodes.ToAPIErr(adminAPIErr), r.URL) | ||||
| 		return | ||||
|  |  | |||
|  | @ -151,9 +151,10 @@ func validateAdminSignature(ctx context.Context, r *http.Request, region string) | |||
| 	return cred, claims, owner, ErrNone | ||||
| } | ||||
| 
 | ||||
| // checkAdminRequestAuthType checks whether the request is a valid signature V2 or V4 request.
 | ||||
| // It does not accept presigned or JWT or anonymous requests.
 | ||||
| func checkAdminRequestAuthType(ctx context.Context, r *http.Request, action iampolicy.AdminAction, region string) (auth.Credentials, APIErrorCode) { | ||||
| // checkAdminRequestAuth checks for authentication and authorization for the incoming
 | ||||
| // request. It only accepts V2 and V4 requests. Presigned, JWT and anonymous requests
 | ||||
| // are automatically rejected.
 | ||||
| func checkAdminRequestAuth(ctx context.Context, r *http.Request, action iampolicy.AdminAction, region string) (auth.Credentials, APIErrorCode) { | ||||
| 	cred, claims, owner, s3Err := validateAdminSignature(ctx, r, region) | ||||
| 	if s3Err != ErrNone { | ||||
| 		return cred, s3Err | ||||
|  |  | |||
|  | @ -421,7 +421,7 @@ func TestCheckAdminRequestAuthType(t *testing.T) { | |||
| 	} | ||||
| 	ctx := context.Background() | ||||
| 	for i, testCase := range testCases { | ||||
| 		if _, s3Error := checkAdminRequestAuthType(ctx, testCase.Request, iampolicy.AllAdminActions, globalServerRegion); s3Error != testCase.ErrCode { | ||||
| 		if _, s3Error := checkAdminRequestAuth(ctx, testCase.Request, iampolicy.AllAdminActions, globalServerRegion); s3Error != testCase.ErrCode { | ||||
| 			t.Errorf("Test %d: Unexpected s3error returned wanted %d, got %d", i, testCase.ErrCode, s3Error) | ||||
| 		} | ||||
| 	} | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue