Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loginKey does not work in MeshCtrl.js #6328

Closed
geekasso opened this issue Aug 15, 2024 · 7 comments
Closed

loginKey does not work in MeshCtrl.js #6328

geekasso opened this issue Aug 15, 2024 · 7 comments
Assignees
Labels

Comments

@geekasso
Copy link

Describe the bug
Hello. I am having an issue when using a loginKey in config.json and performing a remote MeshCtrl.js command, the MC server does not provide a valid response. Browsing via the URL and adding the key works as expected.

Not sure if it's for specific actions in MeshCtrl.js, but ListDevices is not working in my test. If the ?key=[key] is not used, the response is immediate, however when the ?key=[key] is used, the response takes a long time. Neither produce a valid response, but the timing implies that the ?key parameter is causing MC to not handle it properly.

To Reproduce
Steps to reproduce the behavior:

  1. Add 'loginKey': 'bob' to the config.json
  2. Restart MC service
  3. Call this command from remote MeshCtrl.js:
  4. node ./node_modules/meshcentral/meshctrl.js ListDevices --url wss://mydomain.com:443?key=bob --loginkey [encrypted token] --json
  5. Hangs

Expected behavior
?key param should return the devices in json, as it does before enabling the loginKey in config.json.

Server Software (please complete the following information):

  • OS: Ubuntu
  • Network: WAN

Client Device (please complete the following information):

  • Remote machine (Windows and/or Linux)

Your config.json file

{
	"$schema": "https://raw.githubusercontent.com/Ylianst/MeshCentral/master/meshcentral-config-schema.json",
	"__comment1__": "This is a simple configuration file, all values and sections that start with underscore (_) are ignored. Edit a section and remove the _ in front of the name. Refer to the user's guide for details.",
	"__comment2__": "See node_modules/meshcentral/sample-config-advanced.json for a more advanced example.",
	"settings": {
	  "MaxInvalidLogin": {
		"time": 5,
		"count": 5,
		"coolofftime": 30
	  },
	  "plugins": {
		"enabled": true
	  },
	  "cert": [domain],
	  "port": 443,
	  "redirPort": 80,
	  "wanonly": true,
	  "minify": true,
	  "clickonce": true,
	  "webrtc": true,
	  "allowLoginToken": true,
	  "allowFraming": true,
	  "selfupdate": true,
	  "sessionSameSite": "none",
	  "allowHighQualityDesktop": true,
	  "desktopMultiple": true
	},
	"domains": {
	  "": {
		"allowaccountreset": false,
		"welcomePictureFullScreen": false,
		"siteStyle": 2,
		"title": "Remote Access",
		"title2": "",
		"loginKey": "bob",
		"minify": true,
		"userNameIsEmail": true,
		"allowedOrigin": true,
		"httpHeaders": {
			"Strict-Transport-Security": "max-age=3600",
			"Content-Security-Policy": "frame-src * data: blob:; connect-src * wss:;",
			"Access-Control-Allow-Origin": "*",
			"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
			"Access-Control-Allow-Headers": "Origin, Content-Type, Accept, Authorization"
		},
		"agentConfig": [ 
		 {
			 "skipmaccheck": true
		 }
		],
		"mstsc": true,
		"geoLocation": true,
		"lockAgentDownload": false,
		"userConsentFlags": {
			 "desktopnotify": false,
			 "terminalnotify": false,
			 "filenotify": false,
			 "desktopprompt": false,
			 "terminalprompt": false,
			 "fileprompt": false,
			 "desktopprivacybar": true
		},
		"ipBlockedUserRedirect": "https://somedomain.com",
		"newAccounts": false,
		"allowSavingDeviceCredentials": false
	  }
	},
	"letsencrypt": {
		 "__comment": "Requires NodeJS 8.x or better, Go to https://letsdebug.net/ first before trying Let's Encrypt.",
		 "email": [email],
		 "names": [domains],
		 "skipChallengeVerification": true,
		 "production": true
	}
}

@geekasso geekasso added the bug label Aug 15, 2024
@si458
Copy link
Collaborator

si458 commented Aug 15, 2024

I will check tomorrow, but i think you are setting the url incorrectly?
I think it's wss://meshserver.com/?key=bob
But I could be mistaken

@si458
Copy link
Collaborator

si458 commented Aug 16, 2024

ok ive just checked and it works correctly here?

node meshctrl.js --url wss://mc.myserver.com:443?key=a1b2c3d4 --loginuser simon --loginpass mysecretpassword --token 123456 ListDevices

are you sure you are hexing the loginkey correctly in your url?
how did you generate it/where did you get it from?

@si458
Copy link
Collaborator

si458 commented Aug 16, 2024

ok ive just looked, are you sure you are sending all the values that you need?
from the looks of the code
if you use --loginkey,
you need to also specify --loginuser USERNAME otherwise it defaults to admin as the user
ALSO
you need to specify --logindomain MESHDOMAIN if you have multiple domains in meshcentral,
otherwise its the default "" one
you need to also specify --loginuser USERNAME

@si458
Copy link
Collaborator

si458 commented Aug 16, 2024

OOO just spotted a bug too can you spot it?
Connecting to wss://mc.myserver.com:443/control.ashx?key=a1b2c3d4?auth=abc123

si458 added a commit that referenced this issue Aug 16, 2024
Signed-off-by: si458 <simonsmith5521@gmail.com>
@si458
Copy link
Collaborator

si458 commented Aug 16, 2024

ok ive fixed the meshctrl passing loginkey and key=xxx incorrect at the same time
ive also added some more info in webserver.js so it should return if something is wrong!
fa39f8a

@si458 si458 self-assigned this Aug 16, 2024
@geekasso
Copy link
Author

geekasso commented Aug 16, 2024 via email

@si458
Copy link
Collaborator

si458 commented Aug 16, 2024

@geekasso ah right ok no worries! in that case its the bug i mensioned above!
#6328 (comment)
download and replace meshctrl.js with the master one then and it should work now!
https://github.com/Ylianst/MeshCentral/raw/master/meshctrl.js

@si458 si458 closed this as completed Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants