Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: remoting/protocol/third_party_client_authenticator.h

Issue 12326090: Third Party authentication protocol. (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: Reviewer comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 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 REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_
6 #define REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_
7
8 #include <string>
9
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "remoting/protocol/third_party_authenticator_base.h"
14
15 class GURL;
16
17 namespace remoting {
18 namespace protocol {
19
20 // Implements an authentication method that relies on a third party server for
21 // authentication of both client and host.
22 // When third party authentication is being used, the client must request both a
23 // token and a shared secret from a third-party server (which may require the
24 // user to authenticate themselves). The client then sends only the token to the
25 // host. The host signs the token, then contacts the third-party server to
26 // exchange the token for the shared secret. Once both client and host have the
27 // shared secret, they use an underlying |V2Authenticator| (SPAKE2) to negotiate
28 // an authentication key, which is used to establish the connection.
Wez 2013/03/22 06:17:01 Isn't this comment already present on the ThirdPar
rmsousa 2013/03/22 21:19:05 Indeed, changed for a client specific comment.
29 class ThirdPartyClientAuthenticator : public ThirdPartyAuthenticatorBase {
30 public:
31 class TokenFetcher {
32 public:
33 // Callback passed to |FetchThirdPartyToken|, and called once the client
34 // authentication finishes. |token| is an opaque string that should be sent
35 // directly to the host. |shared_secret| should be used by the client to
36 // create a V2Authenticator. In case of failure, the callback is called with
37 // an empty |token| and |shared_secret|.
38 typedef base::Callback<void(
39 const std::string& token,
40 const std::string& shared_secret)> TokenFetchedCallback;
41
42 virtual ~TokenFetcher() {}
43
44 // Fetches a third party token from |token_url|. |host_public_key| is sent
45 // to the server so it can later authenticate the host. |scope| is a string
46 // with a space-separated list of attributes for this connection (e.g.
47 // "hostjid:abc@example.com/123 clientjid:def@example.org/456".
48 // |token_fetched_callback| is called when the client authentication ends,
49 // in the same thread |FetchThirdPartyToken| was originally called.
50 // The request is canceled if the TokenFetcher is destroyed.
51 virtual void FetchThirdPartyToken(
52 const GURL& token_url,
53 const std::string& host_public_key,
54 const std::string& scope,
55 const TokenFetchedCallback& token_fetched_callback) = 0;
56 };
57
58 // Creates a third-party client authenticator, for the host with the given
Wez 2013/03/22 06:17:01 nit: remove comma
rmsousa 2013/03/22 21:19:05 Done.
59 // |host_public_key|. |token_fetcher| is used to get the authentication token.
60 ThirdPartyClientAuthenticator(const std::string& host_public_key,
61 scoped_ptr<TokenFetcher> token_fetcher);
62 virtual ~ThirdPartyClientAuthenticator();
63
64 protected:
65 // ThirdPartyAuthenticator implementation.
66 virtual void ProcessTokenMessage(
67 const buzz::XmlElement* message,
68 const base::Closure& resume_callback) OVERRIDE;
69 virtual void AddTokenElements(buzz::XmlElement* message) OVERRIDE;
70
71 private:
72 void OnThirdPartyTokenFetched(const base::Closure& resume_callback,
73 const std::string& third_party_token,
74 const std::string& shared_secret);
75
76 std::string host_public_key_;
77 std::string token_;
78 scoped_ptr<TokenFetcher> token_fetcher_;
79
80 DISALLOW_COPY_AND_ASSIGN(ThirdPartyClientAuthenticator);
81 };
82
83
84 } // namespace protocol
85 } // namespace remoting
86
87 #endif // REMOTING_PROTOCOL_THIRD_PARTY_CLIENT_AUTHENTICATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698