mirror of
https://github.com/9001/copyparty.git
synced 2026-01-12 07:44:08 -07:00
u2c: add --ba argument to use basicauth instead of PW header
This allows using u2c.py with a copyparty server behind a reverseproxy which enforces authentication through basicauth Also expands the BadAuth check to status 401. Closes #1150
This commit is contained in:
parent
4642d32366
commit
76eef78374
|
|
@ -195,7 +195,10 @@ class HCli(object):
|
|||
|
||||
hdrs.update(self.base_hdrs)
|
||||
if self.ar.a:
|
||||
hdrs["PW"] = self.ar.a
|
||||
if self.ar.ba:
|
||||
hdrs["Authorization"] = "Basic " + base64.b64encode(self.ar.a.encode("utf-8")).decode("utf-8")
|
||||
else:
|
||||
hdrs["PW"] = self.ar.a
|
||||
if ctype:
|
||||
hdrs["Content-Type"] = ctype
|
||||
if meth == "POST" and CLEN not in hdrs:
|
||||
|
|
@ -857,7 +860,7 @@ def handshake(ar, file, search):
|
|||
return [], False
|
||||
elif sc == 409 or "<pre>upload rejected, file already exists" in txt:
|
||||
return [], False
|
||||
elif sc == 403:
|
||||
elif sc == 403 or sc == 401:
|
||||
print("\nERROR: login required, or wrong password:\n%s" % (txt,))
|
||||
raise BadAuth()
|
||||
|
||||
|
|
@ -1551,6 +1554,7 @@ NOTE: if server has --usernames enabled, then password is "username:password"
|
|||
ap.add_argument("files", type=files_decoder, nargs="+", help="files and/or folders to process")
|
||||
ap.add_argument("-v", action="store_true", help="verbose")
|
||||
ap.add_argument("-a", metavar="PASSWD", help="password or $filepath")
|
||||
ap.add_argument("--ba", action="store_true", help="use basic auth instead of PW header")
|
||||
ap.add_argument("-s", action="store_true", help="file-search (disables upload)")
|
||||
ap.add_argument("-x", type=unicode, metavar="REGEX", action="append", help="skip file if filesystem-abspath matches REGEX (option can be repeated), example: '.*/\\.hist/.*'")
|
||||
ap.add_argument("--ok", action="store_true", help="continue even if some local files are inaccessible")
|
||||
|
|
|
|||
Loading…
Reference in a new issue