mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
initial support for identity providers (#62):
add argument --hdr-au-usr which specifies a HTTP header to read usernames from; entirely bypasses copyparty's password checks for http/https clients (ftp/smb are unaffected) users must exist in the copyparty config, passwords can be whatever just the first step but already a bit useful on its own, more to come in a few months
This commit is contained in:
parent
8c52b88767
commit
ccab44daf2
|
@ -919,6 +919,11 @@ def add_cert(ap, cert_path):
|
|||
ap2.add_argument("--crt-alg", metavar="S-N", type=u, default="ecdsa-256", help="algorithm and keysize; one of these: ecdsa-256 rsa-4096 rsa-2048")
|
||||
|
||||
|
||||
def add_auth(ap):
|
||||
ap2 = ap.add_argument_group('user authentication options')
|
||||
ap2.add_argument("--hdr-au-usr", metavar="HN", type=u, default="", help="bypass the copyparty authentication checks and assume the request-header \033[33mHN\033[0m contains the username of the requesting user (for use with authentik/oauth/...)\n\033[1;31mWARNING:\033[0m if you enable this feature, make sure clients are unable to specify this header themselves; must be washed away and replaced by a reverse-proxy. Also, the argument must be lowercase, but not the actual header")
|
||||
|
||||
|
||||
def add_zeroconf(ap):
|
||||
ap2 = ap.add_argument_group("Zeroconf options")
|
||||
ap2.add_argument("-z", action="store_true", help="enable all zeroconf backends (mdns, ssdp)")
|
||||
|
|
|
@ -439,8 +439,16 @@ class HttpCli(object):
|
|||
except:
|
||||
pass
|
||||
|
||||
if self.args.hdr_au_usr:
|
||||
self.pw = ""
|
||||
self.uname = self.headers.get(self.args.hdr_au_usr) or "*"
|
||||
if self.uname not in self.asrv.vfs.aread:
|
||||
self.loud_reply("unknown username: [%s]" % (self.uname), 401)
|
||||
return False
|
||||
else:
|
||||
self.pw = uparam.get("pw") or self.headers.get("pw") or bauth or cookie_pw
|
||||
self.uname = self.asrv.iacct.get(self.asrv.ah.hash(self.pw)) or "*"
|
||||
|
||||
self.rvol = self.asrv.vfs.aread[self.uname]
|
||||
self.wvol = self.asrv.vfs.awrite[self.uname]
|
||||
self.mvol = self.asrv.vfs.amove[self.uname]
|
||||
|
|
Loading…
Reference in a new issue