1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
"""Credential Store Extension"""
import typing as t
if t.TYPE_CHECKING:
from gssapi.raw.creds import Creds
from gssapi.raw.named_tuples import AcquireCredResult, StoreCredResult
from gssapi.raw.names import Name
from gssapi.raw.oids import OID
def acquire_cred_from(
dict_store: t.Optional[
t.Dict[t.Union[bytes, str], t.Union[bytes, str]]
] = None,
name: t.Optional["Name"] = None,
lifetime: t.Optional[int] = None,
mechs: t.Optional[t.Iterable["OID"]] = None,
usage: str = 'both',
) -> "AcquireCredResult":
"""Acquire credentials from the given store.
This method acquires credentials from the store specified by the
given credential store information.
The credential store information is a dictionary containing
mechanisms-specific keys and values pointing to a credential store
or stores.
Args:
store (dict): the credential store information pointing to the
credential store from which to acquire the credentials.
See :doc:`credstore` for valid values
name (~gssapi.raw.names.Name): the name associated with the
credentials, or None for the default name
lifetime (int): the desired lifetime of the credentials in seconds, or
None for indefinite
mechs (list): the desired mechanisms to be used with these
credentials, or None for the default set
usage (str): the usage for these credentials -- either 'both',
'initiate', or 'accept'
Returns:
AcquireCredResult: the acquired credentials and information about
them
Raises:
~gssapi.exceptions.GSSError
"""
def add_cred_from(
dict_store: t.Optional[
t.Dict[t.Union[bytes, str], t.Union[bytes, str]]
],
input_creds: "Creds",
name: "Name",
mech: "OID",
usage: str = 'both',
init_lifetime: t.Optional[int] = None,
accept_lifetime: t.Optional[int] = None,
) -> "AcquireCredResult":
"""Acquire credentials to add to the current set from the given store.
This method works like :func:`acquire_cred_from`, except that it
adds the acquired credentials for a single mechanism to a copy of
the current set, instead of creating a new set for multiple mechanisms.
Unlike :func:`~gssapi.raw.creds.acquire_cred`, you cannot pass None for the
desired name or mechanism.
The credential store information is a dictionary containing
mechanisms-specific keys and values pointing to a credential store
or stores.
Args:
store (dict): the store into which to store the credentials,
or None for the default store.
See :doc:`credstore` for valid values
name (~gssapi.raw.names.Name): the name associated with the credentials
mech (~gssapi.OID): the desired mechanism to be used with these
credentials
usage (str): the usage for these credentials -- either 'both',
'initiate', or 'accept'
init_lifetime (int): the desired initiate lifetime of the credentials
in seconds, or None for indefinite
accept_lifetime (int): the desired accept lifetime of the credentials
in seconds, or None for indefinite
Returns:
AcquireCredResult: the new credentials set and information about
it
Raises:
~gssapi.exceptions.GSSError
"""
def store_cred_into(
dict_store: t.Optional[
t.Dict[t.Union[bytes, str], t.Union[bytes, str]]
],
creds: "Creds",
usage: str = 'both',
mech: t.Optional["OID"] = None,
overwrite: bool = False,
set_default: bool = False,
) -> "StoreCredResult":
"""Store credentials into the given store.
This method stores the given credentials into the store specified
by the given store information. They may then be retrieved later using
:func:`acquire_cred_from` or :func:`add_cred_from`.
The credential store information is a dictionary containing
mechanisms-specific keys and values pointing to a credential store
or stores.
Args:
store (dict): the store into which to store the credentials,
or None for the default store.
See :doc:`credstore` for valid values
creds (Creds): the credentials to store
usage (str): the usage to store the credentials with -- either
'both', 'initiate', or 'accept'
mech (~gssapi.OID): the mechansim to associate with the stored
credentials
overwrite (bool): whether or not to overwrite existing credentials
stored with the same name, etc
set_default (bool): whether or not to set these credentials as
the default credentials for the given store.
Returns:
StoreCredResult: the results of the credential storing operation
Raises:
~gssapi.exceptions.GSSError
"""
|