Commit b02cd97c authored by bartfab@chromium.org's avatar bartfab@chromium.org

Remove credentials passing API version 1

Remove API version 1 of the credentials passing API and rename version 2
to version 1. This renumbering is backwards-incompatible and would break
any existing users of API version 1. However, the API is still under
development and thee are no users yet. Thus, we should take the
opportunity to remove the cruft of an obsolete experimental API version
before we release anything to the public.

BUG=367847
TEST=Updated browser test
TBR=nkostylev

Review URL: https://codereview.chromium.org/276903002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269590 0039d316-1c4b-4281-b951-d872f2087c98
parent ffa21d14
...@@ -418,26 +418,9 @@ IN_PROC_BROWSER_TEST_F(SamlTest, SamlUI) { ...@@ -418,26 +418,9 @@ IN_PROC_BROWSER_TEST_F(SamlTest, SamlUI) {
JsExpect("!$('gaia-signin').classList.contains('saml')"); JsExpect("!$('gaia-signin').classList.contains('saml')");
} }
// Tests the sign-in flow when version 1 of the credentials passing API is used. // Tests the sign-in flow when the credentials passing API is used.
IN_PROC_BROWSER_TEST_F(SamlTest, CredentialPassingAPIV1) { IN_PROC_BROWSER_TEST_F(SamlTest, CredentialPassingAPI) {
fake_saml_idp()->SetLoginHTMLTemplate("saml_api_login_v1.html"); fake_saml_idp()->SetLoginHTMLTemplate("saml_api_login.html");
fake_saml_idp()->SetLoginAuthHTMLTemplate("saml_api_login_auth.html");
StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail);
// Fill-in the SAML IdP form and submit.
SetSignFormField("Email", "fake_user");
SetSignFormField("Password", "fake_password");
ExecuteJsInSigninFrame("document.getElementById('Submit').click();");
// Login should finish login and a session should start.
content::WindowedNotificationObserver(
chrome::NOTIFICATION_SESSION_STARTED,
content::NotificationService::AllSources()).Wait();
}
// Tests the sign-in flow when version 2 of the credentials passing API is used.
IN_PROC_BROWSER_TEST_F(SamlTest, CredentialPassingAPIV2) {
fake_saml_idp()->SetLoginHTMLTemplate("saml_api_login_v2.html");
fake_saml_idp()->SetLoginAuthHTMLTemplate("saml_api_login_auth.html"); fake_saml_idp()->SetLoginAuthHTMLTemplate("saml_api_login_auth.html");
StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail); StartSamlAndWaitForIdpPageLoad(kFirstSAMLUserEmail);
......
...@@ -25,10 +25,10 @@ Authenticator.MIN_API_VERSION_VERSION = 1; ...@@ -25,10 +25,10 @@ Authenticator.MIN_API_VERSION_VERSION = 1;
* The highest version of the credentials passing API supported. * The highest version of the credentials passing API supported.
* @type {number} * @type {number}
*/ */
Authenticator.MAX_API_VERSION_VERSION = 2; Authenticator.MAX_API_VERSION_VERSION = 1;
/** /**
* The key types supported for credentials passing API 2 and higher. * The key types supported by the credentials passing API.
* @type {Array} Array of strings. * @type {Array} Array of strings.
*/ */
Authenticator.API_KEY_TYPES = [ Authenticator.API_KEY_TYPES = [
...@@ -292,20 +292,6 @@ Authenticator.prototype = { ...@@ -292,20 +292,6 @@ Authenticator.prototype = {
onAPICall_: function(msg) { onAPICall_: function(msg) {
var call = msg.call; var call = msg.call;
if (call.method == 'initialize') { if (call.method == 'initialize') {
// TODO(bartfab): There was no |requestedVersion| parameter in version 1
// of the API. Remove this code once all consumers have switched to
// version 2 or higher.
if (!call.hasOwnProperty('requestedVersion')) {
if (Authenticator.MIN_API_VERSION_VERSION == 1) {
this.apiVersion_ = 1;
this.initialized_ = true;
this.sendInitializationSuccess_();
}
// The glue code for API version 1 interprets all responses as success.
// Instead of reporting failure, do not send any response at all.
return;
}
if (!Number.isInteger(call.requestedVersion) || if (!Number.isInteger(call.requestedVersion) ||
call.requestedVersion < Authenticator.MIN_API_VERSION_VERSION) { call.requestedVersion < Authenticator.MIN_API_VERSION_VERSION) {
this.sendInitializationFailure_(); this.sendInitializationFailure_();
...@@ -320,17 +306,13 @@ Authenticator.prototype = { ...@@ -320,17 +306,13 @@ Authenticator.prototype = {
} }
if (call.method == 'add') { if (call.method == 'add') {
if (this.apiVersion_ > 1 && if (Authenticator.API_KEY_TYPES.indexOf(call.keyType) == -1) {
Authenticator.API_KEY_TYPES.indexOf(call.keyType) == -1) {
console.error('Authenticator.onAPICall_: unsupported key type'); console.error('Authenticator.onAPICall_: unsupported key type');
return; return;
} }
this.apiToken_ = call.token; this.apiToken_ = call.token;
this.email_ = call.user; this.email_ = call.user;
if (this.apiVersion_ == 1) this.passwordBytes_ = call.passwordBytes;
this.passwordBytes_ = call.password;
else
this.passwordBytes_ = call.passwordBytes;
} else if (call.method == 'confirm') { } else if (call.method == 'confirm') {
if (call.token != this.apiToken_) if (call.token != this.apiToken_)
console.error('Authenticator.onAPICall_: token mismatch'); console.error('Authenticator.onAPICall_: token mismatch');
...@@ -340,14 +322,11 @@ Authenticator.prototype = { ...@@ -340,14 +322,11 @@ Authenticator.prototype = {
}, },
sendInitializationSuccess_: function() { sendInitializationSuccess_: function() {
var response = { this.supportChannel_.send({name: 'apiResponse', response: {
result: 'initialized', result: 'initialized',
version: this.apiVersion_ version: this.apiVersion_,
}; keyTypes: Authenticator.API_KEY_TYPES
if (this.apiVersion_ >= 2) }});
response['keyTypes'] = Authenticator.API_KEY_TYPES;
this.supportChannel_.send({name: 'apiResponse', response: response});
}, },
sendInitializationFailure_: function() { sendInitializationFailure_: function() {
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
return; return;
var response = event.data.response; var response = event.data.response;
if (response.result != 'initialized' || if (response.result != 'initialized' ||
response.version != 2 || response.version != 1 ||
response.keyTypes.indexOf('KEY_TYPE_PASSWORD_PLAIN') == -1) { response.keyTypes.indexOf('KEY_TYPE_PASSWORD_PLAIN') == -1) {
return; return;
} }
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
window.setTimeout(function() { window.setTimeout(function() {
window.postMessage({ window.postMessage({
type: 'gaia_saml_api', type: 'gaia_saml_api',
call: {method: 'initialize', requestedVersion: 2}}, '/'); call: {method: 'initialize', requestedVersion: 1}}, '/');
}, 0); }, 0);
} }
......
<html>
<head>
<script type="text/javascript">
function initialize() {
window.setTimeout(function() {
window.postMessage({
type: 'gaia_saml_api',
call: {method: 'initialize'}}, '/');
}, 0);
}
function send_and_submit() {
var form = document.forms[0];
var token = form.elements['RelayState'].value;
var user = form.elements['Email'].value;
var password = form.elements['Password'].value;
window.setTimeout(function() {
window.postMessage({
type: 'gaia_saml_api',
call: {method: 'add',
token: token,
user: user,
password: password}}, '/');
form.submit();
}, 0);
}
</script>
</head>
<body onload="initialize();">
<form method=post action="$Post">
<input type=hidden name=RelayState value="$RelayState">
User: <input type=text id=Email name=Email>
Password: <input type=password id=Password name=Password>
<input id=Submit type=button value="Login" onclick="send_and_submit();"/>
</form>
</body>
</html>
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