Skip to content

kanidm.types.KanidmClientConfig

Bases: BaseModel

Configuration file definition for Kanidm client config Based on struct KanidmClientConfig in kanidm_client/src/lib.rs

See source code for fields

Source code in kanidm/types.py
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
class KanidmClientConfig(BaseModel):
    """Configuration file definition for Kanidm client config
    Based on struct KanidmClientConfig in kanidm_client/src/lib.rs

    See source code for fields
    """

    uri: Optional[str] = None

    auth_token: Optional[str] = None

    verify_hostnames: bool = True
    verify_certificate: bool = True
    ca_path: Optional[str] = None

    username: Optional[str] = None
    password: Optional[str] = None

    radius_cert_path: str = "/data/cert.pem"
    radius_key_path: str = "/data/key.pem"  # the signing key for radius TLS
    radius_dh_path: str = "/data/dh.pem"  # the diffie-hellman output
    radius_ca_path: Optional[str] = None
    radius_ca_dir: Optional[str] = None

    radius_required_groups: List[str] = []
    radius_default_vlan: int = 1
    radius_groups: List[RadiusGroup] = []
    radius_clients: List[RadiusClient] = []

    connect_timeout: int = 30

    @classmethod
    def parse_toml(cls, input_string: str) -> Any:
        """loads from a string"""
        return super().parse_obj(toml.loads(input_string))

    @validator("uri")
    def validate_uri(cls, value: Optional[str]) -> Optional[str]:
        """validator for the uri field"""
        if value is not None:
            uri = urlparse(value)
            valid_schemes = ["http", "https"]
            if uri.scheme not in valid_schemes:
                raise ValueError(
                    f"Invalid URL Scheme for uri='{value}': '{uri.scheme}' - expected one of {valid_schemes}"
                )

            # make sure the URI ends with a /
            if not value.endswith("/"):
                value = f"{value}/"

        return value

parse_toml(input_string) classmethod

loads from a string

Source code in kanidm/types.py
198
199
200
201
@classmethod
def parse_toml(cls, input_string: str) -> Any:
    """loads from a string"""
    return super().parse_obj(toml.loads(input_string))

validate_uri(value)

validator for the uri field

Source code in kanidm/types.py
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
@validator("uri")
def validate_uri(cls, value: Optional[str]) -> Optional[str]:
    """validator for the uri field"""
    if value is not None:
        uri = urlparse(value)
        valid_schemes = ["http", "https"]
        if uri.scheme not in valid_schemes:
            raise ValueError(
                f"Invalid URL Scheme for uri='{value}': '{uri.scheme}' - expected one of {valid_schemes}"
            )

        # make sure the URI ends with a /
        if not value.endswith("/"):
            value = f"{value}/"

    return value