keystoneauth1.identity.v3.base 模块

class keystoneauth1.identity.v3.base.Auth(auth_url: str, auth_methods: list[AuthMethod], *, unscoped: bool = False, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True)

基础: BaseAuth

Identity V3 身份验证插件。

参数:
  • auth_url (string) – 身份服务端点,用于身份验证。

  • auth_methods (list) – 用于身份验证的方法集合。

  • trust_id (string) – 信任范围的信任 ID。

  • domain_id (string) – 域 ID,用于域范围限定。

  • domain_name (string) – 域名称,用于域范围限定。

  • project_id (string) – 项目 ID,用于项目范围限定。

  • project_name (string) – 项目名称,用于项目范围限定。

  • project_domain_id (string) – 项目的域 ID,用于项目。

  • project_domain_name (string) – 项目的域名称,用于项目。

  • reauthenticate (bool) – 允许在当前令牌即将过期时获取新的令牌。(可选)默认值为 True

  • include_catalog (bool) – 在返回的令牌中包含服务目录。(可选)默认值为 True。

  • unscoped (bool) – 强制返回未范围限定的令牌。即使此用户的 default_project_id 已设置,也会使 Keystone 服务器返回未范围限定的令牌。

__abstractmethods__ = frozenset({})
__annotations__ = {'MIN_TOKEN_LIFE_SECONDS': 'int', '_discovery_cache': 'dict[str, discover.Discover]', 'auth_ref': 'access.AccessInfo | None', 'auth_url': 'str', 'reauthenticate': 'bool'}
__doc__ = "Identity V3 身份验证 插件。\n\n    :param 字符串 auth_url: 身份验证的 身份服务端点。\n    :param 列表 auth_methods: 用于身份验证的方法集合。\n    :param 字符串 trust_id: 信任范围的信任 ID。\n    :param 字符串 domain_id: 域范围的域 ID。\n    :param 字符串 domain_name: 域范围的域名称。\n    :param 字符串 project_id: 项目范围的项目 ID。\n    :param 字符串 project_name: 项目范围的项目名称。\n    :param 字符串 project_domain_id: 项目的域 ID。\n    :param 字符串 project_domain_name: 项目的域名称。\n    :param 布尔值 reauthenticate: 如果当前令牌即将过期,则允许获取新的令牌。(可选)默认值为 True\n    :param 布尔值 include_catalog: 在返回的令牌中包含服务目录。(可选)默认值为 True。\n    :param 布尔值 unscoped: 强制返回未作用域的令牌。即使为该用户设置了 default_project_id,这也会使 keystone 服务器返回未作用域的令牌。\n    "
__init__(auth_url: str, auth_methods: list[AuthMethod], *, unscoped: bool = False, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True)
__module__ = 'keystoneauth1.identity.v3.base'
_abc_impl = <_abc._abc_data object>
_discovery_cache: dict[str, discover.Discover]
add_method(method: AuthMethod) None

添加一个额外的已初始化 AuthMethod 实例。

auth_ref: access.AccessInfo | None
auth_url: str
get_auth_ref(session: Session) AccessInfoV3

从 OpenStack Identity 服务获取令牌。

此方法由各种令牌版本插件覆盖。

不应独立调用此函数,并预计通过 do_authenticate 函数调用。

如果插件缓存的 AccessInfo 对象无效,将调用此函数。因此,插件应始终在调用时获取新的 AccessInfo。如果您只想检索当前的身份验证数据,则应使用 get_access。

参数:

session (keystoneauth1.session.Session) – 可以用于通信的会话对象。

引发:
返回值:

令牌访问信息。

返回类型:

keystoneauth1.access.AccessInfo

get_cache_id_elements() dict[str, str | None]

获取使此身份验证插件唯一化的元素。

作为 get_cache_id 要求的一部分,我们需要确定此插件及其值的哪些方面构成唯一的元素。

插件希望允许缓存时应覆盖此方法。

返回值:

此插件的唯一属性和值。

返回类型:

