Environment setup ================= As described in the :ref:`security_auth` chapter, the relationship between the in-browser JavaScript code and the SCWS service must be established using a specific :ref:`webapp_certificate` provided by Idopte, and a challenge-response authentication scheme. The functions decribed below must be called before any other API methods to achieve this. Client-side ----------- .. js:autofunction:: SCWS.findService .. js:autofunction:: SCWS.createEnvironment Below is an example usage of these functions, with the call to a specific server-side ``signchallenge.php`` script to produce the required signature: .. code-block:: js var webappcert = "4HfLHzMS05>]T+PeNPwQ=?r-f-mJ4nre!!s7cqOJ0/Os@Kw?HHaS>ewC+WPnDEbhxh:6MUtZIt0+D^Wa2eO?(&l.>A0MDw!JF2K0[8TM{W^[FLaq?oRb{WDRmEmo#oEoV3e The key included in this script represents the :ref:`security_auth` key generated on the customer's side, whose public key is provided to Idopte when requesting the :ref:`webapp_certificate`. .. caution:: Note that the above script does not check the origin of the request. This is volontary, as ensuring that the request effectively comes from a valid client is the responsibility of the web application developer, and depends on the architecture of the entire application. However, not checking the origin of the request before producing the signature is a security weakness and should be avoided. Standard methods such as cookies, or session mechanisms, can be used to solve this requirement.