How to develop authentication plugin

This tutorial shows you how to configure authentication in your application.

Authentication settings

1. Login into developer panel.

2. Navigate to Application settings > Authentication.

3. On this page you can configure settings about authentication in your application. You can configure authentication user entity, user name attribute, password attribute, user roles attribute. It is possible to reconfigure those existing entities or add new and reconfigure those authentication settings, it will work with system Login plugin. With roles entity and roles name attribute you can configure what will be listed in authorization component. Login page is page where are redirected all not logged users. First page is page shown when you open application. If you change first parameter authentication to No, then all not logged users can access application.

4. You can also select functions that will be used to get logged user, check is logged user in roles and logout user function. Default authentication functions are located in system Login plugin, but you can develop your own authentication functions in your custom plugin. All of these functions must return result as AjaxProxy class.

  • Get logged user function – attribute status of result should be set to true ($result->status = true). Attribute data of result should be an array (i.e. $result->data  = array(“Id” => “1”, “User name” => “admin”, “First name” => “admin”, “Last name” => “admin”)). This function do not accept any parameters.
  • Check is logged user in roles function – if logged user in roles, attribute status of result should be set to true, otherwise should be set to false. This function should accept one parameter with name $roles, it is simple array of integers.
  • Log out user function – attribute status of result should be set to true ($result->status = true). This function do not accept any parameters.