Custom authentication

MCFileManager if created to be easy to integrate with existing server applications such as CMS systems, web hosting controllers or LMS systems. So the most common need is to handle authentication of end users.

Writing your own authentication plug in

The most common need for integration is with a systems authentication logic. Verify the level of access the end user has to the system. MCFileManager comes with a built in session authenticator, this authenticator simply checks for two named session variables. But some times more custom logic is required, then you can extend the build in authenticator logic by writing an authenticator plug in.

A authenticator plug in is a PHP class that extends the BaseAuthenicator class located in "filemanager\classes\Authenticators\BaseAuthenticator.php". The default behavior of this base class is that everyone is logged in and the user isn't added to any groups. This behavior can easily be changed if you subclass it and extend the base methods with your logic.

Example of a custom Authenticator class:

class MyAuthenticator extends BaseAuthenticator {
    function MyAuthenticator() {
        // Your custom constructor code
    }

    function init(&$config) {
        // Your custom initialization code
        $config['some.config.option'] = "new value";
    }

    function getGroups() {
        return "mygroup1,mygroup2";
    }

    function isLoggedin() {
        if ($something)
            return true;

        return false;
    }
}

The example above changes a specific config value when it initializes, returns two groups and checks the $something variable to verify access. For more details on the specific methods in BaseAuthenticator consult the API documentation.