The Queue-it Security Framework is used to ensure that end users cannot bypass the queue by adding a server-side integration to your server.
When a user is redirected back from the queue to your website, the queue engine can attache a query string parameter (queueittoken) containing some information about the user.
The most important fields of the queueittoken are:
- q - the users unique queue identifier
- ts - a timestamp of how long this redirect is valid
- h - a hash of the token
The high level logic is as follows:
- User requests a page on your server
- The validation method sees that the has no Queue-it session cookie and no
queueittokenand sends him to the correct queue based on the configuration - User waits in the queue
- User is redirected back to your website, now with a
queueittoken - The validation method validates the
queueittokenand creates a Queue-it session cookie - The user browses to a new page and the Queue-it session cookie will let him go there without queuing again
To validate that the current user is allowed to enter your website (has been through the queue) these steps are needed:
- Providing the queue configuration to the KnownUser validation
- Validate the
queueittokenand store a session cookie
The recommended way is to use the Go Queue-it self-service portal to setup the configuration. The configuration specifies a set of Triggers and Actions. A Trigger is an expression matching one, more or all URLs on your website. When a user enter your website and the URL matches a Trigger-expression the corresponding Action will be triggered. The Action specifies which queue the users should be send to. In this way you can specify which queue(s) should protect which page(s) on the fly without changing the server-side integration.
This configuration can then be downloaded to your application server as shown in the IntegrationConfigProvider example. The configuration will be downloaded and cached for 5 minutes.
To validate that the user has been through the queue, use the KnownUser.validateRequestByIntegrationConfig() method.
This call will validate the timestamp and hash and if valid create a "QueueITAccepted-SDFrts345E-V3_[EventId]" cookie with a TTL as specified in the configuration.
If the timestamp or hash is invalid, the user is send back to the queue.
The KnownUser validation must only be done on page requests.
This example is using the IntegrationConfigProvider to download the queue configuration.
The following method is all that is needed to validate that a user has been through the queue:
private void doValidation(HttpServletRequest request, HttpServletResponse response) {
try {
String customerId = "Your Queue-it customer ID";
String secretKey = "Your 72 char secrete key as specified in Go Queue-it self-service platform";
String queueitToken = request.getParameter(KnownUser.QUEUEIT_TOKEN_KEY);
String pureUrl = getPureUrl(request);
CustomerIntegration integrationConfig = IntegrationConfigProvider.getCachedIntegrationConfig(customerId);
//Verify if the user has been through the queue
RequestValidationResult validationResult = KnownUser.validateRequestByIntegrationConfig(
pureUrl, queueitToken, integrationConfig, customerId, request, response, secretKey);
if (validationResult.doRedirect()) {
//Send the user to the queue - either becuase hash was missing or becuase is was invalid
response.sendRedirect(validationResult.getRedirectUrl());
} else {
String queryString = request.getQueryString();
//Request can continue - we remove queueittoken form querystring parameter to avoid sharing of user specific token
if (queryString != null && queryString.contains(KnownUser.QUEUEIT_TOKEN_KEY)) {
response.sendRedirect(pureUrl);
}
}
} catch (Exception ex) {
//There was an error validationg the request
//Use your own logging framework to log the Exception
//This was a configuration exception, so we let the user continue
}
}
If your application server (maybe due to security reasons) is not allowed to do external GET requests, then you have three options:
- Manually download the configuration file from Queue-it Go self-service portal, save it on your application server and load it from local disk
- Use an internal gateway server to download the configuration file and save to application server
- Specify the configuration in code without using the Trigger/Action paradigm. In this case it is important only to queue-up page requests and not requests for resources or AJAX calls. This can be done by adding custom filtering logic to Global.asax
The following is an example of how to specify the configuration in code:
private void doValidationByLocalEventConfig(HttpServletRequest request, HttpServletResponse response) {
try {
String customerId = "Your Queue-it customer ID";
String secretKey = "Your 72 char secrete key as specified in Go Queue-it self-service platform";
String queueitToken = request.getParameter(KnownUser.QUEUEIT_TOKEN_KEY);
String pureUrl = getPureUrl(request);
EventConfig eventConfig = new EventConfig();
eventConfig.setEventId("event1"); //ID of the queue to use
eventConfig.setCookieDomain(".mydomain.com"); //Optional - Domain name where the Queue-it session cookie should be saved. Default is to save on the domain of the request
eventConfig.setQueueDomain("queue.mydomain.com"); //Optional - Domian name of the queue. Default is [CustomerId].queue-it.net
eventConfig.setCookieValidityMinute(15); //Optional - Validity of the Queue-it session cookie. Default is 10 minutes
eventConfig.setExtendCookieValidity(false); //Optional - Should the Queue-it session cookie validity time be extended each time the validation runs? Default is true.
eventConfig.setCulture("en-US"); //Optional - Culture of the queue ticket layout in the format specified here: https://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx Default is to use what is specified on Event
eventConfig.setLayoutName("MyCustomLayoutName"); //Optional - Name of the queue ticket layout - e.g. "Default layout by Queue-it". Default is to use what is specified on the Event
//Verify if the user has been through the queue
RequestValidationResult validationResult = KnownUser.validateRequestByLocalEventConfig(pureUrl, queueitToken, eventConfig, customerId, request, response, secretKey);
if (validationResult.doRedirect()) {
//Send the user to the queue - either becuase hash was missing or becuase is was invalid
response.sendRedirect(validationResult.getRedirectUrl());
} else {
String queryString = request.getQueryString();
//Request can continue - we remove queueittoken form querystring parameter to avoid sharing of user specific token
if (queryString != null && queryString.contains(KnownUser.QUEUEIT_TOKEN_KEY)) {
response.sendRedirect(pureUrl);
}
}
} catch (Exception ex) {
//There was an error validationg the request
//Please log the error and let user continue
}
}
