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

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

Issue 12326090: Third Party authentication protocol. (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: TokenFetcher/Validator ownership, move parameters to Validator, remove client/host glue 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_AUTHENTICATOR_H_
6 #define REMOTING_PROTOCOL_THIRD_PARTY_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"
Wez 2013/03/05 22:55:53 Remove this include.
rmsousa 2013/03/06 00:54:16 Done.
13 #include "googleurl/src/gurl.h"
14 #include "remoting/protocol/authenticator.h"
15
16 namespace remoting {
17
18 class RsaKeyPair;
19
20 namespace protocol {
21
22 // Implements an authentication method that relies on a third party server for
23 // authentication of both client and host.
Wez 2013/03/05 22:55:53 Suggest "Authenticator implementation that authent
24 // When third party authentication is being used, the client must request both a
25 // token and a shared secret from a third-party server (which may require the
26 // user to authenticate themselves). The client then sends only the token to the
27 // host. The host signs the token, then contacts the third-party server to
28 // exchange the token for the shared secret. Once both client and host have the
29 // shared secret, they use an underlying |V2Authenticator| (SPAKE2) to negotiate
30 // an authentication key, which is used to establish the connection.
Wez 2013/03/05 22:55:53 nit: This looks like it should break down into a s
31 class ThirdPartyAuthenticator : public Authenticator {
32 public:
33 class TokenFetcher {
34 public:
35 // Callback passed to |FetchThirdPartyToken|, and called once the client
36 // authentication finishes. |token| is an opaque string that should be sent
37 // directly to the host. |shared_secret| should be used by the client to
Wez 2013/03/05 22:55:53 nit: "... will be passed ..."
38 // create a V2Authenticator. In case of failure, the callback is called with
Wez 2013/03/05 22:55:53 nit: "... will be used at the client to create a V
39 // an empty |token| and |shared_secret|.
40 typedef base::Callback<void(
41 const std::string& token,
42 const std::string& shared_secret)> TokenFetchedCallback;
43
44 virtual ~TokenFetcher() {};
45
46 // Fetches a third party token from |token_url|. |host_public_key| is sent
47 // to the server so it can later authenticate the host. |scope| is a string
48 // with a space-separated list of attributes for this connection (e.g.
49 // "hostjid:abc@example.com/123 clientjid:def@example.org/456".
50 // |token_fetched_callback| is called when the client authentication ends,
51 // in the same thread |FetchThirdPartyToken| was originally called.
52 // The request is canceled if the TokenFetcher is destroyed.
Wez 2013/03/05 22:55:53 See above, re documenting in terms of what the Thi
53 virtual void FetchThirdPartyToken(
54 const std::string& token_url,
55 const std::string& host_public_key,
56 const std::string& scope,
57 const TokenFetchedCallback& token_fetched_callback) = 0;
58 };
59
60 class TokenValidator {
61 public:
62 // Callback passed to |ValidateThirdPartyToken|, and called once the host
63 // authentication finishes. |shared_secret| should be used by the host to
64 // create a V2Authenticator. In case of failure, the callback is called with
65 // an empty |shared_secret|.
Wez 2013/03/05 22:55:53 See above re comments.
66 typedef base::Callback<void(
67 const std::string& shared_secret)> TokenValidatedCallback;
68
69 virtual ~TokenValidator() {}
70
71 // Validates |token| with the server and exchanges it for a |shared_secret|.
72 // |token_validated_callback| is called when the host authentication ends,
73 // in the same thread |ValidateThirdPartyToken| was originally called.
74 // The request is canceled if this object is destroyed.
75 virtual void ValidateThirdPartyToken(
76 const std::string& token,
77 const TokenValidatedCallback& token_validated_callback) = 0;
78
79 // URL sent to the client, to be used by its |TokenFetcher| to get a token.
80 virtual const GURL& token_url() const = 0;
Wez 2013/03/05 22:55:53 nit: Blank line after this.
81 // Space-separated list of connection attributes the host must send to the
82 // client, and require the token received in response to match.
83 virtual const std::string& token_scope() const = 0;
84 };
85
86 // Creates a third-party client authenticator, for the host with the given
87 // |host_public_key|. |token_fetcher| must outlive this authenticator.
Wez 2013/03/05 22:55:53 |token_fetcher| is being passed, so it's lifetime
88 static scoped_ptr<Authenticator> CreateForClient(
89 const std::string& host_public_key,
90 scoped_ptr<ThirdPartyAuthenticator::TokenFetcher> token_fetcher,
91 Authenticator::State initial_state);
92
93 // Creates a third-party host authenticator. |local_cert| and |key_pair| are
94 // used by the underlying V2Authenticator to create the SSL channels.
95 // |token_validator| contains the token parameters to be sent to the client
96 // and is used to obtain the shared secret.
Wez 2013/03/05 22:55:53 nit: "... used by ... " -> "... passed to ..." Yo
97 static scoped_ptr<Authenticator> CreateForHost(
98 const std::string& local_cert,
99 scoped_refptr<RsaKeyPair> key_pair,
100 scoped_ptr<ThirdPartyAuthenticator::TokenValidator> token_validator,
101 Authenticator::State initial_state);
102
103 virtual ~ThirdPartyAuthenticator();
104
105 // Authenticator interface.
106 virtual State state() const OVERRIDE;
107 virtual RejectionReason rejection_reason() const OVERRIDE;
108 virtual void ProcessMessage(const buzz::XmlElement* message,
109 const base::Closure& resume_callback) OVERRIDE;
110 virtual scoped_ptr<buzz::XmlElement> GetNextMessage() OVERRIDE;
111 virtual scoped_ptr<ChannelAuthenticator>
112 CreateChannelAuthenticator() const OVERRIDE;
113
114 protected:
115 explicit ThirdPartyAuthenticator(State initial_state);
Wez 2013/03/05 22:55:53 nit: Blank line after this to separate it from the
116 void ProcessUnderlyingMessage(
117 const buzz::XmlElement* message,
118 const base::Closure& resume_callback);
119 virtual void ProcessMessageInternal(
120 const buzz::XmlElement* message,
121 const base::Closure& resume_callback) = 0;
122 virtual void GetNextMessageInternal(buzz::XmlElement* message) = 0;
Wez 2013/03/05 22:55:53 nit: Add comments documenting how/why these are ov
123
124 // Used for both host and client authenticators.
Wez 2013/03/05 22:55:53 nit: Suggest "State comment to client and host aut
125 scoped_ptr<Authenticator> underlying_;
126 State state_;
127 RejectionReason rejection_reason_;
Wez 2013/03/05 22:55:53 nit: Should these be private and accessible only v
128
129 private:
130 DISALLOW_COPY_AND_ASSIGN(ThirdPartyAuthenticator);
131 };
132
133 } // namespace protocol
134 } // namespace remoting
135
136 #endif // REMOTING_PROTOCOL_THIRD_PARTY_AUTHENTICATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698