User Guide > Tasks > Working with Cloud Connected Mobile > Adding and Testing Authentication

Adding and Testing Authentication

The following procedures describe how to add, configure and test authentication for the services handled by the Zend Server Gateway.

Adding HTTP Basic/Digest Authentication

This procedure explains how to add HTTP Basic or Digest authentication to an RPC or RESTful API method. For information on adding Token authentication, see Adding Token Authentication below.

 

 

Instructions on how to complete a procedure

To add HTTP Basic/Digest authentication:

  1. In the PHP Explorer, open the 'config' folder of your CCM server-side project, and select the 'gateway.xml 'file .
    The file is displayed in a graphic editor.

  1. From the Handlers list on the right, drag and drop the Authenticate element after the Initialize stage.
    The Authentication dialog is displayed.

  1. Select HTTP Basic/Digest authentication type.
  2. Configure the following authentication parameters:
    1. Select the HTTP authentication method (Basic, Digest, Basic and Digest).
    2. Select the allowed resolvers (htpasswd, htdigest, callback).

    3. Click File to view the 'users.htpasswd' file used for authentication. Click Browse to use a different file.
  3. Click OK.
    Authentication is added to the Zend Server Gateway, and is displayed in the editor. The

Note:

Once added, all defined services in the Gateway will automatically require authentication. To change this, select a service and un-select the Requires authentication check-box.

Adding Token Authentication

This procedure explains how to add Token authentication to an RPC or RESTful API method. For information on adding HTTP Basic/Digest authentication, see Adding HTTP Basic/Digest Authentication above.

 

 

Instructions on how to complete a procedure

To add Token authentication:

  1. In the PHP Explorer, open the 'config' folder of your CCM server-side project, and select the 'gateway.xml 'file .
    The file is displayed in a graphic editor.

  1. From the Handlers list on the right, drag and drop the Authenticate element after the Initialize stage.
    The Authentication dialog is displayed.

  1. Select the Token authentication type.

  1. Use the resolver callback generated automatically, or click Browse to select a different file.
  2. Click OK.
    Authentication is added to the Zend Server Gateway, and is displayed in the editor.

Note:

Once added, all defined services in the Gateway will automatically require authentication. To change this, select a service , and in the Edit Service dialog un-select the Requires authentication check-box.

Testing Authentication

This procedure explains how to test authentication for an existing RPC or RESTful API method.

Important:

Testing authentication can only be performed if you have already successfully deployed the application. In the PHP Explorer, open the 'deployment.xml' file and in the Testing area, click Deploy a PHP Application. For more information on deploying applications, see Working with Deployment.

 

 

Instructions on how to complete a procedure

To test authentication:

  1. In the PHP Explorer, open the 'config' folder of your CCM server-side project, and select the 'gateway.xml 'file .
    The file is displayed in a graphic editor.

  1. Right-click the service you wish to test authentication for, and select Test Service .
    The Test Service view is displayed.

  1. Verify the URL at the top of the view. It should be automatically displaying the correct URL for the selected service.
  2. Click .
    You will receive a '401 Unauthorized' response message.

  1. Select the Authentication required check-box.
    The Service authentication dialog is displayed.

  1. Enter a valid username and password in the relevant fields, and click OK.
    The authentication header is added
  1. Click .
    You will receive a '200 OK' response message.

Important!

If you are using Windows, you will need to un-comment the following lines in the '.htaccess' file, in the server-side project's 'public' folder, to authenticate your requests:
*RewriteCond %{HTTP:Authorization} ^(.*)
*RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

 

 

Related Links

Related Links:

Cloud Connected Mobile

Configuring the Zend Server Gateway

Adding and Testing a New Method Route

Adding Validation to Method Routes

Procedural Configuration

Test Service View

 

 

 

©1999-2013 Zend Technologies LTD. All rights reserved.