Overview

Namespaces

  • Core
    • Auth
    • Exceptions
    • Helpers
    • Providers
  • Kernel
    • Dispatch
    • Providers
  • None
  • Vendor
    • ExampleVendor

Classes

  • Permission
  • Router
  • Overview
  • Namespace
  • Class
  • Download

Class Permission

Manages the permissions required for a specific call (Controller->action()).
If the user has not enough permissions, it returns a __throw_to action to redirect them to.

Namespace: Kernel\Providers
Package: Kernel
Example:
; For LoginController, it should look something like
[Login]
    __throw_to = "Login" ; any unauthorized request goes to the Login path (check routing.ini)
     * = 2               ; As a general rule, in this example all calls require being authenticated
    showLogin = 1        ; Of course, to log in you must be guest, so this has level=1
    login = 1 ; user     ; On submitting the login form, you are not authenticated yet! level=1
    showLoginHome = 2    ; Once logged in, you go to the "admin zone": level=2

Usage:

Enter the name of the Controller (but without writing "Controller"; e.g., for HomeController, write [Home].
There is no ambiguity here, for there should be no direct access/permission to Model files.

By default, <Controller>@<action> has permission level = 1 for all controllers and actions.
That means, if you don't write it down there'll be no errors thrown, but also no security level!


Located at app/Kernel/Providers/Permission.php
Methods summary
public static Kernel\Providers\Permission
# singleton( )

Returns a Permission instance, creating it if it did not exist

Returns a Permission instance, creating it if it did not exist

Returns

Kernel\Providers\Permission
public boolean
# checkPermission( string $controller, string $method )

Returns whether the user has permission to acces a given method

Returns whether the user has permission to acces a given method

Parameters

$controller
The controller name
$method
The method name

Returns

boolean
$accessAllowed;
public integer
# getUserPermission( )

Returns the user permission as an integer.

Returns the user permission as an integer.

Returns

integer
user permission
public Kernel\Providers\Permission
# setUserPermission( integer $level = 1 )

Sets a permission level to the current user

Sets a permission level to the current user

Parameters

$level
= 1 The permission level

Returns

Kernel\Providers\Permission
Ribosome API documentation generated by ApiGen