blob: 34737ada6d5efc9b0902875895f632c92b95e0a9 [file] [log] [blame]
Avi Drissmand6cdf9b2022-09-15 19:52:531// Copyright 2013 The Chromium Authors
[email protected]9a6361d02013-03-23 16:27:522// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_
6#define REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_
7
dcheng0765c492016-04-06 22:41:538#include <memory>
[email protected]9a6361d02013-03-23 16:27:529#include <string>
10
Avi Drissman135261e2023-01-11 22:43:1511#include "base/functional/callback.h"
[email protected]9a6361d02013-03-23 16:27:5212#include "base/memory/weak_ptr.h"
sergeyu64adc272016-03-12 09:12:4313#include "remoting/protocol/client_authentication_config.h"
[email protected]9a6361d02013-03-23 16:27:5214#include "remoting/protocol/third_party_authenticator_base.h"
Joe Downing2f836a82021-07-24 06:03:5415#include "remoting/protocol/token_validator.h"
[email protected]9a6361d02013-03-23 16:27:5216
Joe Downing39d710e2022-08-25 20:11:4517namespace remoting::protocol {
[email protected]9a6361d02013-03-23 16:27:5218
19// Implements the client side of the third party authentication mechanism.
20// The client authenticator expects a |token_url| and |scope| in the first
21// message from the host, then calls the |TokenFetcher| asynchronously to
22// request a |token| and |shared_secret| from that url. If the server requires
23// interactive authentication, the |TokenFetcher| implementation will show the
24// appropriate UI. Once the |TokenFetcher| returns, the client sends the |token|
25// to the host, and uses the |shared_secret| to create an underlying
26// |V2Authenticator|, which is used to establish the encrypted connection.
27class ThirdPartyClientAuthenticator : public ThirdPartyAuthenticatorBase {
28 public:
sergeyu12e320a2016-03-08 18:10:2829 // Creates a third-party client authenticator.
30 // |create_base_authenticator_callback| is used to create the base
31 // authenticator. |token_fetcher| is used to get the authentication token.
32 ThirdPartyClientAuthenticator(
33 const CreateBaseAuthenticatorCallback& create_base_authenticator_callback,
sergeyu1acf67ba2016-03-10 02:59:1434 const FetchThirdPartyTokenCallback& fetch_token_callback);
Peter Boströme9178e42021-09-22 18:11:4935
36 ThirdPartyClientAuthenticator(const ThirdPartyClientAuthenticator&) = delete;
37 ThirdPartyClientAuthenticator& operator=(
38 const ThirdPartyClientAuthenticator&) = delete;
39
dcheng562aba52014-10-21 12:30:1440 ~ThirdPartyClientAuthenticator() override;
[email protected]9a6361d02013-03-23 16:27:5241
42 protected:
43 // ThirdPartyAuthenticator implementation.
Mirko Bonadei80d1cea2019-01-18 22:22:1744 void ProcessTokenMessage(const jingle_xmpp::XmlElement* message,
Evan Stadece9372b2020-03-12 01:28:1645 base::OnceClosure resume_callback) override;
Mirko Bonadei80d1cea2019-01-18 22:22:1746 void AddTokenElements(jingle_xmpp::XmlElement* message) override;
[email protected]9a6361d02013-03-23 16:27:5247
48 private:
Joe Downing2f836a82021-07-24 06:03:5449 void OnThirdPartyTokenFetched(
50 base::OnceClosure resume_callback,
51 const std::string& third_party_token,
52 const TokenValidator::ValidationResult& validation_result);
[email protected]9a6361d02013-03-23 16:27:5253
sergeyu12e320a2016-03-08 18:10:2854 CreateBaseAuthenticatorCallback create_base_authenticator_callback_;
sergeyu1acf67ba2016-03-10 02:59:1455 FetchThirdPartyTokenCallback fetch_token_callback_;
sergeyu12e320a2016-03-08 18:10:2856 std::string token_;
[email protected]9a6361d02013-03-23 16:27:5257
Jeremy Roman7c5cfabd2019-08-12 15:45:2758 base::WeakPtrFactory<ThirdPartyClientAuthenticator> weak_factory_{this};
[email protected]9a6361d02013-03-23 16:27:5259};
60
Joe Downing39d710e2022-08-25 20:11:4561} // namespace remoting::protocol
[email protected]9a6361d02013-03-23 16:27:5262
63#endif // REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_