Replies: 3 comments 9 replies
-
No need for this, the target instance should be encoded in JWT claims instead. |
Beta Was this translation helpful? Give feedback.
-
Sorry, a few things are not clear to me. I see the diagram, but I don't understand what parts of it are HTTP and what parts are using ClientHandshake. In fact the current diagram is quite confusing at that. Will the The Why can't the |
Beta Was this translation helpful? Give feedback.
-
In off-thread discussions we reached a consensus that this approach would insert too much of a control plane surface (and hence failure modes) into the user path, so we'll be going with consistent instance endpoint naming and adding direct support for token authentication to server instead. |
Beta Was this translation helpful? Give feedback.
-
Brief
EdgeDB cloud instances will have (relatively speaking) dynamic DSN to connect, given a static unique name like "org_name/instance_name". The Cloud API would provide a way for EdgeDB clients to resolve the cloud instance name into DSN securely. Now that many (if not most) programming languages don't have a built-in HTTPS client, we are proposing to add this support of authenticated redirection in the edgedb-binary protocol.
"The Client" can be either the CLI or the language bindings. The CLI could
cloud login
to get the token, while the language bindings could load the token from environment variable or the file where CLI stored the token.Even though this proposal is targeting cloud redirection, but this could potentially be used in other scenarios too.
Proposal
The Client should start the JWT authentication with a
ClientHandshake
message. Instead of sendinguser
anddatabase
in the connection parameters, the Client should include the following connection parameters in order to authenticate for a cloud redirect:token
- the JWT tokeninstance
- the name of the cloud instance to connectIf the JWT authentication is a success, the cloud server should return the following messages sequencially:
AuthenticationOK
- indicating the JWT token is acceptedServerKeyData
- not used for nowStateDataDescription
- not usedParameterStatus
with namecredentials
- the DSN/credentials to connect to the actual instance, value explained laterTerminate
- indicating the current connection must be terminatedIf the JWT authentication is a failure, a single
ErrorResponse
message is returned. In either case, the server will actively close the connection after returning.The value of the
credentials
ParameterStatus
is similar to theParameterStatus_SystemConfig
:And
DataElement
is again the same as it is in theData
message:An typical credentials type descriptor looks like this:
On receiving credentials, the client could then establish a new connection to the target server.
The Client is suggested to cache the resolved credentials in memory (for language bidnings) or on disk (for the CLI) for a reasonable time (e.g. 30 seconds in memory, or maybe days on disk because 1) the DSN shouldn't change often and 2) connection failure invalidates the cache, explained later), in order to reduce round-trip latency in cases when connections are established frequently. On a failed connection to the target server, the Client should consider invalidating the cache and re-resolve the cloud instance name. This should be transparently done without raising an error to the end-user like all other retry logic, until max retry attempts reached. Ideally, language bindings should not try to resolve the same cloud instance name concurrently, as the result would be the same.
Beta Was this translation helpful? Give feedback.
All reactions