Commit 24228328 authored by Xiyuan Xia's avatar Xiyuan Xia Committed by Commit Bot

cros: SAML flow use auth code to bootstrap user session

If an auth code is issued for SAML flow, use it to perform
the /MergeSession call to bootstrap the user session.

Bug: 767143
Change-Id: Id42a37c84db468f155edfde557ad789b86ab2c4b
Reviewed-on: https://chromium-review.googlesource.com/677485
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarAchuith Bhandarkar <achuith@chromium.org>
Cr-Commit-Position: refs/heads/master@{#503539}
parent 9ea1bc81
......@@ -1602,10 +1602,8 @@ void ExistingUserController::DoCompleteLogin(
return;
}
// Fetch OAuth2 tokens if we have an auth code and are not using SAML.
// SAML uses cookies to get tokens.
if (user_context.GetAuthFlow() == UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML &&
!user_context.GetAuthCode().empty()) {
// Fetch OAuth2 tokens if we have an auth code.
if (!user_context.GetAuthCode().empty()) {
oauth2_token_initializer_.reset(new OAuth2TokenInitializer);
oauth2_token_initializer_->Start(
user_context, base::Bind(&ExistingUserController::OnOAuth2TokensFetched,
......
......@@ -1419,11 +1419,13 @@ void UserSessionManager::InitSessionRestoreStrategy() {
DCHECK(!has_auth_cookies_);
}
if (has_auth_cookies_) {
session_restore_strategy_ = OAuth2LoginManager::RESTORE_FROM_COOKIE_JAR;
} else if (!user_context_.GetRefreshToken().empty()) {
if (!user_context_.GetRefreshToken().empty()) {
session_restore_strategy_ =
OAuth2LoginManager::RESTORE_FROM_PASSED_OAUTH2_REFRESH_TOKEN;
} else if (has_auth_cookies_) {
// TODO(b/63865968): Deprecate RESTORE_FROM_COOKIE_JAR after confirming no
// Gaia cookies will be generated out of SAML flow.
session_restore_strategy_ = OAuth2LoginManager::RESTORE_FROM_COOKIE_JAR;
} else {
session_restore_strategy_ =
OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment