• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_AUTH_INTERFACE_H_
6 #define QUICHE_BLIND_SIGN_AUTH_BLIND_SIGN_AUTH_INTERFACE_H_
7 
8 #include <string>
9 
10 #include "absl/status/statusor.h"
11 #include "absl/time/time.h"
12 #include "absl/types/span.h"
13 #include "quiche/common/platform/api/quiche_export.h"
14 #include "quiche/common/quiche_callbacks.h"
15 
16 namespace quiche {
17 
18 // ProxyLayer indicates which proxy layer that tokens will be used with.
19 enum class ProxyLayer : int {
20   kProxyA,
21   kProxyB,
22 };
23 
24 // A BlindSignToken is used to authenticate a request to a privacy proxy.
25 // The token string contains a serialized SpendTokenData proto.
26 // The token cannot be successfully redeemed after the expiration time.
27 struct QUICHE_EXPORT BlindSignToken {
28   std::string token;
29   absl::Time expiration;
30 };
31 
32 using SignedTokenCallback =
33     SingleUseCallback<void(absl::StatusOr<absl::Span<BlindSignToken>>)>;
34 
35 // BlindSignAuth provides signed, unblinded tokens to callers.
36 class QUICHE_EXPORT BlindSignAuthInterface {
37  public:
38   virtual ~BlindSignAuthInterface() = default;
39 
40   // Returns signed unblinded tokens in a callback. Tokens are single-use.
41   virtual void GetTokens(std::string oauth_token, int num_tokens,
42                          ProxyLayer proxy_layer,
43                          SignedTokenCallback callback) = 0;
44 };
45 
46 }  // namespace quiche
47 
48 #endif  // QUICHE_BLIND_SIGN_AUTH_BLIND_SIGN_AUTH_INTERFACE_H_
49