[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/mambots/editors/mostlyce/jscripts/tiny_mce/filemanager/connectors/php/Docs/ -> AuthenticationHandlers.txt (source)

   1  Authentication via connector::
   2  
   3  In my PHP connector the one from the FBXP project, it is 
   4  possible to require authentication before a user can use
   5  the connector. 
   6  
   7  The works in the following manor:-
   8  
   9  A1/ File Browser Requests Command From Connector
  10  A2/ Connector.php recieves the request
  11      B1/ File config.php imported
  12      B2/ If authentication required load the authentication
  13          handler file specified in the config, i.e.
  14          $config['auth']['HandlerClass']='Default';
  15          the Auth/Default.php will be imported
  16      B3/ Create new instance of Auth class (defined in the
  17          authentication handler imported.
  18          C1/ Auth class, authenticate method called, passing
  19              the data recieved in the ExtraParams variable
  20              of the query string.
  21          C2/ authenticate method returns a modified copy of the 
  22              $config, to indicate successfull authentication
  23              $config['authSuccess'] should be set to true, if
  24              the authentication failed this should be set to false.
  25          
  26      B4a/ on success command is executed and output sent to client
  27      B4b/ on failure blank xml response returned.
  28  
  29  A3/ End
  30  
  31  
  32  How to create my own authentication handler::
  33  
  34  Create a file in the Auth folder with the name of the handler (your choice)
  35  i.e. If i wanted to call it MySQL the file i would create would be
  36  MySQL.php in the Auth folder.
  37  
  38  Skeleton for the new authentication class::
  39  <?php
  40  class Auth {
  41  	function authenticate($data,$config) {
  42      
  43      }
  44  }
  45  ?>
  46  
  47  as you can see the class must have a method called authenticate which
  48  takes two parameters, the value from the ExtraParams ($data) and a 
  49  reference to the connector configuration $config (so you can change
  50  things depending on the user if you wish) , you can now put what
  51  ever code you like in that method to determine if the user is allowed 
  52  or not. (you may add extra function to the class for internal use too,
  53  these will not be called by the connector, but call them from inside
  54  the authenticate method). The function returns a modified copy of the
  55  $config, with any changes you like + the addition of a top level 
  56  array element key: authSuccess   value: true if authentication
  57  successful, else false.
  58  
  59  If you want to limit what the user can do then you may want to change 
  60  the array at: $config['Commands']
  61  This holds an array of command that can be executed, if you remove say
  62  DeleteFolder from the array then the user will not be able to delete 
  63  a folder.
  64  
  65  
  66  By Example:: There is a default authentication handler that i wrote to
  67  distribute with the connector, so you may want to take a look at it
  68  to get a better idea of whats going on.