lucee.Componentmodels.CBSecurity
Copyright since 2016 by Ortus Solutions, Corp www.ortussolutions.com --- This service is in charge of offering security capabilties to your ColdBox applications It can be injected by using the `@cbSecurity` annotation
property name="cbSecurity" inject="@cbsecurity";Or you can use the `cbSecure()` mixin
cbsecure().secure();
Property Summary | ||||
---|---|---|---|---|
type | property | default | serializable | required |
any
|
DBLogger
|
true
|
false
|
|
any
|
async
|
true
|
false
|
|
any
|
authService
The auth service in use according to the configuration file.
|
true
|
false
|
|
any
|
log
|
true
|
false
|
|
any
|
moduleSettings
|
true
|
false
|
|
any
|
settings
|
true
|
false
|
|
any
|
userService
The user service in use according to the configuration file.
|
true
|
false
|
|
any
|
wirebox
|
true
|
false
|
Constructor Summary | |
---|---|
init()
Constructor. |
Method Summary | |
---|---|
private any
|
_when(boolean target, any success, [any failure])
TODO: Migrate from FlowHelpers once ColdBox 7 goes gold. |
boolean
|
all(any permissions)
Verify that ALL the permissions passed must exist within the authenticated user. |
private any
|
arrayWrap(any items)
convert one or a list of permissions to an array, if it's an array we don't touch it. |
any
|
authenticate(any username, any password)
Login Facade. |
any
|
createPassword([numeric length='32'], [boolean letters='true'], [boolean numbers='true'], [boolean symbols='true'])
Generate a random, secure password using several options. |
string
|
getAsync()
|
any
|
getAuthService()
Get the authentication service defined accordingly in the settings. |
string
|
getDBLogger()
|
struct
|
getDefaultRuleSettings()
Get the default rule settings structure. |
string
|
getLog()
|
string
|
getModuleSettings()
|
string
|
getRealHost([boolean trustUpstream='true'])
Get the real host by looking at the upstreams if trusted or not. |
string
|
getRealIP([boolean trustUpstream='true'])
Get Real IP, by looking at clustered, proxy headers and locally. |
string
|
getSettings()
|
any
|
getUser()
Get the authenticated user. |
any
|
getUserService()
Get the user service object defined accordingly in the settings. |
string
|
getWirebox()
|
any
|
guard()
Alias proxy if somebody is coming from cbguard, proxies to the secure() method. |
boolean
|
has(any permissions)
Verify if the incoming permissions exist in the currently authenticated user. |
boolean
|
isLoggedIn()
Verifies if a user is logged in. |
void
|
logout()
Logout Facade. |
boolean
|
none(any permissions)
Verify that NONE of the permissions passed must exist within the authenticated user. |
any
|
onDIComplete()
|
boolean
|
sameUser(any user)
Verify that the passed in user object must be the same as the authenticated user. |
CBSecurity
|
secure(any permissions, [any message='[runtime expression]'])
Verifies if the currently logged in user has any of the passed permissions. |
CBSecurity
|
secureAll(any permissions, [any message='[runtime expression]'])
Verifies if the currently logged in user has ALL of the passed permissions. |
CBSecurity
|
secureNone(any permissions, [any message='[runtime expression]'])
Verifies if the currently logged in user has NONE of the passed permissions. |
CBSecurity
|
secureSameUser(any user, [any message='[runtime expression]'])
Verifies that the passed in user object must be the same as the authenticated user. |
any
|
secureView(any event, any permissions, any successView, [any failView])
This method is injected into all request contex's in order to allow you to easily. |
any
|
secureViewProxy(any permissions, any successView, [any failView])
This is the method proxy injected into the request context that will act like the. |
CBSecurity
|
secureWhen(any context, [any message='[runtime expression]'])
Verifies the passed in context closure/lambda/udf to a boolean expression. |
any
|
setAsync(any async)
|
any
|
setAuthService(any authService)
|
any
|
setDBLogger(any DBLogger)
|
any
|
setLog(any log)
|
any
|
setModuleSettings(any moduleSettings)
|
any
|
setSettings(any settings)
|
any
|
setUserService(any userService)
|
any
|
setWirebox(any wirebox)
|
any
|
when(any permissions, any success, [any fail])
This method will verify that any permissions must exist in the currently logged in user. |
any
|
whenAll(any permissions, any success, [any fail])
This method will verify that ALL permissions must exist in the currently logged in user. |
any
|
whenNone(any permissions, any success, [any fail])
This method will verify that NONE of the permissions must exist in the currently logged in user. |
Methods inherited from class lucee.Component |
---|
None |
Constructor Detail |
---|
Constructor
Property Detail |
---|
access
- publicrequired
- falsereturntype
- anyinject
- DBLogger@cbsecurityserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- coldbox:asyncManagerserializable
- trueThe auth service in use according to the configuration file
access
- publicrequired
- falsereturntype
- anyserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- logbox:logger:{this}serializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- coldbox:setting:modulesserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- coldbox:moduleSettings:cbsecurityserializable
- trueThe user service in use according to the configuration file
access
- publicrequired
- falsereturntype
- anyserializable
- trueaccess
- publicrequired
- falsereturntype
- anyinject
- wireboxserializable
- trueMethod Detail |
---|
TODO: Migrate from FlowHelpers once ColdBox 7 goes gold. This function evaluates the target boolean expression and if `true` it will execute the `success` closure else, if the `failure` closure is passed, it will execute it.
target
- The boolean evaluator, this can be a boolean valuesuccess
- The closure/lambda to execute if the boolean value is truefailure
- The closure/lambda to execute if the boolean value is falseVerify that ALL the permissions passed must exist within the authenticated user
permissions
- One, a list or an array of permissionsconvert one or a list of permissions to an array, if it's an array we don't touch it
items
- One, a list or an arrayLogin Facade
username
- The username to log in withpassword
- The password to log in withGenerate a random, secure password using several options
length
- The length of the password. Defaults to 32 charactersletters
- Use lettersnumbers
- Use numberssymbols
- Use symbolsGet the authentication service defined accordingly in the settings
Get the default rule settings structure
Get the real host by looking at the upstreams if trusted or not
trustUpstream
- If true, we check the forwarded headers first, else we don'tGet Real IP, by looking at clustered, proxy headers and locally.
trustUpstream
- If true, we check the forwarded headers first, else we don'tGet the authenticated user Change to delegates on CB7
Get the user service object defined accordingly in the settings
Alias proxy if somebody is coming from cbguard, proxies to the secure() method
Verify if the incoming permissions exist in the currently authenticated user. All permissions are Or'ed together
permissions
- One, a list or an array of permissionsVerifies if a user is logged in
Logout Facade
Verify that NONE of the permissions passed must exist within the authenticated user
permissions
- One, a list or an array of permissionsVerify that the passed in user object must be the same as the authenticated user Equality is done by evaluating the `getid()` method on both objects.
user
- The user to test for equalityVerifies if the currently logged in user has any of the passed permissions.
permissions
- One, a list or an array of permissionsmessage
- The error message to throw in the exceptionVerifies if the currently logged in user has ALL of the passed permissions.
permissions
- One, a list or an array of permissionsmessage
- The error message to throw in the exceptionVerifies if the currently logged in user has NONE of the passed permissions.
permissions
- One, a list or an array of permissionsmessage
- The error message to throw in the exceptionVerifies that the passed in user object must be the same as the authenticated user. Equality is done by evaluating the `getid()` method on both objects. If the equality check fails, a `NotAuthorized` exception is thrown.
user
- The user to test for equalitymessage
- The error message to throw in the exceptionThis method is injected into all request contex's in order to allow you to easily switch between views if the permissions are not found in the user.
event
- The proxied request contextpermissions
- One, a list or an array of permissionssuccessView
- The view to set in the request context if the permissions passfailView
- The view to set in the request context if the permissions fails, optionalThis is the method proxy injected into the request context that will act like the `secureView()` method velow
permissions
- One, a list or an array of permissionssuccessView
- The view to set in the request context if the permissions passfailView
- The view to set in the request context if the permissions fails, optionalVerifies the passed in context closure/lambda/udf to a boolean expression. If the context is true, then the exception is thrown. The context must be false in order to pass. The context udf/closure/lambda must adhere to the following signature
function( user ){} ( user ) => {}It receives the currently logged in user
context
- A closure/lambda/udf that returns boolean, or a boolean expressionmessage
- The error message to throw in the exceptionasync
authService
DBLogger
log
moduleSettings
settings
userService
wirebox
This method will verify that any permissions must exist in the currently logged in user. - If the result is true, then it will execute the success closure/lambda or udf. - If the restul is false, then it will execute the fail closure/lambda or udf The success or fail closures/lambdas/udfs must match the following signature
function( user, permissions ){} ( user, permissions ) => {}They receive the currently logged in user and the permissions that where evaluated
permissions
- One, a list, an array of permissions or boolean evaluationsuccess
- The closure/lambda/udf that executes if the context passesfail
- The closure/lambda/udf that executes if the context failsThis method will verify that ALL permissions must exist in the currently logged in user. - If the result is true, then it will execute the success closure/lambda or udf. - If the restul is false, then it will execute the fail closure/lambda or udf The success or fail closures/lambdas/udfs must match the following signature
function( user, permissions ){} ( user, permissions ) => {}They receive the currently logged in user and the permissions that where evaluated
permissions
- One, a list or an array of permissionssuccess
- The closure/lambda/udf that executes if the context passesfail
- The closure/lambda/udf that executes if the context failsThis method will verify that NONE of the permissions must exist in the currently logged in user. - If the result is true, then it will execute the success closure/lambda or udf. - If the restul is false, then it will execute the fail closure/lambda or udf The success or fail closures/lambdas/udfs must match the following signature
function( user, permissions ){} ( user, permissions ) => {}They receive the currently logged in user and the permissions that where evaluated
permissions
- One, a list or an array of permissionssuccess
- The closure/lambda/udf that executes if the context passesfail
- The closure/lambda/udf that executes if the context fails