一个扁平的字典,其中包含一个 str 键和一个 str 或 None 值。这需要我们将这些值馈送到哈希中。值为空的对在哈希 ID 中被忽略。

reauthenticate: bool
class keystoneauth1.identity.v3.base.AuthConstructor(auth_url: str, *args: Any, unscoped: bool = False, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True, **kwargs: Any)

继承自 Auth

创建 Auth 插件的抽象基类。

创建的 Auth 插件仅包含一种身份验证方法。这通常是必需的使用方式。

AuthConstructor 基于插件定义的 method_arguments 和 auth_method_class 创建 AuthMethod。然后,它使用该身份验证方法创建身份验证插件。

__abstractmethods__ = frozenset({})
__annotations__ = {'MIN_TOKEN_LIFE_SECONDS': 'int', '_auth_method_class': typing.ClassVar[type[keystoneauth1.identity.v3.base.AuthMethod]], '_discovery_cache': 'dict[str, discover.Discover]', 'auth_ref': 'access.AccessInfo | None', 'auth_url': 'str', 'reauthenticate': 'bool'}
__doc__ = "用于创建身份验证插件的抽象基类。\n\n    创建的身份验证插件仅包含一种身份验证方法。这是\n    通常需要的用法。\n\n    AuthConstructor 根据方法的参数和插件定义的\n    auth_method_class 创建一个 AuthMethod 。然后它使用该身份验证方法创建\n    身份验证插件。\n    "
__init__(auth_url: str, *args: Any, unscoped: bool = False, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True, **kwargs: Any)
__module__ = 'keystoneauth1.identity.v3.base'
_abc_impl = <_abc._abc_data object>
_auth_method_class: ClassVar[type[AuthMethod]]
_discovery_cache: dict[str, discover.Discover]
auth_ref: access.AccessInfo | None
auth_url: str
reauthenticate: bool
class keystoneauth1.identity.v3.base.AuthMethod(**kwargs: object)

基类: object

V3 身份验证策略的一部分。

v3 的 '/tokens' API 允许在向服务器进行身份验证时提供多种方法。这些方法中的每一个都由 AuthMethod 实现。

注意:实现 AuthMethod 时,请使用关键字参数以确保 MultiFactor 身份验证插件支持它们。

__abstractmethods__ = frozenset({'get_auth_data'})
__annotations__ = {'_method_parameters': list[str] | None}
__dict__ = mappingproxy({'__module__': 'keystoneauth1.identity.v3.base', '__annotations__': {'_method_parameters': list[str] | None}, '__doc__': "V3 身份验证策略的一部分。\n\n    v3 '/tokens' API 允许在向服务器进行身份验证时提供多种方法。\n    这些方法中的每一个都由 AuthMethod 实现。\n\n    注意:实现 AuthMethod 时,请使用关键字参数以确保它们\n    MultiFactor 身份验证插件的支持。\n    ", '_method_parameters': None, '__init__': <function AuthMethod.__init__>, '_extract_kwargs': <classmethod(<function AuthMethod._extract_kwargs>)>, 'get_auth_data': <function AuthMethod.get_auth_data>, 'get_cache_id_elements': <function AuthMethod.get_cache_id_elements>, '__dict__': <attribute '__dict__' of 'AuthMethod' objects>, '__weakref__': <attribute '__weakref__' of 'AuthMethod' objects>, '__abstractmethods__': frozenset({'get_auth_data'}), '_abc_impl': <_abc._abc_data object>})
__doc__ = "V3 身份验证策略的一部分。\n\n    v3 '/tokens' API 允许在向服务器进行身份验证时提供多种方法。\n    这些方法中的每一个都由 AuthMethod 实现。\n\n    注意:实现 AuthMethod 时,请使用关键字参数以确保它们\n    MultiFactor 身份验证插件的支持。\n    "
__init__(**kwargs: object)
__module__ = 'keystoneauth1.identity.v3.base'
__weakref__

对该对象的弱引用列表

_abc_impl = <_abc._abc_data object>
classmethod _extract_kwargs(kwargs: dict[str, object]) dict[str, object]

