wip
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import secrets
|
||||
from collections.abc import Collection
|
||||
|
||||
from authlib.oauth2.rfc6749 import (
|
||||
ClientMixin,
|
||||
@@ -29,7 +30,7 @@ class OAuth2Client(ClientMixin):
|
||||
def get_client_id(self):
|
||||
return self.client_id
|
||||
|
||||
def get_allowed_scope(self, scope) -> str:
|
||||
def get_allowed_scope(self, scope: Collection[str]) -> str:
|
||||
if not scope:
|
||||
return ''
|
||||
|
||||
@@ -37,24 +38,26 @@ class OAuth2Client(ClientMixin):
|
||||
scopes = scope_to_list(scope)
|
||||
return list_to_scope([s for s in scopes if s in allowed])
|
||||
|
||||
def get_default_redirect_uri(self) -> str: # type: ignore
|
||||
def get_default_redirect_uri(self) -> str:
|
||||
if self.redirect_uris:
|
||||
return self.redirect_uris[0]
|
||||
|
||||
def check_response_type(self, response_type):
|
||||
raise ValueError('Missing redirect_uris')
|
||||
|
||||
def check_response_type(self, response_type: str) -> bool:
|
||||
return response_type in self.response_types
|
||||
|
||||
def check_redirect_uri(self, redirect_uri):
|
||||
def check_redirect_uri(self, redirect_uri: str) -> bool:
|
||||
return redirect_uri in self.redirect_uris
|
||||
|
||||
def check_endpoint_auth_method(self, method, endpoint):
|
||||
def check_endpoint_auth_method(self, method: str, endpoint: str) -> bool:
|
||||
if endpoint == 'token':
|
||||
return self.token_endpoint_auth_method == method
|
||||
|
||||
return True
|
||||
|
||||
def check_grant_type(self, grant_type):
|
||||
def check_grant_type(self, grant_type: str) -> bool:
|
||||
return grant_type in self.grant_types
|
||||
|
||||
def check_client_secret(self, client_secret):
|
||||
def check_client_secret(self, client_secret: str) -> bool:
|
||||
return secrets.compare_digest(self.client_secret, client_secret)
|
||||
|
||||
Reference in New Issue
Block a user