Sources
authkeys.sources.file
File source: read keys from a user's ~/.ssh/authorized_keys files.
AuthorizedKeysFiles(conf, globals)
Bases: AuthkeysSource
Source code in src/authkeys/sources/file.py
11 12 | |
paths = conf.getlist('paths', ['authorized_keys', 'authorized_keys2'])
instance-attribute
authorized_keys(username)
Source code in src/authkeys/sources/file.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | |
authkeys.sources.http
HTTP source: fetch keys from a URL, one authorized_keys line per row.
The address is a format string receiving {username}. Optional mutual-TLS
client credentials are given as credentials = cert.pem,key.pem. Requires the
optional requests dependency (pip install authkeys[http]).
HttpAuthorizedKeys(conf, globals)
Bases: AuthkeysSource
Source code in src/authkeys/sources/http.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
address = conf.get('address')
instance-attribute
options = {}
instance-attribute
session = requests.Session()
instance-attribute
timeout = conf.getfloat('timeout', 10.0)
instance-attribute
authorized_keys(username)
Source code in src/authkeys/sources/http.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
authkeys.sources.github
GitHub .keys source: fetch a user's public keys from github.com.
GitHub (and GitLab, and similar forges) publish a user's public SSH keys at a
plain-text .keys URL, one key per line, WITHOUT comments. The url
template receives {username} and defaults to the GitHub endpoint; point it
at https://gitlab.com/{username}.keys (or any other forge with the same
convention) to reuse this source without a separate class.
GithubKeys(conf, globals)
Bases: AuthkeysSource
Source code in src/authkeys/sources/github.py
20 21 22 23 24 25 | |
session = requests.Session()
instance-attribute
timeout = conf.getfloat('timeout', 10.0)
instance-attribute
url = conf.get('url', _DEFAULT_URL)
instance-attribute
authorized_keys(username)
Source code in src/authkeys/sources/github.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
authkeys.sources.ldap
LDAP source: derive SSH keys from X.509 certificates stored in a directory.
Each matching entry's cert_attr values are parsed as DER certificates; the
public key is serialized to OpenSSH format. An optional cert_filter callable
(username, cert) -> bool | str can drop a certificate or supply a comment.
Requires the optional ldap extra (pip install authkeys[ldap]:
ldap3 + cryptography).
CertFilter = Callable[[str, 'object'], 'Union[bool, str]']
module-attribute
LOGGER = logging.getLogger('authkeys.sources.ldap')
module-attribute
LdapAuthorizedKeys(conf, globals)
Bases: AuthkeysSource
Source code in src/authkeys/sources/ldap.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
basedn = conf.get('basedn', '')
instance-attribute
cert_attr = conf.get('cert_attr', 'userCertificate')
instance-attribute
cert_filter = cert_filter
instance-attribute
server = conf.get('server', None)
instance-attribute
timeout = conf.getfloat('timeout', 10.0)
instance-attribute
tls_cert = conf.get('tls_cert', '/etc/pki/tls/certs/server.crt')
instance-attribute
tls_key = conf.get('tls_key', '/etc/pki/tls/private/server.key')
instance-attribute
tls_verify = conf.get('tls_verify', None)
instance-attribute
username_attr = conf.get('username_attr', 'uid')
instance-attribute
authorized_keys(username)
Source code in src/authkeys/sources/ldap.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
only_auth_keys(username, cert)
Default filter: keep certs whose KeyUsage permits digital signature.
Source code in src/authkeys/sources/ldap.py
25 26 27 28 29 30 31 32 33 | |