kanidm/stable/pykanidm/search/search_index.json

1 line
44 KiB
JSON
Raw Normal View History

{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"kanidmclient/","title":"kanidm.KanidmClient","text":"<p>Kanidm client module</p> <p>config: a <code>KanidmClientConfig</code> object, if this is set, everything else is ignored config_file: a <code>pathlib.Path</code> object pointing to a configuration file uri: kanidm base URL session: a <code>aiohttp.client.ClientSession</code> verify_hostnames: verify the hostname is correct verify_certificate: verify the validity of the certificate and its CA ca_path: set this to a trusted CA certificate (PEM format) token: a JWS from an authentication session</p> Source code in <code>kanidm/__init__.py</code> <pre><code>class KanidmClient:\n\"\"\"Kanidm client module\n\n config: a `KanidmClientConfig` object, if this is set, everything else is ignored\n config_file: a `pathlib.Path` object pointing to a configuration file\n uri: kanidm base URL\n session: a `aiohttp.client.ClientSession`\n verify_hostnames: verify the hostname is correct\n verify_certificate: verify the validity of the certificate and its CA\n ca_path: set this to a trusted CA certificate (PEM format)\n token: a JWS from an authentication session\n \"\"\"\n\n # pylint: disable=too-many-instance-attributes,too-many-arguments\n def __init__(\n self,\n config: Optional[KanidmClientConfig] = None,\n config_file: Optional[Union[Path, str]] = None,\n uri: Optional[str] = None,\n verify_hostnames: bool = True,\n verify_certificate: bool = True,\n ca_path: Optional[str] = None,\n token: Optional[str] = None,\n ) -&gt; None:\n\"\"\"Constructor for KanidmClient\"\"\"\n\n if config is not None:\n self.config = config\n\n else:\n self.config = KanidmClientConfig(\n uri=uri,\n verify_hostnames=verify_hostnames,\n verify_certificate=verify_certificate,\n ca_path=ca_path,\n auth_token=token,\n )\n\n if config_file is not None:\n if not isinstance(config_file, Path):\n config_file = Path(config_file)\n config_data = load_config(config_file.expanduser().resolve())\n self.config = self.config.parse_obj(config_data)\n\n if self.config.uri is None:\n raise ValueError(\"Please initialize this with a server URI\")\n\n self._ssl: Optional[Union[bool, ssl.SSLContext]] = None\n self._configure_ssl()\n\n def _configure_ssl(self) -&gt; None:\n\"\"\"Sets up SSL configuration for the client\"\"\"\n if self.config.verify_certificate is False:\n self._ssl = False\n else:\n if (\n self.config.ca_path is not None\n and not Path(self.config.ca_path).expanduser().resolve().exists()\n ):\n raise FileNotFoundError(f\"CA Path not found: {self.config.ca_path}\")\n self._ssl = ssl.create_default_context(cafile=self.config.ca_path)\n if self._ssl is not False:\n # ignoring this for typing because mypy is being weird\n # ssl.SSLContext.check_hostname is totally a thing\n # https://docs.python.org/3/library/ssl.html#ssl.SSLContext.check_hostname\n self._ssl.check_hostname = self.config.verify_hostnames # type: ignore\n\n def parse_config_data(\n self,\n config_data: Dict[str, Any],\n ) -&gt; None:\n\"\"\"hand it a config dict and it'll configure the client\"\"\"\n try:\n self.config.parse_obj(config_data)\n except ValidationError as validation_error:\n # pylint: disable=raise-missing-from\n raise ValueError(f\"Failed to validate configuration: {validation_error}\")\n\n async def check_token_valid(self, token: Optional[str] = None) -&gt; bool:\n\"\"\"checks if a given token is valid, or the local one if you don't pass it\"\"\"\n url = \"/v1/auth/valid\"\n i