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

Side by Side Diff: google_apis/gaia/gaia_auth_fetcher.h

Issue 973953002: Implement the calls to GAIA for the IDP IFrame protocol. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Roger and Guibin's nits and comments Created 5 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
« no previous file with comments | « google_apis/gaia/gaia_auth_consumer.h ('k') | google_apis/gaia/gaia_auth_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ 5 #ifndef GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_
6 #define GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ 6 #define GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 const std::string& service); 184 const std::string& service);
185 185
186 // Starts a request to list the accounts in the GAIA cookie. 186 // Starts a request to list the accounts in the GAIA cookie.
187 void StartListAccounts(); 187 void StartListAccounts();
188 188
189 // Starts a request to get the list of URLs to check for connection info. 189 // Starts a request to get the list of URLs to check for connection info.
190 // Returns token/URL pairs to check, and the resulting status can be given to 190 // Returns token/URL pairs to check, and the resulting status can be given to
191 // /MergeSession requests. 191 // /MergeSession requests.
192 void StartGetCheckConnectionInfo(); 192 void StartGetCheckConnectionInfo();
193 193
194 // Starts listing any sessions that exist for the IDP. If all requested scopes
195 // have been approved by the session user, then a login hint is included in
196 // the response.
197 void StartListIDPSessions(const std::string& scopes,
198 const std::string& domain);
199
200 // Generates an access token for the session, specifying the scopes and
201 // |login_hint|.
202 void StartGetTokenResponse(const std::string& scopes,
203 const std::string& domain,
204 const std::string& login_hint);
205
194 // Implementation of net::URLFetcherDelegate 206 // Implementation of net::URLFetcherDelegate
195 void OnURLFetchComplete(const net::URLFetcher* source) override; 207 void OnURLFetchComplete(const net::URLFetcher* source) override;
196 208
197 // StartClientLogin been called && results not back yet? 209 // StartClientLogin been called && results not back yet?
198 bool HasPendingFetch(); 210 bool HasPendingFetch();
199 211
200 // Stop any URL fetches in progress. 212 // Stop any URL fetches in progress.
201 void CancelRequest(); 213 void CancelRequest();
202 214
203 // From a URLFetcher result, generate an appropriate error. 215 // From a URLFetcher result, generate an appropriate error.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 int response_code); 319 int response_code);
308 320
309 void OnOAuthLoginFetched(const std::string& data, 321 void OnOAuthLoginFetched(const std::string& data,
310 const net::URLRequestStatus& status, 322 const net::URLRequestStatus& status,
311 int response_code); 323 int response_code);
312 324
313 void OnGetCheckConnectionInfoFetched(const std::string& data, 325 void OnGetCheckConnectionInfoFetched(const std::string& data,
314 const net::URLRequestStatus& status, 326 const net::URLRequestStatus& status,
315 int response_code); 327 int response_code);
316 328
329 void OnListIdpSessionsFetched(const std::string& data,
330 const net::URLRequestStatus& status,
331 int response_code);
332
333 void OnGetTokenResponseFetched(const std::string& data,
334 const net::URLRequestStatus& status,
335 int response_code);
336
317 // Tokenize the results of a ClientLogin fetch. 337 // Tokenize the results of a ClientLogin fetch.
318 static void ParseClientLoginResponse(const std::string& data, 338 static void ParseClientLoginResponse(const std::string& data,
319 std::string* sid, 339 std::string* sid,
320 std::string* lsid, 340 std::string* lsid,
321 std::string* token); 341 std::string* token);
322 342
323 static void ParseClientLoginFailure(const std::string& data, 343 static void ParseClientLoginFailure(const std::string& data,
324 std::string* error, 344 std::string* error,
325 std::string* error_url, 345 std::string* error_url,
326 std::string* captcha_url, 346 std::string* captcha_url,
327 std::string* captcha_token); 347 std::string* captcha_token);
328 348
329 // Parse ClientLogin to OAuth2 response. 349 // Parse ClientLogin to OAuth2 response.
330 static bool ParseClientLoginToOAuth2Response( 350 static bool ParseClientLoginToOAuth2Response(
331 const net::ResponseCookies& cookies, 351 const net::ResponseCookies& cookies,
332 std::string* auth_code); 352 std::string* auth_code);
333 353
334 static bool ParseClientLoginToOAuth2Cookie(const std::string& cookie, 354 static bool ParseClientLoginToOAuth2Cookie(const std::string& cookie,
335 std::string* auth_code); 355 std::string* auth_code);
336 356
357 static bool ParseListIdpSessionsResponse(const std::string& data,
358 std::string* login_hint);
359
337 // Is this a special case Gaia error for TwoFactor auth? 360 // Is this a special case Gaia error for TwoFactor auth?
338 static bool IsSecondFactorSuccess(const std::string& alleged_error); 361 static bool IsSecondFactorSuccess(const std::string& alleged_error);
339 362
340 // Is this a special case Gaia error for Less Secure Apps? 363 // Is this a special case Gaia error for Less Secure Apps?
341 static bool IsWebLoginRequiredSuccess(const std::string& alleged_error); 364 static bool IsWebLoginRequiredSuccess(const std::string& alleged_error);
342 365
343 // Given parameters, create a ClientLogin request body. 366 // Given parameters, create a ClientLogin request body.
344 static std::string MakeClientLoginBody( 367 static std::string MakeClientLoginBody(
345 const std::string& username, 368 const std::string& username,
346 const std::string& password, 369 const std::string& password,
(...skipping 21 matching lines...) Expand all
368 static std::string MakeMergeSessionBody(const std::string& auth_token, 391 static std::string MakeMergeSessionBody(const std::string& auth_token,
369 const std::string& external_cc_result, 392 const std::string& external_cc_result,
370 const std::string& continue_url, 393 const std::string& continue_url,
371 const std::string& source); 394 const std::string& source);
372 395
373 static std::string MakeGetAuthCodeHeader(const std::string& auth_token); 396 static std::string MakeGetAuthCodeHeader(const std::string& auth_token);
374 397
375 static std::string MakeOAuthLoginBody(const std::string& service, 398 static std::string MakeOAuthLoginBody(const std::string& service,
376 const std::string& source); 399 const std::string& source);
377 400
401 static std::string MakeListIDPSessionsBody(const std::string& scopes,
402 const std::string& domain);
403
404 static std::string MakeGetTokenResponseBody(const std::string& scopes,
405 const std::string& domain,
406 const std::string& login_hint);
407
378 // Create a fetcher usable for making any Gaia request. |body| is used 408 // Create a fetcher usable for making any Gaia request. |body| is used
379 // as the body of the POST request sent to GAIA. Any strings listed in 409 // as the body of the POST request sent to GAIA. Any strings listed in
380 // |headers| are added as extra HTTP headers in the request. 410 // |headers| are added as extra HTTP headers in the request.
381 // 411 //
382 // |load_flags| are passed to directly to net::URLFetcher::Create() when 412 // |load_flags| are passed to directly to net::URLFetcher::Create() when
383 // creating the URL fetcher. 413 // creating the URL fetcher.
384 static net::URLFetcher* CreateGaiaFetcher( 414 static net::URLFetcher* CreateGaiaFetcher(
385 net::URLRequestContextGetter* getter, 415 net::URLRequestContextGetter* getter,
386 const std::string& body, 416 const std::string& body,
387 const std::string& headers, 417 const std::string& headers,
(...skipping 15 matching lines...) Expand all
403 const GURL client_login_gurl_; 433 const GURL client_login_gurl_;
404 const GURL issue_auth_token_gurl_; 434 const GURL issue_auth_token_gurl_;
405 const GURL oauth2_token_gurl_; 435 const GURL oauth2_token_gurl_;
406 const GURL oauth2_revoke_gurl_; 436 const GURL oauth2_revoke_gurl_;
407 const GURL get_user_info_gurl_; 437 const GURL get_user_info_gurl_;
408 const GURL merge_session_gurl_; 438 const GURL merge_session_gurl_;
409 const GURL uberauth_token_gurl_; 439 const GURL uberauth_token_gurl_;
410 const GURL oauth_login_gurl_; 440 const GURL oauth_login_gurl_;
411 const GURL list_accounts_gurl_; 441 const GURL list_accounts_gurl_;
412 const GURL get_check_connection_info_url_; 442 const GURL get_check_connection_info_url_;
443 const GURL oauth2_iframe_url_;
413 444
414 // While a fetch is going on: 445 // While a fetch is going on:
415 scoped_ptr<net::URLFetcher> fetcher_; 446 scoped_ptr<net::URLFetcher> fetcher_;
416 GURL client_login_to_oauth2_gurl_; 447 GURL client_login_to_oauth2_gurl_;
417 std::string request_body_; 448 std::string request_body_;
418 std::string requested_service_; // Currently tracked for IssueAuthToken only. 449 std::string requested_service_;
419 bool fetch_pending_; 450 bool fetch_pending_;
420 451
421 friend class GaiaAuthFetcherTest; 452 friend class GaiaAuthFetcherTest;
422 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse); 453 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse);
423 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDeletedError); 454 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDeletedError);
424 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDisabledError); 455 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, AccountDisabledError);
425 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, BadAuthenticationError); 456 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, BadAuthenticationError);
426 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, IncomprehensibleError); 457 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, IncomprehensibleError);
427 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError); 458 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ServiceUnavailableError);
428 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode); 459 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckNormalErrorCode);
429 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse); 460 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CheckTwoFactorResponse);
430 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure); 461 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, LoginNetFailure);
431 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, 462 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest,
432 ParseClientLoginToOAuth2Response); 463 ParseClientLoginToOAuth2Response);
433 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ParseOAuth2TokenPairResponse); 464 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ParseOAuth2TokenPairResponse);
434 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthSuccess); 465 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthSuccess);
435 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthWithQuote); 466 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthWithQuote);
436 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeSuccess); 467 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeSuccess);
437 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeQuote); 468 FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, ClientOAuthChallengeQuote);
438 469
439 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher); 470 DISALLOW_COPY_AND_ASSIGN(GaiaAuthFetcher);
440 }; 471 };
441 472
442 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_ 473 #endif // GOOGLE_APIS_GAIA_GAIA_AUTH_FETCHER_H_
OLDNEW
« no previous file with comments | « google_apis/gaia/gaia_auth_consumer.h ('k') | google_apis/gaia/gaia_auth_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698