从其他 kwargs 中移除与此方法相关的参数。

_method_parameters: list[str] | None = None

用于定义插件支持的参数的已弃用参数。这些现在应由类型化的类属性定义。

abstract get_auth_data(session: Session, auth: Auth, headers: dict[str, str], request_kwargs: dict[str, object]) tuple[None, None] | tuple[str, Mapping[str, object]]

返回身份验证插件的身份验证部分。

参数:
  • session (keystoneauth1.session.Session) – 会话。

  • auth (base.Auth) – 调用该方法的认证插件。

  • headers (dict) – 将与身份验证请求一起发送的标头(如果插件需要添加标头)。

返回值:

此插件的标识符和用于身份验证类型的字典数据。

返回类型:

tuple(string, dict)

get_cache_id_elements() dict[str, str | None]

获取使此认证方法唯一化的元素。

这些元素将用作 keystoneauth1.plugin.BaseIdentityPlugin.get_cache_id() 的一部分,以允许缓存认证插件。

如果插件希望允许缓存其状态,则应重写此方法。

为避免冲突或覆盖,返回字典的键应以插件标识符为前缀。例如,密码插件将其用户名值作为“password_username”返回。

class keystoneauth1.identity.v3.base.BaseAuth(auth_url: str, *, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True)

基础: BaseIdentityPlugin

Identity V3 身份验证插件。

参数:
  • auth_url (string) – 身份服务端点,用于身份验证。

  • trust_id (string) – 信任范围的信任 ID。

  • system_scope (string) – 要作用域到的系统信息。

  • domain_id (string) – 域 ID,用于域范围限定。

  • domain_name (string) – 域名称,用于域范围限定。

  • project_id (string) – 项目 ID,用于项目范围限定。

  • project_name (string) – 项目名称,用于项目范围限定。

  • project_domain_id (string) – 项目的域 ID,用于项目。

  • project_domain_name (string) – 项目的域名称,用于项目。

  • reauthenticate (bool) – 允许在当前令牌即将过期时获取新的令牌。(可选)默认值为 True

  • include_catalog (bool) – 在返回的令牌中包含服务目录。(可选)默认值为 True。

__abstractmethods__ = frozenset({'get_auth_ref'})
__annotations__ = {'MIN_TOKEN_LIFE_SECONDS': 'int', '_discovery_cache': 'dict[str, discover.Discover]', 'auth_ref': 'access.AccessInfo | None', 'auth_url': <class 'str'>, 'reauthenticate': 'bool'}
__doc__ = "V3 身份认证插件。\n\n    :param string auth_url: 认证的身份服务端点。\n    :param string trust_id: 信任范围的信任 ID。\n    :param string system_scope: 要作用域到的系统信息。\n    :param string domain_id: 域范围的域 ID。\n    :param string domain_name: 域范围的域名称。\n    :param string project_id: 项目范围的项目 ID。\n    :param string project_name: 项目范围的项目名称。\n    :param string project_domain_id: 项目的域 ID。\n    :param string project_domain_name: 项目的域名称。\n    :param bool reauthenticate: 如果当前令牌即将过期,则允许获取新的令牌。(可选)默认值为 True\n    :param bool include_catalog: 在返回的令牌中包含服务目录。(可选)默认值为 True。\n    "
__init__(auth_url: str, *, trust_id: str | None = None, system_scope: str | None = None, domain_id: str | None = None, domain_name: str | None = None, project_id: str | None = None, project_name: str | None = None, project_domain_id: str | None = None, project_domain_name: str | None = None, reauthenticate: bool = True, include_catalog: bool = True)
__module__ = 'keystoneauth1.identity.v3.base'
_abc_impl = <_abc._abc_data object>
_discovery_cache: dict[str, discover.Discover]
auth_ref: access.AccessInfo | None
auth_url: str
property has_scope_parameters: bool

如果参数可用于创建作用域令牌,则返回 True。

reauthenticate: bool
property token_url: str

