*: replace tuple and set from typing with normal

This commit is contained in:
Jens Langhammer 2021-02-18 13:53:57 +01:00
parent ecff810021
commit e4f0613fab
4 changed files with 7 additions and 8 deletions

View File

@ -1,7 +1,7 @@
"""API Authentication""" """API Authentication"""
from base64 import b64decode from base64 import b64decode
from binascii import Error from binascii import Error
from typing import Any, Optional, Tuple, Union from typing import Any, Optional, Union
from rest_framework.authentication import BaseAuthentication, get_authorization_header from rest_framework.authentication import BaseAuthentication, get_authorization_header
from rest_framework.request import Request from rest_framework.request import Request
@ -44,7 +44,7 @@ def token_from_header(raw_header: bytes) -> Optional[Token]:
class AuthentikTokenAuthentication(BaseAuthentication): class AuthentikTokenAuthentication(BaseAuthentication):
"""Token-based authentication using HTTP Basic authentication""" """Token-based authentication using HTTP Basic authentication"""
def authenticate(self, request: Request) -> Union[Tuple[User, Any], None]: def authenticate(self, request: Request) -> Union[tuple[User, Any], None]:
"""Token-based authentication using HTTP Basic authentication""" """Token-based authentication using HTTP Basic authentication"""
auth = get_authorization_header(request) auth = get_authorization_header(request)

View File

@ -1,6 +1,5 @@
"""Docker controller""" """Docker controller"""
from time import sleep from time import sleep
from typing import Tuple
from django.conf import settings from django.conf import settings
from docker import DockerClient from docker import DockerClient
@ -55,7 +54,7 @@ class DockerController(BaseController):
return True return True
return False return False
def _get_container(self) -> Tuple[Container, bool]: def _get_container(self) -> tuple[Container, bool]:
container_name = f"authentik-proxy-{self.outpost.uuid.hex}" container_name = f"authentik-proxy-{self.outpost.uuid.hex}"
try: try:
return self.client.containers.get(container_name), False return self.client.containers.get(container_name), False

View File

@ -2,7 +2,7 @@
import re import re
from base64 import b64decode from base64 import b64decode
from binascii import Error from binascii import Error
from typing import Optional, Tuple from typing import Optional
from django.http import HttpRequest, HttpResponse, JsonResponse from django.http import HttpRequest, HttpResponse, JsonResponse
from django.utils.cache import patch_vary_headers from django.utils.cache import patch_vary_headers
@ -68,7 +68,7 @@ def extract_access_token(request: HttpRequest) -> Optional[str]:
return None return None
def extract_client_auth(request: HttpRequest) -> Tuple[str, str]: def extract_client_auth(request: HttpRequest) -> tuple[str, str]:
""" """
Get client credentials using HTTP Basic Authentication method. Get client credentials using HTTP Basic Authentication method.
Or try getting parameters via POST. Or try getting parameters via POST.

View File

@ -1,7 +1,7 @@
"""authentik OAuth2 Authorization views""" """authentik OAuth2 Authorization views"""
from dataclasses import dataclass, field from dataclasses import dataclass, field
from datetime import timedelta from datetime import timedelta
from typing import Optional, Set from typing import Optional
from urllib.parse import parse_qs, urlencode, urlsplit, urlunsplit from urllib.parse import parse_qs, urlencode, urlsplit, urlunsplit
from uuid import uuid4 from uuid import uuid4
@ -72,7 +72,7 @@ class OAuthAuthorizationParams:
scope: list[str] scope: list[str]
state: str state: str
nonce: Optional[str] nonce: Optional[str]
prompt: Set[str] prompt: set[str]
grant_type: str grant_type: str
provider: OAuth2Provider = field(default_factory=OAuth2Provider) provider: OAuth2Provider = field(default_factory=OAuth2Provider)