Skip to content

Commit

Permalink
Merge pull request #38 from hivesolutions/src/netius/auth
Browse files Browse the repository at this point in the history
feat: add src/netius/auth to typing
  • Loading branch information
joamag authored Dec 27, 2023
2 parents c669afb + 99087bd commit 9c79e15
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/netius/auth/address.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from typing import Sequence

from netius import Auth

class AddressAuth(Auth):
def __init__(self, allowed: Sequence[str] = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, allowed: Sequence[str] = ..., *args, **kwargs) -> bool: ...
4 changes: 4 additions & 0 deletions src/netius/auth/allow.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from netius import Auth

class AllowAuth(Auth):
pass
26 changes: 20 additions & 6 deletions src/netius/auth/base.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
from typing import Literal
from typing import Any, Literal, NoReturn, PathLike

HashType = Literal["plain", "md5", "sha1", "sha256", "sha512"]
HashType = Literal["plain", "md5", "sha1", "sha256", "sha512"]

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

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

@classmethod
def unpack(cls, password: str) -> tuple[HashType, str, str, str]: ...
def unpack(cls, password) -> tuple[HashType, str | None, str, str | None]: ...
@classmethod
def get_file(
cls, path: PathLike[str], cache: bool = ..., encoding: str | None = ...
) -> str | bytes: ...
@classmethod
def is_simple(cls) -> bool: ...
def auth_i(self, *args, **kwargs) -> bool: ...
def auth_assert_i(self, *args, **kwargs) -> NoReturn: ...
def is_simple_i(self) -> bool: ...
4 changes: 4 additions & 0 deletions src/netius/auth/deny.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from netius import Auth

class DenyAuth(Auth):
pass
6 changes: 6 additions & 0 deletions src/netius/auth/dummy.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from netius import Auth

class DummyAuth(Auth):
def __init__(self, value: bool = ..., *args, **kwargs) -> None: ...
@classmethod
def auth(cls, value: bool = ..., *args, **kwargs) -> bool: ...
25 changes: 25 additions & 0 deletions src/netius/auth/memory.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from typing import Any

from netius import Auth

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

from netius import Auth

class PasswdAuth(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 = ...) -> dict[str, str]: ...
def auth_i(self, username: str, password: str, *args, **kwargs) -> bool: ...
18 changes: 18 additions & 0 deletions src/netius/auth/simple.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from typing import Sequence

from netius import Auth

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

0 comments on commit 9c79e15

Please sign in to comment.