Class AmfphpAuthentication

Description

Authentication for Amfphp.

On a service object, the plugin looks for a method called getMethodRoles. If the method exists, the plugin will look for a role in the session that matches the role. If the roles don't match, an Exception is thrown. The getMethodRoles takes a parameter $methodName, and must return an array of strings containing acceptable roles for the method. If the return value is null, it is considered that that particular method is not protected.

For example:

  1.  public function getMethodRoles($methodName){
  2.     if($methodName == "adminMethod"){
  3.         return array("admin");
  4.     }else{
  5.         return null;
  6.     }
  7.  }

To authenticate a user, the plugin looks for a "login" method. This method can either be called explicitly, or by setting a header with the name "Credentials", containing {userid: userid, password: password}, as defined by the AS2 NetConnection.setCredentials method. It is considered good practise to have a "logout" method, though this is optional The login method returns a role in a "string". It takes 2 parameters, the user id and the password. The logout method should call AmfphpAuthentication::clearSessionInfo();

See the AuthenticationService class in the test data for an example of an implementation.

  • author: Ariel Sommeria-klein

Located in /Amfphp/Plugins/AmfphpAuthentication/AmfphpAuthentication.php (line 42)


	
			
Class Constant Summary
 METHOD_GET_METHOD_ROLES = "getMethodRoles"
 METHOD_LOGIN = "login"
 SESSION_FIELD_ROLES = "amfphp_roles"
Variable Summary
String $headerUserId
Method Summary
static void addRole ( $roleToAdd, String $role)
static void clearSessionInfo ()
AmfphpAuthentication __construct ([ $config = null])
AmfphpAuthentication filterAmfRequestHeaderHandler (Object $handler,  $header)
filterServiceObject ( $serviceObject,  $methodName)
void handleRequestHeader ( $header)
Variables
String $headerUserId (line 62)

the user id passed in the credentials header

  • access: public
Methods
static method addRole (line 172)
  • access: public
static void addRole ( $roleToAdd, String $role)
  • String $role
  • $roleToAdd
static method clearSessionInfo (line 158)

clears the session info set by the plugin. Use to logout

  • access: public
static void clearSessionInfo ()
Constructor __construct (line 74)

constructor.

  • access: public
AmfphpAuthentication __construct ([ $config = null])
  • array $config: optional key/value pairs in an associative array. Used to override default configuration values.
filterAmfRequestHeaderHandler (line 87)
  • access: public
AmfphpAuthentication filterAmfRequestHeaderHandler (Object $handler,  $header)
filterServiceObject (line 104)

called when the service object is created, just before the method call.

Tries to authenticate if a credentials header was sent in the packet. Throws an exception if the roles don't match

  • access: public
filterServiceObject ( $serviceObject,  $methodName)
  • $serviceObject
  • $methodName
  • handleRequestHeader (line 197)

    looks for a "Credentials" request header. If there is one, uses it to try to authentify the user.

    • access: public
    void handleRequestHeader ( $header)
    Class Constants
    METHOD_GET_METHOD_ROLES = "getMethodRoles" (line 51)

    the name of the method on the service where the method roles are given

    METHOD_LOGIN = "login" (line 56)

    the name of the login method

    SESSION_FIELD_ROLES = "amfphp_roles" (line 46)

    the field in the session where the roles array is stored

    Documentation generated on Thu, 24 Mar 2011 16:55:37 +0100 by phpDocumentor 1.4.3