From e128baef2f52c34948aa57e39f7a604c8da4ade4 Mon Sep 17 00:00:00 2001 From: Spurs20 <22457841+Spurs20@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:12:50 -0700 Subject: [PATCH 1/8] Adding domain field to SMB authentication in Parameter Space --- web-server/components/SmbAuthentication.tsx | 41 +++++++++++++------ .../slycat-parameter-image/js/wizard-ui.js | 3 ++ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/web-server/components/SmbAuthentication.tsx b/web-server/components/SmbAuthentication.tsx index 5125f3ef9..53af3a65c 100644 --- a/web-server/components/SmbAuthentication.tsx +++ b/web-server/components/SmbAuthentication.tsx @@ -25,6 +25,7 @@ export default class SmbAuthentication extends React.Component { session_exists: null, password: "", share: display.share?display.share:null, + domain: display.domain?display.domain:null, hostnames : [], loadingData: this.props.loadingData, initialLoad: false, @@ -45,8 +46,8 @@ export default class SmbAuthentication extends React.Component { initialLoad:true, loadingData:false }, () => { - this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username), - this.b64EncodeUnicode(this.state.password), this.state.share, this.state.session_exists); + this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username + '@' + this.state.domain), + this.b64EncodeUnicode(this.state.password), this.state.share, this.state.domain, this.state.session_exists); }); }).catch(response => { this.setState({ @@ -55,7 +56,7 @@ export default class SmbAuthentication extends React.Component { loadingData:false }, () => { this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username), - this.b64EncodeUnicode(this.state.password), this.state.share, this.state.session_exists); + this.b64EncodeUnicode(this.state.password), this.state.share, this.state.domain, this.state.session_exists); }); }); }; @@ -134,29 +135,36 @@ export default class SmbAuthentication extends React.Component { localStorage.setItem("slycat-smb-remote-controls-share", value); this.setState({share: value},() => { this.checkRemoteStatus(this.state.hostname); - this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username), - this.b64EncodeUnicode(this.state.password), this.state.share, this.state.session_exists); + this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username + '@' + this.state.domain), + this.b64EncodeUnicode(this.state.password), this.state.share, this.state.domain, this.state.session_exists); }); break; + case "domain": + localStorage.setItem("slycat-smb-remote-controls-domain", value); + this.setState({domain: value},() => { + this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username + '@' + this.state.domain), + this.b64EncodeUnicode(this.state.password), this.state.share, this.state.domain, this.state.session_exists) + }) + break; case "username": localStorage.setItem("slycat-smb-remote-controls-username", value); this.setState({username: value},() => { - this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username), - this.b64EncodeUnicode(this.state.password), this.state.share, this.state.session_exists); + this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username + '@' + this.state.domain), + this.b64EncodeUnicode(this.state.password), this.state.share, this.state.domain, this.state.session_exists); }); break; case "hostname": localStorage.setItem("slycat-smb-remote-controls-hostname", value); this.checkRemoteStatus(value); this.setState({hostname: value},() => { - this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username), - this.b64EncodeUnicode(this.state.password), this.state.share, this.state.session_exists); + this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username + '@' + this.state.domain), + this.b64EncodeUnicode(this.state.password), this.state.share, this.state.domain, this.state.session_exists); }); break; case "password": this.setState({password: value},() => { - this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username), - this.b64EncodeUnicode(this.state.password), this.state.share, this.state.session_exists); + this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username + '@' + this.state.domain), + this.b64EncodeUnicode(this.state.password), this.state.share, this.state.domain, this.state.session_exists); }); break; default: @@ -201,7 +209,7 @@ export default class SmbAuthentication extends React.Component { if (e.key === 'Enter') { let last_key = e.key; this.props.callBack(this.state.hostname, this.b64EncodeUnicode(this.state.username), - this.b64EncodeUnicode(this.state.password), this.state.share, this.state.session_exists, last_key); + this.b64EncodeUnicode(this.state.password), this.state.share, this.state.domain, this.state.session_exists, last_key); } } @@ -222,6 +230,15 @@ export default class SmbAuthentication extends React.Component { onChange={(e)=>this.onValueChange(e.target.value, "share")} /> +
+ +
+ this.onValueChange(e.target.value, "domain")} /> +
+
diff --git a/web-server/plugins/slycat-parameter-image/js/wizard-ui.js b/web-server/plugins/slycat-parameter-image/js/wizard-ui.js index 318d55d70..8ef43ae9e 100644 --- a/web-server/plugins/slycat-parameter-image/js/wizard-ui.js +++ b/web-server/plugins/slycat-parameter-image/js/wizard-ui.js @@ -45,6 +45,7 @@ function constructor(params) { username: null, password: null, share: null, + domain: null, status: null, status_type: null, enable: true, @@ -260,6 +261,7 @@ function constructor(params) { username, password, share, + domain, session_exists, last_key ) { @@ -267,6 +269,7 @@ function constructor(params) { component.remote.username(username); component.remote.password(password); component.remote.share(share); + component.remote.domain(domain); component.remote.session_exists(session_exists); //If the user hits enter key, try to connect if (last_key === "Enter") { From 2ce9f49d490f3522c8de2ef787222e7bc6a421b8 Mon Sep 17 00:00:00 2001 From: Spurs20 <22457841+Spurs20@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:13:39 -0700 Subject: [PATCH 2/8] Adding domains list to config for wizard pre-population --- .../slycat-docker-compose-authenticated-config.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/compose/slycat-compose/slycat-docker-compose-authenticated-config.ini b/docker/compose/slycat-compose/slycat-docker-compose-authenticated-config.ini index dbfb8ac98..c863e16d5 100644 --- a/docker/compose/slycat-compose/slycat-docker-compose-authenticated-config.ini +++ b/docker/compose/slycat-compose/slycat-docker-compose-authenticated-config.ini @@ -29,7 +29,8 @@ server-root: "/" show-tracebacks: True socket-host: "0.0.0.0" socket-port: 8092 -smb-remote-hosts: ["example.test"] +smb-remote-hosts: ["example.host.test"] +smb-domains: ["example.domain.test"] ssl-certificate: {"cert-path": "", "key-path": ""} sso-auth-server: {"url": ""} support-email: {"address":"nobody@example.com", "subject":"Slycat Support Request"} From b4833f516ca115de5f82db7e7c9ce8dd59bad540 Mon Sep 17 00:00:00 2001 From: Spurs20 <22457841+Spurs20@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:25:19 -0700 Subject: [PATCH 3/8] Creating web service for retrieving domain names from configuration file --- packages/slycat/web/server/engine.py | 1 + packages/slycat/web/server/handlers.py | 8 ++++++++ web-server/js/slycat-web-client.js | 13 +++++++++++++ 3 files changed, 22 insertions(+) diff --git a/packages/slycat/web/server/engine.py b/packages/slycat/web/server/engine.py index 4251cfedd..8eb5aa449 100644 --- a/packages/slycat/web/server/engine.py +++ b/packages/slycat/web/server/engine.py @@ -90,6 +90,7 @@ def abspath(path): dispatcher.connect("get-configuration-parsers", "/configuration/parsers", slycat.web.server.handlers.get_configuration_parsers, conditions={"method" : ["GET"]}) dispatcher.connect("get-configuration-remote-hosts", "/configuration/remote-hosts", slycat.web.server.handlers.get_configuration_remote_hosts, conditions={"method" : ["GET"]}) dispatcher.connect("get-configuration-smb-remote-hosts", "/configuration/smb-remote-hosts", slycat.web.server.handlers.get_configuration_smb_remote_hosts, conditions={"method" : ["GET"]}) + dispatcher.connect("get-configuration-smb-domains", "/configuration/smb-domains", slycat.web.server.handlers.get_configuration_smb_domains, conditions={"method" : ["GET"]}) dispatcher.connect("get-configuration-support-email", "/configuration/support-email", slycat.web.server.handlers.get_configuration_support_email, conditions={"method" : ["GET"]}) dispatcher.connect("get-configuration-injected-code", "/configuration/injected-code", slycat.web.server.handlers.get_configuration_injected_code, conditions={"method" : ["GET"]}) dispatcher.connect("get-configuration-ga-tracking-id", "/configuration/ga-tracking-id", slycat.web.server.handlers.get_configuration_ga_tracking_id, conditions={"method" : ["GET"]}) diff --git a/packages/slycat/web/server/handlers.py b/packages/slycat/web/server/handlers.py index 56412e640..c55686933 100644 --- a/packages/slycat/web/server/handlers.py +++ b/packages/slycat/web/server/handlers.py @@ -3156,6 +3156,14 @@ def get_configuration_smb_remote_hosts(): return json_hostnames return {"hostnames":[]} +@cherrypy.tools.json_out(on=True) +def get_configuration_smb_domains(): + if "smb-domains" in cherrypy.request.app.config["slycat-web-server"]: + domains = cherrypy.request.app.config["slycat-web-server"]["smb-domains"] + json_domains = {"domains": domains} + return domains + return {"domains":[]} + @cherrypy.tools.json_out(on=True) def get_configuration_support_email(): return cherrypy.request.app.config["slycat-web-server"]["support-email"] diff --git a/web-server/js/slycat-web-client.js b/web-server/js/slycat-web-client.js index e69cb1d05..692c0f03e 100644 --- a/web-server/js/slycat-web-client.js +++ b/web-server/js/slycat-web-client.js @@ -518,6 +518,19 @@ module.get_configuration_smb_remote_hosts_fetch = async function () { }); }; +module.get_configuration_smb_domains_fetch = async function () { + return fetch(`${api_root}configuration/smb-domains`, { + credentials: 'same-origin', + cache: 'no-store', + dataType: 'json' + }).then(async function (response) { + if (!response.ok) { + throw `bad response with: ${response.status} :: ${response.statusText}`; + } + return response.json(); + }); +} + module.get_configuration_version = function (params) { $.ajax({ dataType: 'json', From 3c8e4f50c73363120a2957c1996291a8663950d3 Mon Sep 17 00:00:00 2001 From: Spurs20 <22457841+Spurs20@users.noreply.github.com> Date: Fri, 17 Nov 2023 14:07:05 -0700 Subject: [PATCH 4/8] Replacing domain form with dropdown in smb authentication for parameter space wizard --- ...at-docker-compose-authenticated-config.ini | 4 +- packages/slycat/web/server/handlers.py | 2 +- web-server/components/SmbAuthentication.tsx | 61 ++++++++++++++++--- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/docker/compose/slycat-compose/slycat-docker-compose-authenticated-config.ini b/docker/compose/slycat-compose/slycat-docker-compose-authenticated-config.ini index c863e16d5..de0f317f4 100644 --- a/docker/compose/slycat-compose/slycat-docker-compose-authenticated-config.ini +++ b/docker/compose/slycat-compose/slycat-docker-compose-authenticated-config.ini @@ -29,8 +29,8 @@ server-root: "/" show-tracebacks: True socket-host: "0.0.0.0" socket-port: 8092 -smb-remote-hosts: ["example.host.test"] -smb-domains: ["example.domain.test"] +smb-remote-hosts: ["examples.host.com"] +smb-domains: ["domain.com"] ssl-certificate: {"cert-path": "", "key-path": ""} sso-auth-server: {"url": ""} support-email: {"address":"nobody@example.com", "subject":"Slycat Support Request"} diff --git a/packages/slycat/web/server/handlers.py b/packages/slycat/web/server/handlers.py index c55686933..3fbea4b2d 100644 --- a/packages/slycat/web/server/handlers.py +++ b/packages/slycat/web/server/handlers.py @@ -3161,7 +3161,7 @@ def get_configuration_smb_domains(): if "smb-domains" in cherrypy.request.app.config["slycat-web-server"]: domains = cherrypy.request.app.config["slycat-web-server"]["smb-domains"] json_domains = {"domains": domains} - return domains + return json_domains return {"domains":[]} @cherrypy.tools.json_out(on=True) diff --git a/web-server/components/SmbAuthentication.tsx b/web-server/components/SmbAuthentication.tsx index 53af3a65c..07c3e677a 100644 --- a/web-server/components/SmbAuthentication.tsx +++ b/web-server/components/SmbAuthentication.tsx @@ -26,6 +26,7 @@ export default class SmbAuthentication extends React.Component { password: "", share: display.share?display.share:null, domain: display.domain?display.domain:null, + domains: [], hostnames : [], loadingData: this.props.loadingData, initialLoad: false, @@ -83,9 +84,23 @@ export default class SmbAuthentication extends React.Component { }) }; + /** + * gets a list of all the known domain names that we can connect to + * via ssh + * + * @memberof SmbAuthentication + */ + getDomains = async () => { + return client.get_configuration_smb_domains_fetch() + .then((json)=>{ + this.setState({domains:json.domains}); + }) + } + async componentDidMount(){ await this.checkRemoteStatus(this.state.hostname); await this.getRemoteHosts(); + await this.getDomains(); if(this.poll){ clearInterval(this.poll); } @@ -230,15 +245,6 @@ export default class SmbAuthentication extends React.Component { onChange={(e)=>this.onValueChange(e.target.value, "share")} />
-
- -
- this.onValueChange(e.target.value, "domain")} /> -
-
@@ -262,7 +268,7 @@ export default class SmbAuthentication extends React.Component { } /** - * maps the hostnames as dropdowns items JSX + * maps the hostnames as dropdown items JSX * * @memberof SmbAuthentication */ @@ -279,6 +285,24 @@ export default class SmbAuthentication extends React.Component { return hostnamesJSX; } + /** + * maps the domains as dropdown items JSX + * + * @memberof SmbAuthentication + */ + getDomainsJSX = () => { + const domainsJSX = this.state.domains.map((domain, i) => { + return ( +
  • + this.onValueChange(e.target.text, "domain")}> + {domain} + +
  • + ) + }); + return domainsJSX; + } + /** * JSX for SlycatRemoteControls * @@ -309,6 +333,23 @@ export default class SmbAuthentication extends React.Component {
    +
    + +
    +
    +
    +
    + this.onValueChange(e.target.value, "domain")} /> +
    +
    +
    {this.getFormInputsJSX()} ); From 02a7b9f49a4197b317a2fc59633ddcb6f8e41cc6 Mon Sep 17 00:00:00 2001 From: Spurs20 <22457841+Spurs20@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:55:04 -0700 Subject: [PATCH 5/8] Adding docstring to new web service --- packages/slycat/web/server/handlers.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/slycat/web/server/handlers.py b/packages/slycat/web/server/handlers.py index 3fbea4b2d..ff0e13241 100644 --- a/packages/slycat/web/server/handlers.py +++ b/packages/slycat/web/server/handlers.py @@ -3158,6 +3158,11 @@ def get_configuration_smb_remote_hosts(): @cherrypy.tools.json_out(on=True) def get_configuration_smb_domains(): + """ + Returns the SMB domains from the slycat web server + configuration file + :return: domain names + """ if "smb-domains" in cherrypy.request.app.config["slycat-web-server"]: domains = cherrypy.request.app.config["slycat-web-server"]["smb-domains"] json_domains = {"domains": domains} From d528cda6f9ccc4d260a0526fb62e74026a9b9fba Mon Sep 17 00:00:00 2001 From: Spurs20 <22457841+Spurs20@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:20:43 -0700 Subject: [PATCH 6/8] Adding doc page for smb domain web service --- .../GET-Configuration-SMB-Domains.rst | 47 +++++++++++++++++++ docs/source/GET-methods/GET-rest-api.rst | 1 + 2 files changed, 48 insertions(+) create mode 100644 docs/source/GET-methods/GET-Configuration-SMB-Domains.rst diff --git a/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst b/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst new file mode 100644 index 000000000..d51c0cfd1 --- /dev/null +++ b/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst @@ -0,0 +1,47 @@ +GET SMB Domain Names +============ + +.. http:get:: /configuration/smb-domains + + Retrieves a list of SMB domain names, which get returned as JSON + + :responseheader Content-Type: application/json + + **Sample Request** + + .. sourcecode:: http + + GET /api/configuration/smb-domains HTTP/1.1 + Host: localhost:9000 + Connection: keep-alive + Accept: application/json, text/javascript, */*; q=0.01 + DNT: 1 + X-Requested-With: XMLHttpRequest + User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36 + Referer: https://localhost:9000/models/b26d9a5d7b2f44729bffccad51fdfcf9?bid=405d84f7553f53736beabdf874d55356 + Accept-Encoding: gzip, deflate, br + Accept-Language: en-US,en;q=0.9 + Cookie: slycatauth=e9528234ede94e159fc21ef2f744323f; slycattimeout=timeout + + **Sample Response** + + .. sourcecode:: http + + HTTP/1.1 200 OK + X-Powered-By: Express + content-length: 43 + expires: 0 + server: CherryPy/14.0.0 + pragma: no-cache + cache-control: no-cache, no-store, must-revalidate + date: Fri, 14 Jun 2019 19:41:58 GMT + content-type: application/json + connection: close + + {"selected-column":34,"selected-row":13} + +See Also +-------- + +- :http:post:`/api/configuration/smb-domains` + diff --git a/docs/source/GET-methods/GET-rest-api.rst b/docs/source/GET-methods/GET-rest-api.rst index 157a2d086..6df0e0ad8 100644 --- a/docs/source/GET-methods/GET-rest-api.rst +++ b/docs/source/GET-methods/GET-rest-api.rst @@ -7,6 +7,7 @@ GET METHODS :maxdepth: 1 GET-Bookmark.rst + GET-Configuration-SMB-Domains.rst GET-Home.rst GET-Model-Arrayset-Data.rst GET-Model-Arrayset-Metadata.rst From 0c7d2e13e0180012a18a833f84e9d01a21b59480 Mon Sep 17 00:00:00 2001 From: Spurs20 <22457841+Spurs20@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:51:25 -0700 Subject: [PATCH 7/8] Fixing doc page syntax for smb domains --- docs/source/GET-methods/GET-Configuration-SMB-Domains.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst b/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst index d51c0cfd1..b2035a4e4 100644 --- a/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst +++ b/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst @@ -1,5 +1,5 @@ GET SMB Domain Names -============ +======================== .. http:get:: /configuration/smb-domains From 584c911888d316579d7882f0dce646d516110ff8 Mon Sep 17 00:00:00 2001 From: Spurs20 <22457841+Spurs20@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:52:41 -0700 Subject: [PATCH 8/8] Updating doc page --- docs/source/GET-methods/GET-Configuration-SMB-Domains.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst b/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst index b2035a4e4..2536ecb24 100644 --- a/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst +++ b/docs/source/GET-methods/GET-Configuration-SMB-Domains.rst @@ -38,7 +38,7 @@ GET SMB Domain Names content-type: application/json connection: close - {"selected-column":34,"selected-row":13} + {"domains":['domain_1', 'domain_2', 'domain_3']} See Also --------