About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
configuration:permission_options

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
configuration:permission_options [2017/08/30 15:51] demiankatzconfiguration:permission_options [2023/11/09 19:10] (current) demiankatz
Line 1: Line 1:
 ====== Permission Configuration ====== ====== Permission Configuration ======
  
-VuFind 2.4 introduced a configurable permission system, allowing access to certain features of the system to be restricted based on a variety of options such as username, login status, IP address, etc. All of the available rules and permissions are documented in [[https://github.com/vufind-org/vufind/blob/master/config/vufind/permissions.ini|permissions.ini]].+VuFind® 2.4 introduced a configurable permission system, allowing access to certain features of the system to be restricted based on a variety of options such as username, login status, IP address, etc. All of the available rules and permissions are documented in [[https://github.com/vufind-org/vufind/blob/dev/config/vufind/permissions.ini|permissions.ini]].
  
-VuFind 4.1 added another layer of configuration to the system: the ability to configure exactly what VuFind will do when a particular permission is denied. Permissions may be checked in either controllers or templates, and different options are available for denied permissions in each of these places. A controller may throw an exception or display a custom "access denied" message; a template may suppress portions of its output, or display alternate content in the form of a text message or custom sub-template. These newer features are controlled by, and documented within, [[https://github.com/vufind-org/vufind/blob/master/config/vufind/permissionBehavior.ini|permissionBehavior.ini]].+VuFind® 4.1 added another layer of configuration to the system: the ability to configure exactly what VuFind® will do when a particular permission is denied. Permissions may be checked in either controllers or templates, and different options are available for denied permissions in each of these places. A controller may throw an exception or display a custom "access denied" message; a template may suppress portions of its output, or display alternate content in the form of a text message or custom sub-template. These newer features are controlled by, and documented within, [[https://github.com/vufind-org/vufind/blob/dev/config/vufind/permissionBehavior.ini|permissionBehavior.ini]].
  
 +VuFind® 6.1 adds a significant new option to permissionBehavior.ini: the controllerAccess setting, which allows you to control access permissions at the controller level (or even globally, if you wish) without changing any code.
 ===== Structure of permissionBehavior.ini ===== ===== Structure of permissionBehavior.ini =====
  
Line 11: Line 12:
 deniedTemplateBehavior controls the display of template content associated with the permission. If you want to show the content only to people who have logged in, you could define a permission rule in permissions.ini and reference that in permissionBehavior.ini, setting deniedTemplateBehavior to show a blank message (as illustrated in one of the Favorites examples below). deniedTemplateBehavior controls the display of template content associated with the permission. If you want to show the content only to people who have logged in, you could define a permission rule in permissions.ini and reference that in permissionBehavior.ini, setting deniedTemplateBehavior to show a blank message (as illustrated in one of the Favorites examples below).
  
-deniedControllerBehavior controls VuFind's behavior if someone tries to access a page that has been restricted at the controller level.+deniedControllerBehavior controls VuFind®'s behavior if someone tries to access a page that has been restricted at the controller level.
  
 As noted above, all possible values for these options are documented in permissionBehavior.ini. As noted above, all possible values for these options are documented in permissionBehavior.ini.
Line 21: Line 22:
 ==== Search Tabs Permissions ==== ==== Search Tabs Permissions ====
  
-VuFind 4.1 introduces a [SearchTabsPermissions] section in [[configuration:files:config.ini|config.ini]] which allows you to restrict search box tabs using permissions. You can associate the name of a permission from permissions.ini with a tab using this section. You can then set up behaviors in permissionBehavior.ini to control what (if anything) is displayed in place of the tab for restricted users.+VuFind® 4.1 introduces a [SearchTabsPermissions] section in [[configuration:files:config.ini|config.ini]] which allows you to restrict search box tabs using permissions. You can associate the name of a permission from permissions.ini with a tab using this section. You can then set up behaviors in permissionBehavior.ini to control what (if anything) is displayed in place of the tab for restricted users.
  
 Note that [SearchTabsPermissions] ONLY controls the rendering of tabs. It does not prevent users from accessing the searches that those tabs can produce. To restrict actual searching, you will need to pair some controller-specific rules with your search tab permissions. Examples can be found below. Note that [SearchTabsPermissions] ONLY controls the rendering of tabs. It does not prevent users from accessing the searches that those tabs can produce. To restrict actual searching, you will need to pair some controller-specific rules with your search tab permissions. Examples can be found below.
Line 27: Line 28:
 ===== Checking permissions in code ===== ===== Checking permissions in code =====
  
-Starting with VuFind 4.1, the code includes some convenient tools to help with permission management.+Starting with VuFind® 4.1, the code includes some convenient tools to help with permission management.
  
 ==== Controllers ==== ==== Controllers ====
  
-Since VuFind 2.4, it has been possible to make a controller check a particular permission before dispatching any actions. A controller simply needs to set its $accessPermission property to the name of a permission from permissions.ini to enforce this simple check.+Since VuFind® 2.4, it has been possible to make a controller check a particular permission before dispatching any actions. A controller simply needs to set its $accessPermission property to the name of a permission from permissions.ini to enforce this simple check.
  
-VuFind 4.0 added the $accessDeniedBehavior property, which a controller can set to either 'promptLogin' or 'exception' to control how a blocked permission will be handled.+VuFind® 4.0 added the $accessDeniedBehavior property, which a controller can set to either 'promptLogin' or 'exception' to control how a blocked permission will be handled.
  
-VuFind 4.1 added even greater flexibility by adding permissionBehavior.ini (which overrides $accessDeniedBehavior for configured permissions, and defaults back to it for others) and by adding the permission controller plugin. The permission controller plugin makes it possible to check a permission and implement appropriate behavior at the action level, allowing greater granularity than the previous controller-level checking. Simply add code like this to the top of your action to implement the necessary check:+VuFind® 4.1 added even greater flexibility by adding permissionBehavior.ini (which overrides $accessDeniedBehavior for configured permissions, and defaults back to it for others) and by adding the permission controller plugin. The permission controller plugin makes it possible to check a permission and implement appropriate behavior at the action level, allowing greater granularity than the previous controller-level checking. Simply add code like this to the top of your action to implement the necessary check:
  
 <code> <code>
Line 48: Line 49:
 ==== Templates ==== ==== Templates ====
  
-It was not possible to check permissions in templates until VuFind 4.1, which introduced the permission view helper. This can be used in templates like this:+It was not possible to check permissions in templates until VuFind® 4.1, which introduced the permission view helper. This can be used in templates like this:
  
 <code> <code>
Line 114: Line 115:
 // The button to save a record as a favorite record should be always displayed, but if a user is not logged in, he should be forced to login. // // The button to save a record as a favorite record should be always displayed, but if a user is not logged in, he should be forced to login. //
  
-(This is the default behavior in VuFind now).+(This is the default behavior in VuFind® now).
  
 permissions.ini: permissions.ini:
Line 168: Line 169:
 permissionBehavior.ini: permissionBehavior.ini:
   [access.PrimoModule]    [access.PrimoModule] 
-  deniedControllerBehavior = "exception:Forbidden:You are not allowed to do this!" +  deniedControllerBehavior = "exception:VuFind\Exception\Forbidden:You are not allowed to do this!" 
 ---- struct data ---- ---- struct data ----
 +properties.Page Owner : 
 ---- ----
  
configuration/permission_options.1504108289.txt.gz · Last modified: 2017/08/30 15:51 by demiankatz