Skip to content

Latest commit

 

History

History
40 lines (29 loc) · 2.18 KB

authentication_and_right_management.md

File metadata and controls

40 lines (29 loc) · 2.18 KB

Authentication and authorization

Wordpress features a complete user management system. It also features a system to manage authorization via Roles and capabilities.

Mouf on the other hand features an authentication system named UserService and a authorization system named RightsService. The rights service in Mouf has the notion of "right" that maps the notion of "capability" in Wordpress. The notion of "role" in Mouf is voluntarily absent (in order to allow developers to add whatever they want).

When you install Moufpress, the install process will create 2 instances related to authentication and authorization:

  • userService : an instance of the MoufpressUserService class that is compatible with the UserServiceInterface
  • rightsService : an instance of the MoufpressRightService class that is compatible with the RightServiceInterface

Many packages in Mouf rely on those 2 instances so installing those will allow those packages to integrate directly with Wordpress rights.

Note: if you want to create additional rights in Mouf, you have to declare additional capabilities (since Mouf's right = Wordpress capability). These capabilities can be created using the add_cap Wordpress function. You can also manage roles and capabilities using many well designed plugins like role-manager.

A few exemples of what you can do with these objects:

// Connects the user
Mouf::getUserService()->login('login', 'password');

// Returns whether a user is connected or not
$isLogged = Mouf::getUserService()->isLogged();

// Returns the login of the current logged user
$login = Mouf::getUserService()->getUserLogin();

// Returns whether the logged user has rights to 'read' articles (mapping the 'read' capability in Wordpress)
$isAllowed = Mouf::getRightsService()->isAllowed('read');