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
anyUserListOptional, default [] Array of action names that do not require a specific right, but do require an authenticated user
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

Note

This behavior only protects the controllers to which it is applied.  If this is not set in the global controller your application may be at risk for unauthorized access

Usage

// 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()
}
})
}

// 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
})
}
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