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 endpoint 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).
EndpointToken
¶
EndpointToken(token: bytes)
Token that a client and endpoint prove they know.
The token is never included in its repr() so it is not accidentally
logged, and tokens are compared in constant time. In pydantic models,
the token is validated from and serialized to its hex encoding.
Parameters:
-
token(bytes) –Token as 32 bytes.
Raises:
-
ValueError–If
tokenis not the correct size.
Source code in proxystore/endpoint/auth.py
from_hex
classmethod
¶
proof
¶
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:
-
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
¶
verify(
role: Literal['client', 'server'],
first_nonce: bytes,
second_nonce: bytes,
proof: bytes,
) -> bool
Verify a proof computed by the other side of the handshake.
Parameters:
-
role(Literal['client', 'server']) –Role of the side that computed the proof.
-
first_nonce(bytes) –Nonce of the side that computed the proof.
-
second_nonce(bytes) –Nonce of the other side.
-
proof(bytes) –Proof to verify.
Source code in proxystore/endpoint/auth.py
TLSCertificate
dataclass
¶
Self-signed TLS certificate and private key of an endpoint.
The private key is never included in its repr().
Attributes:
generate
classmethod
¶
Generate a self-signed TLS certificate and private key.
Parameters:
-
common_name(str) –Common name of the certificate subject.
Source code in proxystore/endpoint/auth.py
ssl_context
¶
ssl_context() -> SSLContext
Create a server SSL context with the 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.