Sources
authkeys.sources
Key sources, found by name.
backend = "<name>" in a [source.<name>] table selects one. file,
http, github and ldap are built in; an installed distribution adds a
source through the authkeys.sources entry-point group (name =
"pkg.module:Class", a :class:~authkeys.KeySource subclass). Optional
dependencies (syshttp, ldap3, cryptography) are imported
inside each source, so naming a source never fails for a missing extra until it
is used.
__all__ = ['FileSource', 'GitHubSource', 'HTTPSource', 'LDAPSource', 'get_source', 'only_auth_keys', 'register_source', 'source_names']
module-attribute
FileSource(options, globals)
Bases: KeySource
Keys from the target user's own ~/.ssh files.
Source code in src/authkeys/sources/_file.py
17 18 19 | |
options = frozenset({'paths'})
class-attribute
instance-attribute
paths = [paths] if isinstance(paths, str) else [str(p) for p in paths]
instance-attribute
authorized_keys(username)
Source code in src/authkeys/sources/_file.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | |
GitHubSource(options, globals, *, ssl_context=None)
Bases: KeySource
Keys from a forge's plain-text .keys endpoint.
Source code in src/authkeys/sources/_github.py
27 28 29 30 31 32 33 34 35 | |
client = KeyClient(options, 'github source', ssl_context=ssl_context)
instance-attribute
options = frozenset({'url'}) | CLIENT_OPTIONS
class-attribute
instance-attribute
url = typed(options, 'url', str, _DEFAULT_URL, 'github source')
instance-attribute
authorized_keys(username)
Source code in src/authkeys/sources/_github.py
37 38 39 40 41 | |
HTTPSource(options, globals, *, ssl_context=None)
Bases: KeySource
Keys from an HTTP endpoint, one authorized_keys line per row.
ssl_context (programmatic use) replaces the TLS options.
Source code in src/authkeys/sources/_http.py
28 29 30 31 32 33 34 35 36 37 38 | |
client = KeyClient(options, 'http source', ssl_context=ssl_context)
instance-attribute
options = frozenset({'url'}) | CLIENT_OPTIONS
class-attribute
instance-attribute
url = typed(options, 'url', str, None, 'http source')
instance-attribute
authorized_keys(username)
Source code in src/authkeys/sources/_http.py
40 41 42 43 44 | |
LDAPSource(options, globals, *, ssl_context=None)
Bases: KeySource
Keys derived from X.509 certificates stored in an LDAP directory.
ssl_context (programmatic use) is the client TLS context; it selects the
ldap3 client, which can take one.
Source code in src/authkeys/sources/_ldap.py
122 123 124 125 126 127 128 129 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 165 166 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 | |
cert_attr = typed(options, 'cert_attr', str, 'userCertificate', where)
instance-attribute
cert_filter = cert_filter
instance-attribute
client = make_client(self.settings, typed(options, 'client', str, 'auto', where))
instance-attribute
issuers = self._load_issuers(typed(options, 'issuer_ca', str, None, where))
instance-attribute
options = frozenset({'server', 'basedn', 'cert_attr', 'username_attr', 'client', 'auth', 'keytab', 'principal', 'bind_dn', 'password_env', 'starttls', 'tls_verify', 'tls_cert', 'tls_key', 'timeout', 'cert_filter', 'issuer_ca'})
class-attribute
instance-attribute
settings = LDAPSettings(url=url, starttls=starttls, basedn=typed(options, 'basedn', str, '', where), attribute=self.cert_attr, auth=auth, keytab=keytab, principal=typed(options, 'principal', str, None, where), bind_dn=bind_dn, password_env=password_env, tls_verify=typed(options, 'tls_verify', str, None, where), tls_cert=tls_cert, tls_key=tls_key, timeout=float(typed(options, 'timeout', (int, float), 10.0, where)), ssl_context=ssl_context)
instance-attribute
username_attr = typed(options, 'username_attr', str, 'uid', where)
instance-attribute
authorized_keys(username)
Source code in src/authkeys/sources/_ldap.py
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
get_source(name)
The source class registered as name; ConfigError listing the names.
Source code in src/authkeys/sources/__init__.py
61 62 63 64 65 66 67 68 69 | |
only_auth_keys(username, cert)
Default filter: keep only certificates that are login credentials.
A certificate is kept when it is within its validity period, is not self-signed, its KeyUsage (when present) permits digital signature, and its ExtendedKeyUsage (when present) includes clientAuth or anyExtendedKeyUsage. Directories also hold encryption, e-mail and recovery certificates in the same attribute; those must not become SSH keys.
Source code in src/authkeys/sources/_ldap.py
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 | |
register_source(name, cls)
Register a source class under name; a name taken by another class is a
ValueError. Returns cls.
Source code in src/authkeys/sources/__init__.py
36 37 38 39 40 41 42 | |
source_names()
The registered source names, sorted.
Source code in src/authkeys/sources/__init__.py
55 56 57 58 | |