MKP 2.4.1, removed token parameter, switch to app password parameter only
This commit is contained in:
parent
714990bffb
commit
05415a8d1d
@ -16,26 +16,24 @@ def showUsage():
|
|||||||
|
|
||||||
USAGE: agent_nextcloud_info -u [username] -p [password]
|
USAGE: agent_nextcloud_info -u [username] -p [password]
|
||||||
OR
|
OR
|
||||||
agent_nextcloud_info -u [username] -t [token]
|
|
||||||
agent_nextcloud_info -h
|
agent_nextcloud_info -h
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
-H, --hostname Hostname (FQDN or IP) of Nextcloud server
|
-H, --hostname Hostname (FQDN or IP) of Nextcloud server
|
||||||
-u, --username Username
|
-u, --username Username
|
||||||
-p, --password Password
|
-p, --password App Password
|
||||||
-P, --port Port
|
-P, --port Port
|
||||||
-f, --folder Subfolder if not installed in web root
|
-f, --folder Subfolder if not installed in web root
|
||||||
-t, --token Token (recommended)
|
|
||||||
--no-https True|False If "True": Disable HTTPS, use HTTP (not recommended!)
|
--no-https True|False If "True": Disable HTTPS, use HTTP (not recommended!)
|
||||||
--no-cert-check True|False If "True": Disable TLS certificate check (not recommended!)
|
--no-cert-check True|False If "True": Disable TLS certificate check (not recommended!)
|
||||||
-h, --help Show this help message and exit
|
-h, --help Show this help message and exit
|
||||||
""")
|
""")
|
||||||
|
|
||||||
# set this to true to produce debug output (this clutters the agent output)
|
# set this to true to produce debug output (this clutters the agent output)
|
||||||
# be aware: activating this logs very sensitive information to debug files in ~/tmp
|
# be aware: activating this flag logs very sensitive information to debug files in ~/tmp
|
||||||
# !!DO NOT FORGET to delete these files after debugging is done!!
|
# !!DO NOT FORGET to delete these files after debugging is done!!
|
||||||
|
|
||||||
DEBUG = True
|
DEBUG = False
|
||||||
|
|
||||||
nc_api_endpoint = "ocs/v2.php/apps/serverinfo/api/v1/info?format=json"
|
nc_api_endpoint = "ocs/v2.php/apps/serverinfo/api/v1/info?format=json"
|
||||||
nc_api_endpoint_all_users = "ocs/v1.php/cloud/users?format=json"
|
nc_api_endpoint_all_users = "ocs/v1.php/cloud/users?format=json"
|
||||||
@ -46,13 +44,12 @@ opt_username = ""
|
|||||||
opt_password = ""
|
opt_password = ""
|
||||||
opt_port = ""
|
opt_port = ""
|
||||||
opt_folder = ""
|
opt_folder = ""
|
||||||
opt_token = "0"
|
|
||||||
opt_no_https = False
|
opt_no_https = False
|
||||||
opt_no_cert_check = False
|
opt_no_cert_check = False
|
||||||
|
|
||||||
short_options = 'hH:u:p:P:f:t:'
|
short_options = 'hH:u:p:P:f:'
|
||||||
long_options = [
|
long_options = [
|
||||||
'hostname=', 'username=', 'password=', 'port=', 'token=', 'folder=', 'no-https=', 'no-cert-check=', 'help'
|
'hostname=', 'username=', 'password=', 'port=', 'folder=', 'no-https=', 'no-cert-check=', 'help'
|
||||||
]
|
]
|
||||||
|
|
||||||
def logDebug(line):
|
def logDebug(line):
|
||||||
@ -70,7 +67,6 @@ def getOptions():
|
|||||||
global opt_password
|
global opt_password
|
||||||
global opt_port
|
global opt_port
|
||||||
global opt_folder
|
global opt_folder
|
||||||
global opt_token
|
|
||||||
global opt_no_https
|
global opt_no_https
|
||||||
global opt_no_cert_check
|
global opt_no_cert_check
|
||||||
|
|
||||||
@ -86,8 +82,6 @@ def getOptions():
|
|||||||
opt_port = arg
|
opt_port = arg
|
||||||
elif opt in ['-f', '--folder']:
|
elif opt in ['-f', '--folder']:
|
||||||
opt_folder = arg
|
opt_folder = arg
|
||||||
elif opt in ['-t', '--token']:
|
|
||||||
opt_token = arg
|
|
||||||
elif opt in ['--no-https']:
|
elif opt in ['--no-https']:
|
||||||
if arg == 'True':
|
if arg == 'True':
|
||||||
opt_no_https = True
|
opt_no_https = True
|
||||||
@ -109,13 +103,12 @@ def showOptions():
|
|||||||
print(f"Password: {opt_password}")
|
print(f"Password: {opt_password}")
|
||||||
print(f"Port: {opt_port}")
|
print(f"Port: {opt_port}")
|
||||||
print(f"Folder: {opt_folder}")
|
print(f"Folder: {opt_folder}")
|
||||||
print(f"Token: {opt_token}")
|
|
||||||
print(f"No HTTPS: {opt_no_https}")
|
print(f"No HTTPS: {opt_no_https}")
|
||||||
print(f"No TLS Check: {opt_no_cert_check}")
|
print(f"No TLS Check: {opt_no_cert_check}")
|
||||||
logDebug(f"showOptions - Hostname: {opt_hostname}, Port: {opt_port}, No HTTPS: {opt_no_https}, No Cert Check: {opt_no_cert_check}\n")
|
logDebug(f"showOptions - Hostname: {opt_hostname}, Port: {opt_port}, No HTTPS: {opt_no_https}, No Cert Check: {opt_no_cert_check}\n")
|
||||||
|
|
||||||
def createUrl(endpoint, hostname, protocol, port, folder):
|
def createUrl(endpoint, hostname, protocol, port, folder):
|
||||||
# these parameters are needed, otherwise no information about updates regarding apps and Nextcloud itself are not reported (since version 28)
|
# these parameters are needed, otherwise no information about updates regarding apps and Nextcloud itself are reported (since version 28)
|
||||||
params = "skipApps=false&skipUpdate=false"
|
params = "skipApps=false&skipUpdate=false"
|
||||||
if folder == "":
|
if folder == "":
|
||||||
url = f"{protocol}://{hostname}:{port}/{endpoint}"
|
url = f"{protocol}://{hostname}:{port}/{endpoint}"
|
||||||
@ -264,6 +257,14 @@ def main():
|
|||||||
sys.stderr.write(f"No hostname given.\n")
|
sys.stderr.write(f"No hostname given.\n")
|
||||||
showUsage()
|
showUsage()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
if (opt_username == ""):
|
||||||
|
sys.stderr.write(f"No username given.\n")
|
||||||
|
showUsage()
|
||||||
|
sys.exit(1)
|
||||||
|
if (opt_password == ""):
|
||||||
|
sys.stderr.write(f"No password given.\n")
|
||||||
|
showUsage()
|
||||||
|
sys.exit(1)
|
||||||
if (opt_no_cert_check):
|
if (opt_no_cert_check):
|
||||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||||
verify = False
|
verify = False
|
||||||
@ -290,12 +291,7 @@ def main():
|
|||||||
if (protocol == "https" and port == "80"):
|
if (protocol == "https" and port == "80"):
|
||||||
sys.stderr.write(f"Combining HTTPS with port 80 is not supported.\n")
|
sys.stderr.write(f"Combining HTTPS with port 80 is not supported.\n")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if (opt_token == '0'):
|
|
||||||
# authenticate with username and password
|
|
||||||
pwd = opt_password
|
pwd = opt_password
|
||||||
else:
|
|
||||||
# authenticate with token
|
|
||||||
pwd = opt_token
|
|
||||||
|
|
||||||
# create session
|
# create session
|
||||||
session = getSession(opt_username, pwd)
|
session = getSession(opt_username, pwd)
|
||||||
|
@ -2,8 +2,7 @@ def agent_nextcloud_arguments(params, hostname, ipaddress):
|
|||||||
return [
|
return [
|
||||||
"--hostname", params["hostname"],
|
"--hostname", params["hostname"],
|
||||||
"--username", params["username"],
|
"--username", params["username"],
|
||||||
"--password", params["password"],
|
"--password", passwordstore_get_cmdline("%s", params["password"]),
|
||||||
"--token", passwordstore_get_cmdline("%s", params["token"]),
|
|
||||||
"--port", params["port"],
|
"--port", params["port"],
|
||||||
"--folder", params["folder"],
|
"--folder", params["folder"],
|
||||||
"--no-https", params["no_https"],
|
"--no-https", params["no_https"],
|
||||||
|
@ -26,19 +26,19 @@ def _valuespec_special_agent_nextcloud():
|
|||||||
elements=[
|
elements=[
|
||||||
("hostname", TextAscii(title=_("Hostname"),
|
("hostname", TextAscii(title=_("Hostname"),
|
||||||
allow_empty=False,
|
allow_empty=False,
|
||||||
help=_("Hostname of Nextcloud server (bare FQDN or IP, IP not tested), mandatory"))),
|
size = 40,
|
||||||
|
help=_("Hostname of Nextcloud server (bare FQDN or IP), mandatory, eg. nextcloud.yourdomain.tld"))),
|
||||||
("username", TextAscii(title=_("Username"),
|
("username", TextAscii(title=_("Username"),
|
||||||
|
size = 40,
|
||||||
allow_empty=False,
|
allow_empty=False,
|
||||||
help=_("Username with administrative rights, mandatory"))),
|
help=_("Username with administrative rights, mandatory"))),
|
||||||
("password", Password(title=_("Password"),
|
("password", IndividualOrStoredPassword(title=_("App Password"),
|
||||||
allow_empty=True,
|
size = 40,
|
||||||
help=_("Specify password OR token, not both, token recommended"))),
|
allow_empty=False,
|
||||||
("token", IndividualOrStoredPassword(title=_("App Password"),
|
help=_("Specify app password, mandatory, use Personal Settings|Security|Devices and Sessions within the NC UI to create one for the given user"))),
|
||||||
allow_empty=True,
|
|
||||||
help=_("Specify password OR token, not both, token recommended"))),
|
|
||||||
("port", TextAscii(title=_("Port"),
|
("port", TextAscii(title=_("Port"),
|
||||||
allow_empty=True,
|
allow_empty=True,
|
||||||
help=_("Specify port if not listening to HTTPS, optional"))),
|
help=_("Specify port if not listening to HTTP(S), optional"))),
|
||||||
("folder", TextAscii(title=_("Folder"),
|
("folder", TextAscii(title=_("Folder"),
|
||||||
allow_empty=True,
|
allow_empty=True,
|
||||||
help=_("Specify subfolder if your Nextcloud instance is not installed in the web root, no trailing/leading slashes, optional"))),
|
help=_("Specify subfolder if your Nextcloud instance is not installed in the web root, no trailing/leading slashes, optional"))),
|
||||||
|
BIN
mkp/Nextcloud-2.4.1.mkp
Normal file
BIN
mkp/Nextcloud-2.4.1.mkp
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user