我们将发送身份验证数据的完整 URL。

class keystoneauth1.identity.v3.base.SupportsMultiFactor(*args, **kwargs)

基础: Protocol

__abstractmethods__ = frozenset({})
__annotations__ = {'_auth_method_class': typing.ClassVar[type[keystoneauth1.identity.v3.base.AuthMethod]]}
__dict__ = mappingproxy({'__module__': 'keystoneauth1.identity.v3.base', '__annotations__': {'_auth_method_class': typing.ClassVar[type[keystoneauth1.identity.v3.base.AuthMethod]]}, '__dict__': <attribute '__dict__' of 'SupportsMultiFactor' objects>, '__weakref__': <attribute '__weakref__' of 'SupportsMultiFactor' objects>, '__doc__': None, '__parameters__': (), '_is_protocol': True, '__subclasshook__': <classmethod(<function _proto_hook>)>, '__init__': <function _no_init_or_replace_init>, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__protocol_attrs__': {'_auth_method_class'}, '_is_runtime_protocol': True, '__non_callable_proto_members__': {'_auth_method_class'}})
__doc__ = None
__init__(*args, **kwargs)
__module__ = 'keystoneauth1.identity.v3.base'
__non_callable_proto_members__ = {'_auth_method_class'}
__parameters__ = ()
__protocol_attrs__ = {'_auth_method_class'}
classmethod __subclasshook__(other)

抽象类可以覆盖此方法以自定义 issubclass()。

这在 abc.ABCMeta.__subclasscheck__() 的早期被调用。它应该返回 True、False 或 NotImplemented。如果它返回 NotImplemented,则使用正常的算法。否则,它会覆盖正常的算法(结果会被缓存)。

__weakref__

对该对象的弱引用列表

_abc_impl = <_abc._abc_data object>
_auth_method_class: ClassVar[type[AuthMethod]]
_is_protocol = True
_is_runtime_protocol = True
class keystoneauth1.identity.v3.base._AuthBody

基础: TypedDict

__annotations__ = {'auth': <class 'keystoneauth1.identity.v3.base._AuthIdentity'>}
__dict__ = mappingproxy({'__module__': 'keystoneauth1.identity.v3.base', '__annotations__': {'auth': <class 'keystoneauth1.identity.v3.base._AuthIdentity'>}, '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of '_AuthBody' objects>, '__weakref__': <attribute '__weakref__' of '_AuthBody' objects>, '__doc__': None, '__required_keys__': frozenset({'auth'}), '__optional_keys__': frozenset(), '__total__': True})
__doc__ = None
__module__ = 'keystoneauth1.identity.v3.base'
__optional_keys__ = frozenset({})
__orig_bases__ = (<function TypedDict>,)
__required_keys__ = frozenset({'auth'})
__total__ = True
__weakref__

对该对象的弱引用列表

auth: _AuthIdentity
class keystoneauth1.identity.v3.base._AuthIdentity

基础: TypedDict

__annotations__ = {'identity': dict[str, typing.Any], 'scope': typing.NotRequired[dict[str, typing.Any] | str]}
__dict__ = mappingproxy({'__module__': 'keystoneauth1.identity.v3.base', '__annotations__': {'identity': dict[str, typing.Any], 'scope': typing.NotRequired[dict[str, typing.Any] | str]}, '__orig_bases__': (<function TypedDict>,), '__dict__': <attribute '__dict__' of '_AuthIdentity' objects>, '__weakref__': <attribute '__weakref__' of '_AuthIdentity' objects>, '__doc__': None, '__required_keys__': frozenset({'identity'}), '__optional_keys__': frozenset({'scope'}), '__total__': True})
__doc__ = None
__module__ = 'keystoneauth1.identity.v3.base'
__optional_keys__ = frozenset({'scope'})
__orig_bases__ = (<function TypedDict>,)
__required_keys__ = frozenset({'identity'})
__total__ = True
__weakref__

对该对象的弱引用列表

identity: dict[str, Any]
scope: NotRequired[dict[str, Any] | str]