Server
authkeys.server
Unattended HTTP key server (the generalized keygrabber).
Serves authorized_keys over HTTP(S) so hosts that cannot run the
AuthorizedKeysCommand locally (or want a shared, cached view) can fetch keys
from a central instance. Where it listens is a netimps listen specification
("127.0.0.1:8090", "[::1]:8090,192.0.2.10"); the API key is compared in
constant time.
Config ([serve] table)::
[serve]
listen = "127.0.0.1:8090"
api_key = "${env.AUTHKEYS_APIKEY}" # unset => auth disabled (listen locally!)
path = "/keys"
request_timeout = 10 # seconds a connection may stay idle
max_connections = 64 # requests served at once; more get 503
certificate = "/etc/authkeys/tls.pem" # with key: serve HTTPS
key = "/etc/authkeys/tls.key"
DEFAULT_PORT = 8090
module-attribute
LOGGER = logging.getLogger('authkeys.server')
module-attribute
__all__ = ['DEFAULT_PORT', 'KeyHandler', 'KeyServer', 'bind_servers', 'serve']
module-attribute
KeyHandler
Bases: BaseHTTPRequestHandler
server
instance-attribute
server_version = 'authkeys'
class-attribute
instance-attribute
do_GET()
Source code in src/authkeys/server.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
log_message(fmt, *args)
Source code in src/authkeys/server.py
192 193 | |
log_request(code='-', size='-')
Source code in src/authkeys/server.py
195 196 197 198 | |
setup()
Source code in src/authkeys/server.py
187 188 189 190 | |
KeyServer(authkeys, listen='127.0.0.1:8090', *, api_key=None, path='/keys', max_usernames=16, require_auth=False, request_timeout=10.0, max_connections=64, ssl_context=None)
Bases: ThreadingHTTPServer
Threaded HTTP server bound to an :class:AuthKeys instance.
Bind one listening socket for listen (one netimps listen entry:
"host:port", "[v6]:port", ":port", a ListenAddress; the
port defaults to 8090). ssl_context (server side) serves HTTPS.
Raises ValueError for a specification that names no address or more
than one (use :func:bind_servers), and OSError when the socket
cannot be bound (netimps.AddressInUseError for a taken port).
Source code in src/authkeys/server.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 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 | |
address_family = sock.family
instance-attribute
allow_reuse_address = True
class-attribute
instance-attribute
api_key = api_key or None
instance-attribute
authkeys = authkeys
instance-attribute
daemon_threads = True
class-attribute
instance-attribute
max_usernames = max_usernames
instance-attribute
request_timeout = request_timeout
instance-attribute
route = '/' + path.strip('/')
instance-attribute
server_address = sock.getsockname()
instance-attribute
socket = sock
instance-attribute
ssl_context = ssl_context
instance-attribute
url
property
The URL this server answers on, IPv6 hosts in brackets.
check_auth(provided)
Source code in src/authkeys/server.py
174 175 176 177 178 179 180 | |
finish_request(request, client_address)
Source code in src/authkeys/server.py
134 135 136 137 138 139 140 | |
handle_error(request, client_address)
Source code in src/authkeys/server.py
142 143 144 145 146 147 148 149 | |
process_request(request, client_address)
Source code in src/authkeys/server.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | |
process_request_thread(request, client_address)
Source code in src/authkeys/server.py
168 169 170 171 172 | |
bind_servers(authkeys, listen='127.0.0.1:8090', **options)
One :class:KeyServer per entry of the netimps listen specification
listen ("127.0.0.1:8090,[::1]:8090"); options go to each.
Every socket is bound before this returns; if one fails, those already bound
are closed and the error is raised (ValueError for a bad specification,
OSError for a socket that cannot be bound).
Source code in src/authkeys/server.py
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | |
serve(servers)
Run servers until interrupted (blocking), then close them.
Source code in src/authkeys/server.py
274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |