Skip to content

kanidm.types.RadiusClient

Bases: BaseModel

Client config for Kanidm FreeRADIUS integration, this is a pydantic model.

name: (str) An identifier for the client definition

ipaddr: (str) A single IP Address, CIDR or DNS hostname (which will be resolved on startup, preferring A records over AAAA). FreeRADIUS doesn't recommend using DNS.

secret: (str) The password the client should use to authenticate.

Source code in kanidm/types.py
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
class RadiusClient(BaseModel):
    """Client config for Kanidm FreeRADIUS integration,
    this is a pydantic model.

    name: (str) An identifier for the client definition

    ipaddr: (str) A single IP Address, CIDR or
    DNS hostname (which will be resolved on startup,
    preferring A records over AAAA).
    FreeRADIUS doesn't recommend using DNS.

    secret: (str) The password the client should use to
    authenticate.
    """

    name: str
    ipaddr: str
    secret: str  # TODO: this should probably be renamed to token

    @validator("ipaddr")
    def validate_ipaddr(cls, value: str) -> str:
        """validates the ipaddr field is an IP address, CIDR or valid hostname"""
        for typedef in (IPv6Network, IPv6Address, IPv4Address, IPv4Network):
            try:
                typedef(value)
                return value
            except ValueError:
                pass
        try:
            socket.gethostbyname(value)
            return value
        except socket.gaierror as error:
            raise ValueError(
                f"ipaddr value ({value}) wasn't an IP Address, Network or valid hostname: {error}"
            )

validate_ipaddr(value)

validates the ipaddr field is an IP address, CIDR or valid hostname

Source code in kanidm/types.py
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
@validator("ipaddr")
def validate_ipaddr(cls, value: str) -> str:
    """validates the ipaddr field is an IP address, CIDR or valid hostname"""
    for typedef in (IPv6Network, IPv6Address, IPv4Address, IPv4Network):
        try:
            typedef(value)
            return value
        except ValueError:
            pass
    try:
        socket.gethostbyname(value)
        return value
    except socket.gaierror as error:
        raise ValueError(
            f"ipaddr value ({value}) wasn't an IP Address, Network or valid hostname: {error}"
        )