use default profile by default

This commit is contained in:
Kay0u 2020-01-02 12:14:23 +08:00
parent d51bb55573
commit 6f7f870d3d
No known key found for this signature in database
GPG key ID: 7FF262C033518333

View file

@ -256,10 +256,8 @@ class _ActionsMapPlugin(object):
kwargs["password"] = request.POST["password"]
except KeyError:
raise HTTPBadRequestResponse("Missing password parameter")
try:
kwargs["profile"] = request.POST["profile"]
except KeyError:
pass
kwargs["profile"] = request.POST.get("profile", "default")
return callback(**kwargs)
return wrapper
@ -351,7 +349,7 @@ class _ActionsMapPlugin(object):
# Routes callbacks
def login(self, password, profile="default"):
def login(self, password, profile):
"""Log in to an authenticator profile
Attempt to authenticate to a given authenticator profile and
@ -406,13 +404,11 @@ class _ActionsMapPlugin(object):
"""
s_id = request.get_cookie("session.id")
try:
# We check that there's a (signed) session.hash available
# for additional security ?
# (An attacker could not craft such signed hashed ? (FIXME : need to make sure of this))
s_secret = self.secrets[s_id]
request.get_cookie("session.tokens", secret=s_secret, default={})[profile]
except KeyError:
# We check that there's a (signed) session.hash available
# for additional security ?
# (An attacker could not craft such signed hashed ? (FIXME : need to make sure of this))
s_secret = self.secrets[s_id]
if profile not in request.get_cookie("session.tokens", secret=s_secret, default={}):
raise HTTPUnauthorizedResponse(m18n.g("not_logged_in"))
else:
del self.secrets[s_id]