User Guide > Tasks > Working with Cloud Connected Mobile > Procedural Configuration

Procedural Configuration

This procedure explains how to configure the Zend Server Gateway directly from the PHP. As an example, we will be adding an authentication service using an MySQL database with existing user tables.

 

 

Instructions on how to complete a procedure

To add an authentication service via the PHP:

  1. In the PHP Explorer, locate your server project, expand the public folder, and select the 'index.php 'file.
    The 'index.php' file is displayed, showing how the Zend Server Gateway is initialized.

<?php

set_include_path ( get_include_path () . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../services' );

require_once 'ZendGateway/Main.php';

$gateway->configure ( dirname ( __DIR__ ) . DIRECTORY_SEPARATOR . 'gateway.xml' );

$gateway->send ();

  1. Add Authentication parameters: 
  • The HTTPBasic authentication name.
  • A regular expression pattern. In this example we will include a '/' to require all requests be authenticated.
  • User data provider.
  • Database specific options and properties.
    Example:

$gateway->authenticate(array(

'My Secured API'=> array(

'pattern'=>'/',

'provider'=>array(

'type'=>'db',

'options'=>array(

'driver'=>'Mysqli''

'hostname'=>'127.1.1.1',

'database'=>'daniel'

'username'=>'admin',

'password'=>'1234',

'tableName'=>'users',

'identityColumn'=>'username',

'credentialsColumn'=>'password',

'roleColumn'=>'role',

'options'=>array(

'buffer_results'=>true

)

)

)

)

));

  1. Save the file.
    The new configurations are saved and applied to the Zend Server Gateway.

Test the route from the Test Service view: Select the 'Authentication required' check-box and add authentication headers.

 

 

Related Links

Related Links:

Cloud Connected Mobile

Configuring the Zend Server Gateway

Adding Validation to Method Routes

Adding Validation to Method Routes

Adding and Testing Authentication

 

 

 

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