1"""Collection of classes for various Vault auth methods."""
2
3import warnings
4
5from hvac.api.auth_methods.approle import AppRole
6from hvac.api.auth_methods.azure import Azure
7from hvac.api.auth_methods.gcp import Gcp
8from hvac.api.auth_methods.github import Github
9from hvac.api.auth_methods.jwt import JWT
10from hvac.api.auth_methods.kubernetes import Kubernetes
11from hvac.api.auth_methods.ldap import Ldap
12from hvac.api.auth_methods.userpass import Userpass
13from hvac.api.auth_methods.mfa import Mfa
14from hvac.api.auth_methods.oidc import OIDC
15from hvac.api.auth_methods.okta import Okta
16from hvac.api.auth_methods.radius import Radius
17from hvac.api.auth_methods.token import Token
18from hvac.api.auth_methods.aws import Aws
19from hvac.api.auth_methods.cert import Cert
20from hvac.api.vault_api_category import VaultApiCategory
21from hvac.utils import generate_method_deprecation_message
22
23__all__ = (
24    "AuthMethods",
25    "AppRole",
26    "Azure",
27    "Gcp",
28    "Github",
29    "JWT",
30    "Kubernetes",
31    "Ldap",
32    "Userpass",
33    "Mfa",
34    "OIDC",
35    "Okta",
36    "Radius",
37    "Token",
38    "Aws",
39    "Cert",
40)
41
42
43class AuthMethods(VaultApiCategory):
44    """Auth Methods."""
45
46    implemented_classes = [
47        AppRole,
48        Azure,
49        Github,
50        Gcp,
51        JWT,
52        Kubernetes,
53        Ldap,
54        Userpass,
55        Mfa,
56        OIDC,
57        Okta,
58        Radius,
59        Token,
60        Aws,
61        Cert,
62    ]
63    unimplemented_classes = [
64        "AppId",
65        "AliCloud",
66    ]
67
68    def __call__(self, *args, **kwargs):
69        """Implement callable magic method for backwards compatibility.
70
71        Older versions of hvac.Client had an auth method that has now been replaced with an "auth" property pointing to
72        this class.
73        """
74        deprecation_message = generate_method_deprecation_message(
75            to_be_removed_in_version="0.9.0",
76            old_method_name="auth",
77            method_name="login",
78            module_name="adapters.Request",
79        )
80        warnings.simplefilter("always", DeprecationWarning)
81        warnings.warn(
82            message=deprecation_message,
83            category=DeprecationWarning,
84            stacklevel=2,
85        )
86        warnings.simplefilter("default", DeprecationWarning)
87
88        return self._adapter.login(*args, **kwargs)
89