Behavior: MynaAuth

Applies action.controller based authentication and rights checking to controllers.

This behavior uses Myna’s centralized authentication and permissions system to authenticate this controller’s actions.  Each action is treated as a right in the form of “<controllerName>.<actionName>”.  If the current user is not authenticated, they are sent to Myna’s centralized login page and authenticated against one of the defined AuthTypes (see: AuthAdapters)

Parameters

whiteListOptional, default [] Array of action names that do not require authentication
providersOptional, default <Myna.Permissions.getAuthTypes> Array of provider names (AuthTypes) to make available from authentication,
redirectParamsOptional, default {} Any extra parameters to $res.redirectLogin.  This behavior will automatically set the callbackUrl to the originally requested action
userFunctionOptional, default $cookie.getAuthUser Function to call to acquire the user to test against permissions.  This function will be passed a reference to the controller, and this options object

Usage

// used in a single controller
//main_controller.sjs
function init(){
this.applyBehavior("MynaAuth",{
whitelist:[
"logout",
"dashbord",
/^rpt/
],
providers:Myna.Permissions.getAuthTypes(),//this is default
redirectParams:{}//this is default
})
}

// used in the global controller
//app/controllers/global.sjs
function init(){
this.applyBehavior("MynaAuth",{
whitelist:[
"Main.logout",
"Main.dashbord",
/^Public\./
],
providers:Myna.Permissions.getAuthTypes(),
redirectParams:{},
userFunction:function(controller,options){
return controller._getUser()
}
})
}
Auth Adapters are customizable authentication modules that can be used with Myna’s permissions system or separately.
redirectLogin:function(options)
Redirect this page to the central login page