Added the get_opaque inline function in the make_response_header method of the DigestAuth class for readability.
This commit is contained in:
parent
f473db29a8
commit
9616fb3ddc
@ -203,9 +203,19 @@ class DigestAuth:
|
|||||||
:param state: The authorization state.
|
:param state: The authorization state.
|
||||||
:return: The WWW-Authenticate response header.
|
:return: The WWW-Authenticate response header.
|
||||||
"""
|
"""
|
||||||
opaque: t.Optional[str] = None if not self.use_opaque else \
|
|
||||||
(state.opaque if state.opaque is not None
|
def get_opaque() -> t.Optional[str]:
|
||||||
else self.serializer.dumps(randbits(32), salt="opaque"))
|
"""Returns the opaque value.
|
||||||
|
|
||||||
|
:return: The opaque value.
|
||||||
|
"""
|
||||||
|
if not self.use_opaque:
|
||||||
|
return None
|
||||||
|
if state.opaque is not None:
|
||||||
|
return state.opaque
|
||||||
|
return self.serializer.dumps(randbits(32), salt="opaque")
|
||||||
|
|
||||||
|
opaque: t.Optional[str] = get_opaque()
|
||||||
nonce: str = self.serializer.dumps(
|
nonce: str = self.serializer.dumps(
|
||||||
randbits(32),
|
randbits(32),
|
||||||
salt="nonce" if opaque is None else f"nonce-{opaque}")
|
salt="nonce" if opaque is None else f"nonce-{opaque}")
|
||||||
|
Loading…
Reference in New Issue
Block a user