authorization: fix minor typing issues
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
58fa361c8c
commit
8266376f46
|
@ -172,6 +172,7 @@ class Authorization:
|
||||||
self.trusted_domains: List[str] = []
|
self.trusted_domains: List[str] = []
|
||||||
for val in config.getlist('trusted_clients', []):
|
for val in config.getlist('trusted_clients', []):
|
||||||
# Check IP address
|
# Check IP address
|
||||||
|
tc: Union[IPAddr, IPNetwork]
|
||||||
try:
|
try:
|
||||||
tc = ipaddress.ip_address(val)
|
tc = ipaddress.ip_address(val)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -247,7 +248,7 @@ class Authorization:
|
||||||
self._handle_oneshot_request, transports=['http'])
|
self._handle_oneshot_request, transports=['http'])
|
||||||
self.server.register_endpoint(
|
self.server.register_endpoint(
|
||||||
"/access/info", ['GET'],
|
"/access/info", ['GET'],
|
||||||
self._handle_default_source_request, transports=['http'])
|
self._handle_info_request, transports=['http'])
|
||||||
self.server.register_notification("authorization:user_created")
|
self.server.register_notification("authorization:user_created")
|
||||||
self.server.register_notification("authorization:user_deleted")
|
self.server.register_notification("authorization:user_deleted")
|
||||||
|
|
||||||
|
@ -291,9 +292,9 @@ class Authorization:
|
||||||
"action": "user_logged_out"
|
"action": "user_logged_out"
|
||||||
}
|
}
|
||||||
|
|
||||||
async def _handle_default_source_request(self,
|
async def _handle_info_request(
|
||||||
web_request: WebRequest
|
self, web_request: WebRequest
|
||||||
) -> Dict[str, str | List[str]]:
|
) -> Dict[str, Any]:
|
||||||
sources = ["moonraker"]
|
sources = ["moonraker"]
|
||||||
if self.ldap is not None:
|
if self.ldap is not None:
|
||||||
sources.append("ldap")
|
sources.append("ldap")
|
||||||
|
@ -689,7 +690,7 @@ class Authorization:
|
||||||
|
|
||||||
def _check_oneshot_token(self,
|
def _check_oneshot_token(self,
|
||||||
token: str,
|
token: str,
|
||||||
cur_ip: IPAddr
|
cur_ip: Optional[IPAddr]
|
||||||
) -> Optional[Dict[str, Any]]:
|
) -> Optional[Dict[str, Any]]:
|
||||||
if token in self.oneshot_tokens:
|
if token in self.oneshot_tokens:
|
||||||
ip_addr, user, hdl = self.oneshot_tokens.pop(token)
|
ip_addr, user, hdl = self.oneshot_tokens.pop(token)
|
||||||
|
@ -717,7 +718,7 @@ class Authorization:
|
||||||
return jwt_user
|
return jwt_user
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ip = ipaddress.ip_address(request.remote_ip)
|
ip = ipaddress.ip_address(request.remote_ip) # type: ignore
|
||||||
except ValueError:
|
except ValueError:
|
||||||
logging.exception(
|
logging.exception(
|
||||||
f"Unable to Create IP Address {request.remote_ip}")
|
f"Unable to Create IP Address {request.remote_ip}")
|
||||||
|
|
Loading…
Reference in New Issue