checkAdminAuthenticationOnly simply checks whether a username / password combination is authenticated pulling the credentials from the handler
()
| 1122 | // checkAdminAuthenticationOnly simply checks whether a username / password combination is authenticated pulling the |
| 1123 | // credentials from the handler |
| 1124 | func (h *handler) checkAdminAuthenticationOnly() (bool, error) { |
| 1125 | managementEndpoints, httpClient, err := h.server.ObtainManagementEndpointsAndHTTPClient() |
| 1126 | if err != nil { |
| 1127 | return false, base.HTTPErrorf(http.StatusInternalServerError, "Error getting management endpoints: %v", err) |
| 1128 | } |
| 1129 | |
| 1130 | username, password := h.getBasicAuth() |
| 1131 | if username == "" { |
| 1132 | h.response.Header().Set("WWW-Authenticate", wwwAuthenticateHeader) |
| 1133 | return false, ErrLoginRequired |
| 1134 | } |
| 1135 | |
| 1136 | statusCode, _, err := doHTTPAuthRequest(h.ctx(), httpClient, username, password, "POST", "/pools/default/checkPermissions", managementEndpoints, nil) |
| 1137 | if err != nil { |
| 1138 | return false, base.HTTPErrorf(http.StatusInternalServerError, "Error performing HTTP auth request: %v", err) |
| 1139 | } |
| 1140 | |
| 1141 | if statusCode == http.StatusUnauthorized { |
| 1142 | base.Audit(h.ctx(), base.AuditIDAdminUserAuthenticationFailed, base.AuditFields{base.AuditFieldUserName: username}) |
| 1143 | return false, nil |
| 1144 | } |
| 1145 | |
| 1146 | return true, nil |
| 1147 | } |
| 1148 | |
| 1149 | func checkAdminAuth(ctx context.Context, bucketName, basicAuthUsername, basicAuthPassword string, attemptedHTTPOperation string, httpClient *http.Client, managementEndpoints []string, shouldCheckPermissions bool, accessPermissions []Permission, responsePermissions []Permission) (responsePermissionResults map[string]bool, statusCode int, err error) { |
| 1150 | anyResponsePermFailed := false |
no test coverage detected