PostgreSQL Source Code git master
Loading...
Searching...
No Matches
oauth_server Namespace Reference

Data Structures

class  OAuthHandler
 

Functions

 main ()
 

Variables

 ssl_dir = os.getenv("cert_dir")
 
str ssl_cert = ssl_dir + "/server-localhost-alt-names.crt"
 
str ssl_key = ssl_dir + "/server-localhost-alt-names.key"
 

Function Documentation

◆ main()

oauth_server.main ( void  )
Starts the authorization server on localhost. The ephemeral port in use will
be printed to stdout.

Definition at line 415 of file oauth_server.py.

415def main():
416 """
417 Starts the authorization server on localhost. The ephemeral port in use will
418 be printed to stdout.
419 """
420 # XXX Listen exclusively on IPv4. Listening on a dual-stack socket would be
421 # more true-to-life, but every OS/Python combination in the buildfarm and CI
422 # would need to provide the functionality first.
423 s = http.server.HTTPServer(("127.0.0.1", 0), OAuthHandler)
424
425 # Speak HTTPS.
426 # TODO: switch to HTTPSServer with Python 3.14
428 ssl_context.load_cert_chain(ssl_cert, ssl_key)
429
430 s.socket = ssl_context.wrap_socket(s.socket, server_side=True)
431
432 # Attach a "cache" dictionary to the server to allow the OAuthHandlers to
433 # track state across token requests. The use of defaultdict ensures that new
434 # entries will be created automatically.
435 class _TokenState:
436 retries = 0
437 min_delay = None
438 last_try = None
439
440 s.token_state = defaultdict(_TokenState)
441
442 # Give the parent the port number to contact (this is also the signal that
443 # we're ready to receive requests).
444 port = s.socket.getsockname()[1]
445 print(port)
446
447 # stdout is closed to allow the parent to just "read to the end".
448 stdout = sys.stdout.fileno()
450 os.close(stdout)
451
452 s.serve_forever() # we expect our parent to send a termination signal
453
454
void print(const void *obj)
Definition print.c:36
int main(void)
static int fb(int x)

References fb(), main(), and print().

Referenced by main().

Variable Documentation

◆ ssl_cert

str oauth_server.ssl_cert = ssl_dir + "/server-localhost-alt-names.crt"

Definition at line 22 of file oauth_server.py.

◆ ssl_dir

oauth_server.ssl_dir = os.getenv("cert_dir")

Definition at line 21 of file oauth_server.py.

◆ ssl_key

str oauth_server.ssl_key = ssl_dir + "/server-localhost-alt-names.key"

Definition at line 23 of file oauth_server.py.