Authentication Strategies
Token Authentication
- This is the default authentication strategy
- No additional code is needed
Webhook Authentication
- You need to create an endpoint on your backend (i.e. a webhook)
- The virtual computer will hit your endpoint when a new user tries to connect
- Your backendâs webhook response controls whether the user is granted access
- To set the authentication strategy, you provide an authentication object when starting a cloud computer session:
Setting the Authentication Strategy
To set the authentication strategy, you provide an authentication object when starting a cloud computer session: Token Authentication (Default)Request Body
In-Depth
Token Authentication
When using token authentication, a token is added as a query parameter to the cloud computerâs embed URL. This ensures only users that were provided the embed URL have access to the cloud computerâmalicious actors cannot gain access via the session ID or brute force.Webhook Authentication
Start a cloud computer session with webhook authentication- Set the
Authorizationheader toAuthorization: Bearer <bearer-token><bearer-token>is the token you provided in the authentication object
- Set the
HB-User-Agentheader to the clientâs user agent - Set the
HB-Connection-IPheader to the clientâs IP address - Send a
POSTrequest with a JSON request bodyuser_idis the userâs Hyperbeam identifieruserdatais thewebhookUserdataobject passed into the Hyperbeam JavaScript SDK
localhost:8080). We recommend using ngrok to expose your endpoint for testing.
Your webhook must:
- Check that the bearer token in the Authorization header matches the token you provided
-
Parse the request body and determine if the user should be granted access
- You can use the
user_idand userdata fields to identify the user
- You can use the
-
Send back a
200status with a JSON response body- To grant user access, send back
{"authorized": true} - To deny user access, send back
{"authorized": false} - Any response that doesnât have a 200 status code will deny user access
- If the âauthorizedâ key is not set, the user will be denied
- You can provide a permissions object in the response to atomically set the permission values of the user
- To grant user access, send back