Citrix Storefront - Adventures in customization - Login via credentials in URL search query

30 Oct 2017

If you use a 3rd party service to connect to your Citrix Storefront environment, you may want to “pass-through” credentials without using domain authentication or whatever. This post illustrates how you can login to your Storefront environment using nothing more than a URL with your credentials embedded in them. To enable this functionality, this code must be in your custom.js file.

// CTXS.getParametersFromQueryString(window.location.search.substring(1))  //grab URL query parameters
var username = CTXS.getParametersFromQueryString(window.location.search.substring(1)).username
var password = CTXS.getParametersFromQueryString(window.location.search.substring(1)).password


CTXS.Extensions.beforeLogon = function(callback) {
	if (username) {
		var a = "PostCredentialsAuth/Login";
		$.ctxsAjax({

	                type: "POST",
        	        url: a,
					async: false,
                	data: { username: username, password: password },
                	dataType: "json",

                	suppressEvents: !0,
                	refreshSession: !0

            	})
		CTXS.Location.assign(CTXS.Location.origin + CTXS.Location.pathname);  //remove URL query parameters
      	}
	callback();
};

You MUST have HTTP Basic enabled as an authentication method on your Citrix Storefront Store.

The URL to login would look like this:

http://storefront.bottheory.local/Citrix/StoreWeb/?username=BOTTHEORY\ttye&password=C0mplexPAsswordHorseStapl

Put it all together: