<commit_before># TinyAuth Autorization

Enable TinyAuth Authorize if you want to add instant (and easy) role based
access to your application.

## Enabling

Assuming you already have Authentiction set up correctly you can enable
Authorization in your controllers beforeFilter like this example:

```php
// src/Controller/AppController

use Cake\Event\Event;

public function beforeFilter(Event $event)
{
	parent::beforeFilter($event);
	$this->loadComponent('Auth', [
		'authorize' => [
			'TinyAuth.Tiny' => [
				'autoClearCache' => true,
				'allowUser' => false,
				'allowAdmin' => false,
				'adminRole' => 'admin',
				'superAdminRole' => null
			]
		]
	]);
}
```

## Roles

You need to define some roles for Authorize to work, for example:

```php
// config/app_custom.php


/**
* Optionally define constants for easy referencing throughout your code
*/
define('ROLE_USERS', 1);
define('ROLE_ADMINS', 2);
define('ROLE_SUPERADMINS', 9);

return [
	'Roles' => [
		'user' => ROLE_USERS,
		'admin' => ROLE_ADMINS,
		'superadmin' => ROLE_SUPERADMIN
	]
];
```

## acl.ini

Authorize expects an ``acl.ini`` file in your config directory.
Use it to specify who gets access to which resources.

The section key syntax follows the CakePHP naming convention for plugins.

Make sure to create an entry for each action you want to expose and use:

- one or more role names (groups granted access)
- the ``*`` wildcard to allow access to all authenticated users

```ini
; ----------------------------------------------------------
; Userscontroller
; ----------------------------------------------------------
[Users]<commit_msg>Correctes superadmin constant<commit_after># TinyAuth Autorization

Enable TinyAuth Authorize if you want to add instant (and easy) role based
access to your application.

## Enabling

Assuming you already have Authentiction set up correctly you can enable
Authorization in your controllers beforeFilter like this example:

```php
// src/Controller/AppController

use Cake\Event\Event;

public function beforeFilter(Event $event)
{
	parent::beforeFilter($event);
	$this->loadComponent('Auth', [
		'authorize' => [
			'TinyAuth.Tiny' => [
				'autoClearCache' => true,
				'allowUser' => false,
				'allowAdmin' => false,
				'adminRole' => 'admin',
				'superAdminRole' => null
			]
		]
	]);
}
```

## Roles

You need to define some roles for Authorize to work, for example:

```php
// config/app_custom.php


/**
* Optionally define constants for easy referencing throughout your code
*/
define('ROLE_USERS', 1);
define('ROLE_ADMINS', 2);
define('ROLE_SUPERADMIN', 9);

return [
	'Roles' => [
		'user' => ROLE_USERS,
		'admin' => ROLE_ADMINS,
		'superadmin' => ROLE_SUPERADMIN
	]
];
```

## acl.ini

Authorize expects an ``acl.ini`` file in your config directory.
Use it to specify who gets access to which resources.

The section key syntax follows the CakePHP naming convention for plugins.

Make sure to create an entry for each action you want to expose and use:

- one or more role names (groups granted access)
- the ``*`` wildcard to allow access to all authenticated users

```ini
; ----------------------------------------------------------
; Userscontroller
; ----------------------------------------------------------
[Users]
{'fraction_non_alphanumeric': 0.17796870205584536, 'fraction_numerical': 0.001841055538508745, 'mean_word_length': 3.029666254635352, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1952732', 'n_tokens_mistral': 1022, 'n_tokens_neox': 940, 'n_words': 333}