Documentation

How-tos / How to make your own Authenticator

If you need more control over user rights, we suggest making your own authenticator. They are fairly simple, and you should be able to construct one with basic knowledge in either PHP or .NET.

PHP

In PHP, you can copy one of the existing Authenticators, for example, copy the "/moxiemanager/plugins/SessionAuthenticator" folder into a new folder called "CustomAuthenticator". In that folder is a single Plugin.php file that checks authentication, add checks against your system, and return true if the user is verified, otherwise false. You can also fiddle with the config etc.

<?php
/**
 * Plugin.php
 *
 * Copyright 2003-2013, Moxiecode Systems AB, All rights reserved.
 */
class MOXMAN_CustomAuthenticator_Plugin implements MOXMAN_Auth_IAuthenticator {
	public function authenticate(MOXMAN_Auth_User $user) {
    // CHECK AGAINST YOUR SYSTEM IF USER CAN ACCESS MOXIEMANAGER OR NOT, COULD BE VIA SESSION, LOADING SOME LIB AND RUNNING A FUNCTION ETC.
    // IF HE CAN NOT, RETURN FALSE HERE
    return false;
    
    // IF USER HAS ACCESS, PROCEED THROUGH AND SETUP SOME CUSTOM CONFIG
		$config = MOXMAN::getConfig();
		// Lets overwrite some settings.
		$myConfig = array();
		$myConfig["filesystem.rootpath"] = "c:\inetpub\wwwroot";
		// Extend the config with the session config
		$config->extend($myConfig);

		// The user is authenticated so let them though
		return true;
	}
}
MOXMAN::getAuthManager()->add("CustomAuthenticator", new MOXMAN_CustomAuthenticator_Plugin());

.NET

It is a bit more complicated in .NET, since you need to compile a plugin. Create a bare base project called "MoxieManager.Plugins.CustomAuthenticator", put a single file called Plugin.cs in it, and compile it, add it to the server Bin folder and config it into web.config. If you are familiar with .NET you should be able to use this to empower your integration.

using System;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.IO;
using System.Xml;
using MoxieManager.Core;
using MoxieManager.Core.Auth;
using MoxieManager.Core.Util;

namespace MoxieManager.Plugins.CustomAuthenticator {
    public class Plugin : IPlugin, IAuthenticator {
        public void Init() {
        }

        public bool Authenticate(User user) {
            var config = ManagerContext.Current.Config;
            // You can access session context here if needed.
            //var session = ManagerContext.Current.HttpContextBase.Session;

            // THIS WOULD BE WHEN YOU RUN CHECKS TO SEE IF USER LOGGED INTO YOUR SYSTEM CAN ACCESS MOXIEMANAGER
            // COULD BE VIA CHECKING A SESSION, OR IMPLEMENTING SOMETHING TO CHECK AGAINST, JUST INCLUDE LIB ABOVE.
            return false;

            // PUT SOME CUSTOM CONFIG OPTIONS
            config.Put("filesystem.rootpath", "c:\inetpub\wwwroot");
            
            // The user is authenticated so let them though
            return true;
        }

        public string Name {
            get { return "CustomAuthenticator"; }
        }
    }
}

Return true after you check if the user is authenticated in your system, otherwise return false.