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
| whiteList | Optional, default [] Array of action names that do not require authentication |
| providers | Optional, default <Myna.Permissions.getAuthTypes> Array of provider names (AuthTypes) to make available from authentication, |
| redirectParams | Optional, default {} Any extra parameters to $res.redirectLogin. This behavior will automatically set the callbackUrl to the originally requested action |
| userFunction | Optional, 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()
}
})
}