1 // Copyright (c) 2023 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef QUICHE_BLIND_SIGN_AUTH_BLIND_SIGN_HTTP_INTERFACE_H_ 6 #define QUICHE_BLIND_SIGN_AUTH_BLIND_SIGN_HTTP_INTERFACE_H_ 7 8 #include <string> 9 10 #include "absl/status/statusor.h" 11 #include "quiche/blind_sign_auth/blind_sign_http_response.h" 12 #include "quiche/common/platform/api/quiche_export.h" 13 #include "quiche/common/quiche_callbacks.h" 14 15 namespace quiche { 16 17 using BlindSignHttpCallback = 18 quiche::SingleUseCallback<void(absl::StatusOr<BlindSignHttpResponse>)>; 19 20 enum class BlindSignHttpRequestType { 21 kUnknown = 0, 22 kGetInitialData, 23 kAuthAndSign, 24 }; 25 26 // Interface for async HTTP POST requests in BlindSignAuth. 27 // Implementers must send a request to a signer server's URL 28 // and call the provided callback when the request is complete. 29 class QUICHE_EXPORT BlindSignHttpInterface { 30 public: 31 virtual ~BlindSignHttpInterface() = default; 32 // Non-HTTP errors (like failing to create a socket) must return an 33 // absl::Status. 34 // HTTP errors must set status_code and body in BlindSignHttpResponse. 35 // DoRequest must be a HTTP POST request. 36 // Requests do not need cookies and must follow redirects. 37 // The implementer must set Content-Type and Accept headers to 38 // "application/x-protobuf". 39 // DoRequest is async. When the request completes, the implementer must call 40 // the provided callback. 41 virtual void DoRequest(BlindSignHttpRequestType request_type, 42 const std::string& authorization_header, 43 const std::string& body, 44 BlindSignHttpCallback callback) = 0; 45 }; 46 47 } // namespace quiche 48 49 #endif // QUICHE_BLIND_SIGN_AUTH_BLIND_SIGN_HTTP_INTERFACE_H_ 50