mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-25 19:30:54 +00:00
More type hints
This commit is contained in:
parent
11f7559ef3
commit
c93d7b8715
51 changed files with 1374 additions and 957 deletions
|
@ -28,18 +28,23 @@ Take a look at the class ``BaseAuth`` if you want to implement your own.
|
|||
|
||||
"""
|
||||
|
||||
from radicale import utils
|
||||
from typing import Sequence, Tuple, Union
|
||||
|
||||
INTERNAL_TYPES = ("none", "remote_user", "http_x_remote_user", "htpasswd")
|
||||
from radicale import config, types, utils
|
||||
|
||||
INTERNAL_TYPES: Sequence[str] = ("none", "remote_user", "http_x_remote_user",
|
||||
"htpasswd")
|
||||
|
||||
|
||||
def load(configuration):
|
||||
def load(configuration: "config.Configuration") -> "BaseAuth":
|
||||
"""Load the authentication module chosen in configuration."""
|
||||
return utils.load_plugin(INTERNAL_TYPES, "auth", "Auth", configuration)
|
||||
return utils.load_plugin(INTERNAL_TYPES, "auth", "Auth", BaseAuth,
|
||||
configuration)
|
||||
|
||||
|
||||
class BaseAuth:
|
||||
def __init__(self, configuration):
|
||||
|
||||
def __init__(self, configuration: "config.Configuration") -> None:
|
||||
"""Initialize BaseAuth.
|
||||
|
||||
``configuration`` see ``radicale.config`` module.
|
||||
|
@ -49,7 +54,8 @@ class BaseAuth:
|
|||
"""
|
||||
self.configuration = configuration
|
||||
|
||||
def get_external_login(self, environ):
|
||||
def get_external_login(self, environ: types.WSGIEnviron) -> Union[
|
||||
Tuple[()], Tuple[str, str]]:
|
||||
"""Optionally provide the login and password externally.
|
||||
|
||||
``environ`` a dict with the WSGI environment
|
||||
|
@ -61,7 +67,7 @@ class BaseAuth:
|
|||
"""
|
||||
return ()
|
||||
|
||||
def login(self, login, password):
|
||||
def login(self, login: str, password: str) -> str:
|
||||
"""Check credentials and map login to internal user
|
||||
|
||||
``login`` the login name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue