Skip to content

Commit

Permalink
Mention config/users.php instead of Configure::write
Browse files Browse the repository at this point in the history
  • Loading branch information
rochamarcelo committed Oct 28, 2021
1 parent c0e4a55 commit c44869e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
36 changes: 20 additions & 16 deletions Docs/Documentation/Authorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,25 @@ projects. We tried to allow you to start quickly without the need to configure a
allow you to configure as much as possible.


If you don't want the plugin to autoload setup authorization, you can do:
```
Configure::write('Auth.Authorization.enabled', false);
If you don't want the plugin to autoload setup authorization, you can disable
in your config/users.php with:

```php
'Auth.Authorization.enabled' => false,
```

Authorization Middleware
------------------------
We load the RequestAuthorization and Authorization middleware with OrmResolver and RbacProvider(work with RequestAuthorizationMiddleware).

The middleware accepts some additional configurations, you can do:
```
Configure::write('Auth.AuthorizationMiddleware', $config);
The middleware accepts some additional configurations, you can update in your
config/users.php file:
```php
'Auth.AuthorizationMiddleware' => $config,
```

The default configuration for authorization middleware is:
```
```php
[
'unauthorizedHandler' => [
'className' => 'CakeDC/Users.DefaultRedirect',
Expand All @@ -41,7 +44,7 @@ The `CakeDC/Users.DefaultRedirect` offers additional behavior and config:

You could do the following to set a custom url and flash message:

```
```php
[
'unauthorizedHandler' => [
'className' => 'CakeDC/Users.DefaultRedirect',
Expand All @@ -61,7 +64,7 @@ You could do the following to set a custom url and flash message:
],
```
OR
```
```php
[
'unauthorizedHandler' => [
'className' => 'CakeDC/Users.DefaultRedirect',
Expand All @@ -82,9 +85,10 @@ OR
Authorization Component
-----------------------
We autoload the authorization component at users controller using the default configuration,
if you don't want the plugin to autoload it, you can do:
```
Configure::write('Auth.AuthorizationComponent.enabled', false);
if you don't want the plugin to autoload it, you can add this to your config/users.php file:

```php
'Auth.AuthorizationComponent.enabled' => false,
```

You can check the configuration options available for authorization component at the
Expand All @@ -100,7 +104,7 @@ default provided.

- Create file src/Loader/AppAuthorizationServiceLoader.php

```
```php
<?php
namespace App\Loader;

Expand All @@ -127,8 +131,8 @@ class AppAuthorizationServiceLoader
}
}
```
- Change the authorization service loader:
- Add this to your config/users.php file to change the authorization service loader:

```
Configure::write('Auth.Authorization.serviceLoader', \App\Loader\AppAuthorizationServiceLoader::class);
```php
'Auth.Authorization.serviceLoader' => \App\Loader\AppAuthorizationServiceLoader::class,
```
6 changes: 3 additions & 3 deletions Docs/Documentation/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ If you want to use Google Authenticator features...
composer require robthree/twofactorauth:"^1.5.2"
```

NOTE: you'll need to enable `OneTimePasswordAuthenticator.login`
NOTE: you'll need to enable `OneTimePasswordAuthenticator.login` in your config/users.php file:

```
Configure::write('OneTimePasswordAuthenticator.login', true);
```php
'OneTimePasswordAuthenticator.login' => true,
```

Load the Plugin
Expand Down
25 changes: 11 additions & 14 deletions Docs/Documentation/SocialAuthentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,20 @@ Facebook/Twitter applications you want to use and update your file config/users.
Check optional configs at [config/users.php](./../../config/users.php) inside 'OAuth' key


You can also change the default settings for social authenticate:
You can also change the default settings for social authenticate in your config/users.php file:

```php
Configure::write('Users', [
'Email' => [
'Users.Email' => [
//determines if the user should include email
'required' => true,
//determines if registration workflow includes email validation
'validate' => true,
],
'Social' => [
'Users.Social' => [
//enable social login
'login' => false,
],
'Key' => [
'Users.Key' => [
'Session' => [
//session key to store the social auth data
'social' => 'Users.social',
Expand All @@ -60,7 +59,6 @@ Configure::write('Users', [
'socialEmail' => 'info.email',
],
],
]);
```

If email is required and the social network does not return the user email then the user will be required to input the email. Additionally, validation could be enabled, in that case the user will be asked to validate the email before be able to login. There are some cases where the email address already exists onto database, if so, the user will receive an email and will be asked to validate the social account in the app. It is important to take into account that the user account itself will remain active and accessible by other ways (other social network account or username/password).
Expand All @@ -70,7 +68,7 @@ In most situations you would not need to change any Oauth setting besides applic
For new facebook aps you must use the graphApiVersion 2.8 or greater:

```php
Configure::write('OAuth.providers.facebook.options.graphApiVersion', 'v2.8');
'OAuth.providers.facebook.options.graphApiVersion' => 'v2.8',
```

User Helper
Expand Down Expand Up @@ -126,12 +124,11 @@ Social Indentifier
------------------
The social identifier "CakeDC/Users.Social", works with data provider by both social authenticator,
it is responsible of finding or creating a user registry for the social user data request.
By default it'll fetch user data with finder 'all', but you can use a custom one. Add this to your
Application class, after CakeDC/Users Plugin is loaded.
By default, it'll fetch user data with finder 'all', but you can use a custom one. Add this to your
config/users.php:

```php
$identifiers = Configure::read('Auth.Identifiers');
$identifiers['CakeDC/Users.Social']['authFinder'] = 'customSocialAuth';
Configure::write('Auth.Identifiers', $identifiers);
'Auth.Identifiers.Social.authFinder' => 'customSocialAuth',
```


Expand All @@ -142,9 +139,9 @@ service to redirects user to an internal page or show an authentication error. I
There are two custom messages (Auth.SocialLoginFailure.messages) and one default message (Auth.SocialLoginFailure.defaultMessage).


To use a custom component to handle the login, do:
To use a custom component to handle the login add this to your config/users.php file:
```php
Configure::write('Auth.SocialLoginFailure.component', 'MyLoginA');
'Auth.SocialLoginFailure.component' => 'MyLoginA',
```

The default configuration is:
Expand Down

0 comments on commit c44869e

Please sign in to comment.