laratrust.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <?php
  2. return [
  3. /*
  4. |--------------------------------------------------------------------------
  5. | Use MorphMap in relationships between models
  6. |--------------------------------------------------------------------------
  7. |
  8. | If true, the morphMap feature is going to be used. The array values that
  9. | are going to be used are the ones inside the 'user_models' array.
  10. |
  11. */
  12. 'use_morph_map' => false,
  13. /*
  14. |--------------------------------------------------------------------------
  15. | Which permissions and role checker to use.
  16. |--------------------------------------------------------------------------
  17. |
  18. | Defines if you want to use the roles and permissions checker.
  19. | Available:
  20. | - default: Check for the roles and permissions using the method that Laratrust
  21. has always used.
  22. | - query: Check for the roles and permissions using direct queries to the database.
  23. | This method doesn't support cache yet.
  24. |
  25. */
  26. 'checker' => 'default',
  27. /*
  28. |--------------------------------------------------------------------------
  29. | Cache
  30. |--------------------------------------------------------------------------
  31. |
  32. | Manage Laratrust's cache configurations. It uses the driver defined in the
  33. | config/cache.php file.
  34. |
  35. */
  36. 'cache' => [
  37. /*
  38. |--------------------------------------------------------------------------
  39. | Use cache in the package
  40. |--------------------------------------------------------------------------
  41. |
  42. | Defines if Laratrust will use Laravel's Cache to cache the roles and permissions.
  43. | NOTE: Currently the database check does not use cache.
  44. |
  45. */
  46. 'enabled' => true,
  47. /*
  48. |--------------------------------------------------------------------------
  49. | Time to store in cache Laratrust's roles and permissions.
  50. |--------------------------------------------------------------------------
  51. |
  52. | Determines the time in SECONDS to store Laratrust's roles and permissions in the cache.
  53. |
  54. */
  55. 'expiration_time' => 3600,
  56. ],
  57. /*
  58. |--------------------------------------------------------------------------
  59. | Laratrust User Models
  60. |--------------------------------------------------------------------------
  61. |
  62. | This is the array that contains the information of the user models.
  63. | This information is used in the add-trait command, for the roles and
  64. | permissions relationships with the possible user models, and the
  65. | administration panel to attach roles and permissions to the users.
  66. |
  67. | The key in the array is the name of the relationship inside the roles and permissions.
  68. |
  69. */
  70. 'user_models' => [
  71. 'users' => 'App\User',
  72. ],
  73. /*
  74. |--------------------------------------------------------------------------
  75. | Laratrust Models
  76. |--------------------------------------------------------------------------
  77. |
  78. | These are the models used by Laratrust to define the roles, permissions and teams.
  79. | If you want the Laratrust models to be in a different namespace or
  80. | to have a different name, you can do it here.
  81. |
  82. */
  83. 'models' => [
  84. 'role' => 'App\Role',
  85. 'permission' => 'App\Permission',
  86. /**
  87. * Will be used only if the teams functionality is enabled.
  88. */
  89. 'team' => 'App\Team',
  90. ],
  91. /*
  92. |--------------------------------------------------------------------------
  93. | Laratrust Tables
  94. |--------------------------------------------------------------------------
  95. |
  96. | These are the tables used by Laratrust to store all the authorization data.
  97. |
  98. */
  99. 'tables' => [
  100. 'roles' => 'roles',
  101. 'permissions' => 'permissions',
  102. /**
  103. * Will be used only if the teams functionality is enabled.
  104. */
  105. 'teams' => 'teams',
  106. 'role_user' => 'role_user',
  107. 'permission_user' => 'permission_user',
  108. 'permission_role' => 'permission_role',
  109. ],
  110. /*
  111. |--------------------------------------------------------------------------
  112. | Laratrust Foreign Keys
  113. |--------------------------------------------------------------------------
  114. |
  115. | These are the foreign keys used by laratrust in the intermediate tables.
  116. |
  117. */
  118. 'foreign_keys' => [
  119. /**
  120. * User foreign key on Laratrust's role_user and permission_user tables.
  121. */
  122. 'user' => 'user_id',
  123. /**
  124. * Role foreign key on Laratrust's role_user and permission_role tables.
  125. */
  126. 'role' => 'role_id',
  127. /**
  128. * Role foreign key on Laratrust's permission_user and permission_role tables.
  129. */
  130. 'permission' => 'permission_id',
  131. /**
  132. * Role foreign key on Laratrust's role_user and permission_user tables.
  133. */
  134. 'team' => 'team_id',
  135. ],
  136. /*
  137. |--------------------------------------------------------------------------
  138. | Laratrust Middleware
  139. |--------------------------------------------------------------------------
  140. |
  141. | This configuration helps to customize the Laratrust middleware behavior.
  142. |
  143. */
  144. 'middleware' => [
  145. /**
  146. * Define if the laratrust middleware are registered automatically in the service provider
  147. */
  148. 'register' => true,
  149. /**
  150. * Method to be called in the middleware return case.
  151. * Available: abort|redirect
  152. */
  153. 'handling' => 'abort',
  154. /**
  155. * Handlers for the unauthorized method in the middlewares.
  156. * The name of the handler must be the same as the handling.
  157. */
  158. 'handlers' => [
  159. /**
  160. * Aborts the execution with a 403 code and allows you to provide the response text
  161. */
  162. 'abort' => [
  163. 'code' => 403,
  164. 'message' => 'User does not have any of the necessary access rights.'
  165. ],
  166. /**
  167. * Redirects the user to the given url.
  168. * If you want to flash a key to the session,
  169. * you can do it by setting the key and the content of the message
  170. * If the message content is empty it won't be added to the redirection.
  171. */
  172. 'redirect' => [
  173. 'url' => '/home',
  174. 'message' => [
  175. 'key' => 'error',
  176. 'content' => ''
  177. ]
  178. ]
  179. ]
  180. ],
  181. 'teams' => [
  182. /*
  183. |--------------------------------------------------------------------------
  184. | Use teams feature in the package
  185. |--------------------------------------------------------------------------
  186. |
  187. | Defines if Laratrust will use the teams feature.
  188. | Please check the docs to see what you need to do in case you have the package already configured.
  189. |
  190. */
  191. 'enabled' => false,
  192. /*
  193. |--------------------------------------------------------------------------
  194. | Strict check for roles/permissions inside teams
  195. |--------------------------------------------------------------------------
  196. |
  197. | Determines if a strict check should be done when checking if a role or permission
  198. | is attached inside a team.
  199. | If it's false, when checking a role/permission without specifying the team,
  200. | it will check only if the user has attached that role/permission ignoring the team.
  201. |
  202. */
  203. 'strict_check' => false,
  204. ],
  205. /*
  206. |--------------------------------------------------------------------------
  207. | Laratrust Magic 'isAbleTo' Method
  208. |--------------------------------------------------------------------------
  209. |
  210. | Supported cases for the magic is able to method (Refer to the docs).
  211. | Available: camel_case|snake_case|kebab_case
  212. |
  213. */
  214. 'magic_is_able_to_method_case' => 'kebab_case',
  215. /*
  216. |--------------------------------------------------------------------------
  217. | Laratrust Panel
  218. |--------------------------------------------------------------------------
  219. |
  220. | Section to manage everything related with the admin panel for the roles and permissions.
  221. |
  222. */
  223. 'panel' => [
  224. /*
  225. |--------------------------------------------------------------------------
  226. | Laratrust Panel Register
  227. |--------------------------------------------------------------------------
  228. |
  229. | This manages if routes used for the admin panel should be registered.
  230. | Turn this value to false if you don't want to use Laratrust admin panel
  231. |
  232. */
  233. 'register' => true,
  234. /*
  235. |--------------------------------------------------------------------------
  236. | Laratrust Panel Path
  237. |--------------------------------------------------------------------------
  238. |
  239. | This is the URI path where Laratrust panel for roles and permissions
  240. | will be accesible from.
  241. |
  242. */
  243. 'path' => '',
  244. /*
  245. |--------------------------------------------------------------------------
  246. | Laratrust Panel Path
  247. |--------------------------------------------------------------------------
  248. |
  249. | The route where the go back link should point
  250. |
  251. */
  252. 'go_back_route' => '/panel',
  253. /*
  254. |--------------------------------------------------------------------------
  255. | Laratrust Panel Route Middleware
  256. |--------------------------------------------------------------------------
  257. |
  258. | These middleware will get attached onto each Laratrust panel route.
  259. |
  260. */
  261. 'middleware' => ['web', 'auth'],
  262. /*
  263. |--------------------------------------------------------------------------
  264. | Enable permissions assignment
  265. |--------------------------------------------------------------------------
  266. |
  267. | Enable/Disable the permissions assignment to the users.
  268. |
  269. */
  270. 'assign_permisions_to_user' => true,
  271. ]
  272. ];