proxystore.endpoint.auth¶
Authentication between clients and their local endpoint.
Each time an endpoint starts, it generates a random token and writes it,
along with its address, to a connection file in the endpoint's directory
that only the owner can read (see
ConnectionInfo). Clients read
the connection file, so any process that can read the user's ProxyStore
home directory is trusted.
The token is never sent over the network. Instead, the client and endpoint each prove they know the token by computing an HMAC over random nonces chosen by both sides. This authenticates the client to the endpoint and the endpoint to the client (i.e., a different server listening on the endpoint's address cannot impersonate the endpoint).
Optionally, connections can be encrypted with TLS. The endpoint generates a new self-signed certificate each time it starts, and clients only trust the certificate whose fingerprint is in the connection file (i.e., certificate pinning).
ConnectionInfo
¶
Bases: NamedTuple
Information that clients use to connect to a running endpoint.
The endpoint writes this to its directory each time it starts and
removes it when it stops (see
EndpointDir).
Attributes:
-
host(str) –Host address the endpoint is listening on.
-
port(int) –Port the endpoint is listening on.
-
token(bytes) –Token that the client and endpoint prove they know.
-
tls_fingerprint(str | None) –SHA-256 fingerprint of the endpoint's TLS certificate or
Noneif the endpoint does not use TLS.
write_private_file
¶
Atomically write data to a file that only the owner can access.
The data is written to a temporary file with mode 0600 in the same
directory which then replaces path, so readers never observe a
partially written file.
Source code in proxystore/endpoint/auth.py
compute_proof
¶
compute_proof(
token: bytes,
role: Literal["client", "server"],
first_nonce: bytes,
second_nonce: bytes,
) -> bytes
Compute a proof that the sender knows the token.
The role is included so a proof sent by one side can never be replayed as the proof of the other side.
Parameters:
-
token(bytes) –Endpoint token.
-
role(Literal['client', 'server']) –Role of the side computing the proof.
-
first_nonce(bytes) –Nonce of the side computing the proof.
-
second_nonce(bytes) –Nonce of the other side.
Source code in proxystore/endpoint/auth.py
verify_proof
¶
verify_proof(
token: bytes,
role: Literal["client", "server"],
first_nonce: bytes,
second_nonce: bytes,
proof: bytes,
) -> bool
Verify a proof computed by the other side of the handshake.
Source code in proxystore/endpoint/auth.py
generate_tls_certificate
¶
Generate a self-signed TLS certificate and private key.
Note
This requires the cryptography package which is included in the
endpoints extra.
Parameters:
-
common_name(str) –Common name of the certificate subject.
Returns:
Source code in proxystore/endpoint/auth.py
server_ssl_context
¶
server_ssl_context(
cert_pem: bytes, key_pem: bytes
) -> SSLContext
Create a server SSL context from a PEM-encoded certificate and key.
The certificate and key are never written to the endpoint directory.
SSLContext.load_cert_chain() only
accepts file paths, so they are briefly written to a private temporary
directory.
Source code in proxystore/endpoint/auth.py
certificate_fingerprint
¶
pem_certificate_fingerprint
¶
Compute the SHA-256 fingerprint of a PEM-encoded certificate.