Commit 877850b3 authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Add dropdown to select authentication method for Smb Share

- Adds a dropdown to select authentication method that is only visible
to chromad users.
- This change has no effect on non-chromad users
- The KerberosAuthentication_ boolean will be passed to
SmbService::Mount in a following CL

Bug: chromium:853803
Change-Id: Icc9ec65a4eb0ae20e90088f2767c7fda17578a0a
Reviewed-on: https://chromium-review.googlesource.com/1191923
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596257}
parent db8d2af8
...@@ -1450,6 +1450,15 @@ ...@@ -1450,6 +1450,15 @@
<message name="IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_INVALID_URL_MESSAGE" desc="The message shown when mounting a new SMB share fails because the URL is an invalid format."> <message name="IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_INVALID_URL_MESSAGE" desc="The message shown when mounting a new SMB share fails because the URL is an invalid format.">
Invalid URL format. Supported formats are \\server\share and smb://server/share. Invalid URL format. Supported formats are \\server\share and smb://server/share.
</message> </message>
<message name="IDS_SETTINGS_DOWNLOADS_ADD_SHARE_AUTHENTICATION_METHOD" desc="Title for the input that lets users specify their authentication method for an SMB Share.">
Authentication Method
</message>
<message name="IDS_SETTINGS_DOWNLOADS_ADD_SHARE_STANDARD_AUTHENTICATION" desc="Authentication method option indicating that fields for username and password should be shown to the user.">
Standard
</message>
<message name="IDS_SETTINGS_DOWNLOADS_ADD_SHARE_KERBEROS_AUTHENTICATION" desc="Authentication method option to use a users Kerberos ticket to authenticate. Only availible for Active Directory users.">
SSO
</message>
<!-- Date/Time Page --> <!-- Date/Time Page -->
<message name="IDS_SETTINGS_DATE_TIME" desc="Name of the settings page which displays date and time preferences."> <message name="IDS_SETTINGS_DATE_TIME" desc="Name of the settings page which displays date and time preferences.">
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> <link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html">
<link rel="import" href="chrome://resources/cr_elements/cr_searchable_drop_down/cr_searchable_drop_down.html"> <link rel="import" href="chrome://resources/cr_elements/cr_searchable_drop_down/cr_searchable_drop_down.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> <link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/md_select_css.html">
<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> <link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="../settings_shared_css.html"> <link rel="import" href="../settings_shared_css.html">
...@@ -12,11 +13,19 @@ ...@@ -12,11 +13,19 @@
<dom-module id="settings-add-smb-share-dialog"> <dom-module id="settings-add-smb-share-dialog">
<template> <template>
<style include="settings-shared"> <style include="settings-shared md-select">
#dialog [slot=body] { #dialog [slot=body] {
height: 350px; height: 350px;
} }
.md-select {
width: 100%;
}
.label {
@apply --cr-form-field-label;
}
cr-input { cr-input {
--cr-input-error-display: none; --cr-input-error-display: none;
} }
...@@ -26,6 +35,7 @@ ...@@ -26,6 +35,7 @@
--cr-searchable-drop-down-width: 472px; --cr-searchable-drop-down-width: 472px;
} }
.md-select,
cr-input:not(:last-child), cr-input:not(:last-child),
cr-searchable-drop-down { cr-searchable-drop-down {
margin-bottom: var(--cr-form-field-bottom-spacing); margin-bottom: var(--cr-form-field-bottom-spacing);
...@@ -42,12 +52,29 @@ ...@@ -42,12 +52,29 @@
<cr-input id="name" label="$i18n{smbShareName}" value="{{mountName_}}" <cr-input id="name" label="$i18n{smbShareName}" value="{{mountName_}}"
maxlength="64"> maxlength="64">
</cr-input> </cr-input>
<cr-input id="username" label="$i18n{smbShareUsername}" <div id="authentication-method" hidden="[[!isActiveDirectory_]]">
value="{{username_}}"> <div id="authentication-label" class="label">
</cr-input> $i18n{smbShareAuthenticationMethod}
<cr-input id="password" type="password" label="$i18n{smbSharePassword}" </div>
value="{{password_}}"> <select class="md-select" aria-labelledby="authentication-label"
</cr-input> value="{{authenticationMethod_::change}}">
<option value="kerberos">
$i18n{smbShareKerberosAuthentication}
</option>
<option value="credentials">
$i18n{smbShareStandardAuthentication}
</option>
</select>
</div>
<div id="credentials"
hidden="[[!shouldShowCredentialUI_(authenticationMethod_)]]">
<cr-input id="username" label="$i18n{smbShareUsername}"
value="{{username_}}">
</cr-input>
<cr-input id="password" type="password"
label="$i18n{smbSharePassword}" value="{{password_}}">
</cr-input>
</div>
</div> </div>
<div slot="button-container"> <div slot="button-container">
<paper-button class="cancel-button" on-click="cancel_" id="cancel"> <paper-button class="cancel-button" on-click="cancel_" id="cancel">
......
...@@ -6,6 +6,13 @@ ...@@ -6,6 +6,13 @@
* @fileoverview 'settings-add-smb-share-dialog' is a component for adding * @fileoverview 'settings-add-smb-share-dialog' is a component for adding
* an SMB Share. * an SMB Share.
*/ */
/** @enum {string} */
settings.SmbAuthMethod = {
KERBEROS: 'kerberos',
CREDENTIALS: 'credentials',
};
Polymer({ Polymer({
is: 'settings-add-smb-share-dialog', is: 'settings-add-smb-share-dialog',
...@@ -42,6 +49,24 @@ Polymer({ ...@@ -42,6 +49,24 @@ Polymer({
return []; return [];
}, },
}, },
/** @private */
isActiveDirectory_: {
type: Boolean,
value: function() {
return loadTimeData.getBoolean('isActiveDirectoryUser');
},
},
/** @private */
authenticationMethod_: {
type: String,
value: function() {
return loadTimeData.getBoolean('isActiveDirectoryUser') ?
settings.SmbAuthMethod.KERBEROS :
settings.SmbAuthMethod.CREDENTIALS;
},
},
}, },
/** @private {?settings.SmbBrowserProxy} */ /** @private {?settings.SmbBrowserProxy} */
...@@ -88,4 +113,11 @@ Polymer({ ...@@ -88,4 +113,11 @@ Polymer({
this.discoveredShares_ = this.discoveredShares_.concat(shares); this.discoveredShares_ = this.discoveredShares_.concat(shares);
}, },
/**
* @return {boolean}
* @private
*/
shouldShowCredentialUI_: function() {
return this.authenticationMethod_ == settings.SmbAuthMethod.CREDENTIALS;
},
}); });
...@@ -848,6 +848,12 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) { ...@@ -848,6 +848,12 @@ void AddDownloadsStrings(content::WebUIDataSource* html_source) {
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_EXISTS_MESSAGE}, IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_EXISTS_MESSAGE},
{"smbShareAddedInvalidURLMessage", {"smbShareAddedInvalidURLMessage",
IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_INVALID_URL_MESSAGE}, IDS_SETTINGS_DOWNLOADS_SHARE_ADDED_MOUNT_INVALID_URL_MESSAGE},
{"smbShareAuthenticationMethod",
IDS_SETTINGS_DOWNLOADS_ADD_SHARE_AUTHENTICATION_METHOD},
{"smbShareStandardAuthentication",
IDS_SETTINGS_DOWNLOADS_ADD_SHARE_STANDARD_AUTHENTICATION},
{"smbShareKerberosAuthentication",
IDS_SETTINGS_DOWNLOADS_ADD_SHARE_KERBEROS_AUTHENTICATION},
#endif #endif
}; };
AddLocalizedStringsBulk(html_source, localized_strings, AddLocalizedStringsBulk(html_source, localized_strings,
...@@ -1363,6 +1369,8 @@ void AddChromeOSUserStrings(content::WebUIDataSource* html_source, ...@@ -1363,6 +1369,8 @@ void AddChromeOSUserStrings(content::WebUIDataSource* html_source,
"secondaryUserBannerText", "secondaryUserBannerText",
l10n_util::GetStringFUTF16(IDS_SETTINGS_SECONDARY_USER_BANNER, l10n_util::GetStringFUTF16(IDS_SETTINGS_SECONDARY_USER_BANNER,
base::ASCIIToUTF16(primary_user_email))); base::ASCIIToUTF16(primary_user_email)));
html_source->AddBoolean("isActiveDirectoryUser",
user && user->IsActiveDirectoryUser());
policy::BrowserPolicyConnectorChromeOS* connector = policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos(); g_browser_process->platform_part()->browser_policy_connector_chromeos();
......
...@@ -118,4 +118,40 @@ suite('AddSmbShareDialogTests', function() { ...@@ -118,4 +118,40 @@ suite('AddSmbShareDialogTests', function() {
assertTrue(!!page.$$('cr-policy-pref-indicator')); assertTrue(!!page.$$('cr-policy-pref-indicator'));
assertTrue(button.disabled); assertTrue(button.disabled);
}); });
test('AuthenticationSelectorVisibility', function() {
const authenticationMethod = addDialog.$$('#authentication-method');
expectTrue(!!authenticationMethod);
expectTrue(authenticationMethod.hidden);
addDialog.isActiveDirectory_ = true;
expectFalse(authenticationMethod.hidden);
});
test('AuthenticationSelectorControlsCredentialFields', function() {
addDialog.isActiveDirectory_ = true;
expectFalse(addDialog.$$('#authentication-method').hidden);
const dropDown = addDialog.$$('.md-select');
expectTrue(!!dropDown);
const credentials = addDialog.$$('#credentials');
expectTrue(!!credentials);
dropDown.value = 'kerberos';
dropDown.dispatchEvent(new CustomEvent('change'));
Polymer.dom.flush();
expectTrue(credentials.hidden);
dropDown.value = 'credentials';
dropDown.dispatchEvent(new CustomEvent('change'));
Polymer.dom.flush();
expectFalse(credentials.hidden);
});
}); });
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