Skip to content

Commit

Permalink
feat: add src/netius/auth
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo-gomes committed Dec 21, 2023
1 parent b33d943 commit afcf6d8
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 7 deletions.
12 changes: 12 additions & 0 deletions src/netius/auth/address.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import netius.auth.base
import netius.auth.base as base

from typing import Literal

class AddressAuth(netius.auth.base.Auth):
def __init__(self, allowed: list = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, allowed: list = ..., *args, **kwargs) -> bool: ...
@classmethod
def is_simple(cls) -> Literal[True]: ...
def auth_i(self, *args, **kwargs): ...
10 changes: 10 additions & 0 deletions src/netius/auth/allow.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import netius.auth.base
import netius.auth.base as base

from typing import Literal

class AllowAuth(netius.auth.base.Auth):
@classmethod
def auth(cls, *args, **kwargs) -> Literal[True]: ...
@classmethod
def is_simple(cls) -> Literal[True]: ...
26 changes: 19 additions & 7 deletions src/netius/auth/base.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
from typing import Literal
import netius as netius

HashType = Literal["plain", "md5", "sha1", "sha256", "sha512"]
from typing import Any, Literal, NoReturn, PathLike, Unbound

class Auth(object):
class Auth:
def __init__(self, *args, **kwargs) -> None: ...
@classmethod
def auth(cls, *args, **kwargs) -> NoReturn: ...
@classmethod
def meta(cls, *args, **kwargs) -> dict: ...
@classmethod
def auth_assert(cls, *args, **kwargs) -> None: ...
@classmethod
def verify(cls, encoded: str, decoded: str) -> bool: ...

@classmethod
def generate(cls, password: str, type: HashType = "sha256", salt: str = "netius") -> str: ...

def generate(cls, password: str, type: str = ..., salt: str = ...) -> str: ...
@classmethod
def unpack(cls, password) -> tuple[Any | Literal["plain"], bytes | Any | str | None, Any | None, Unbound | Any | None]: ...
@classmethod
def get_file(cls, path: PathLike[str], cache: bool = ..., encoding: str | None = ...) -> (Any | str | bytes): ...
@classmethod
def unpack(cls, password: str) -> tuple[HashType, str, str, str]: ...
def is_simple(cls) -> Literal[False]: ...
def auth_i(self, *args, **kwargs) -> NoReturn: ...
def auth_assert_i(self, *args, **kwargs) -> None: ...
def is_simple_i(self) -> Literal[False]: ...
10 changes: 10 additions & 0 deletions src/netius/auth/deny.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import netius.auth.base
import netius.auth.base as base

from typing import Literal

class DenyAuth(netius.auth.base.Auth):
@classmethod
def auth(cls, *args, **kwargs) -> Literal[False]: ...
@classmethod
def is_simple(cls) -> Literal[True]: ...
12 changes: 12 additions & 0 deletions src/netius/auth/dummy.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import netius.auth.base
import netius.auth.base as base

from typing import Literal

class DummyAuth(netius.auth.base.Auth):
def __init__(self, value: bool = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, value: bool = ..., *args, **kwargs) -> bool: ...
@classmethod
def is_simple(cls) -> Literal[True]: ...
def auth_i(self, *args, **kwargs) -> bool: ...
17 changes: 17 additions & 0 deletions src/netius/auth/memory.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import netius as netius
import netius.auth.base
import netius.auth.base as base

from typing import Dict

class MemoryAuth(netius.auth.base.Auth):
def __init__(self, registry: Dict | None = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, username: str, password: str, registry: dict | None = ..., *args, **kwargs) -> bool: ...
@classmethod
def meta(cls, username: str, registry: Dict | None = ..., *args, **kwargs) -> Dict: ...
@classmethod
def get_registry(cls): ...
@classmethod
def load_registry(cls): ...
def auth_i(self, username: str, password: str, *args, **kwargs) -> bool: ...
12 changes: 12 additions & 0 deletions src/netius/auth/passwd.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import netius.auth.base
import netius.auth.base as base

from typing import PathLike, Any, Dict

class PasswdAuth(netius.auth.base.Auth):
def __init__(self, path: PathLike[str] | None = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, username: str, password: str, path: str = ..., *args, **kwargs) -> bool: ...
@classmethod
def get_passwd(cls, path: PathLike[str], cache: bool = ...) -> (Any | Dict): ...
def auth_i(self, username: str, password: str, *args, **kwargs) -> bool: ...
10 changes: 10 additions & 0 deletions src/netius/auth/simple.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import netius.auth.base
import netius.auth.base as base

from typing import Tuple

class SimpleAuth(netius.auth.base.Auth):
def __init__(self, username: str | None = ..., password: str | None = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, username: str, password: str, target: Tuple[str:str] | None = ..., *args, **kwargs) -> bool: ...
def auth_i(self, username:str , password: str, *args, **kwargs) -> bool: ...

0 comments on commit afcf6d8

Please sign in to comment.