README.md 5.44 KB
Newer Older
Marcello Pivanti's avatar
Marcello Pivanti committed
1
2
3
4
5
6
7
8
9
10
11
12
13
Amos Social Auth
-----------------------

Social Auth For Amos

Installation
------------

1. The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
    
    Either run
    
    ```bash
waltermazza's avatar
waltermazza committed
14
    composer require arter/amos-social-auth
Marcello Pivanti's avatar
Marcello Pivanti committed
15
16
17
18
19
    ```
    
    or add
    
    ```
waltermazza's avatar
waltermazza committed
20
    "arter/amos-social-auth": "~1.0"
Marcello Pivanti's avatar
Marcello Pivanti committed
21
22
23
24
25
26
27
28
29
30
    ```
    
    to the require section of your `composer.json` file.
    
2.  Add module to your main config in common:
        
    ```php
    <?php
    'modules' => [
        'socialauth' => [
waltermazza's avatar
waltermazza committed
31
            'class' => 'arter\amos\socialauth\Module'
Marcello Pivanti's avatar
Marcello Pivanti committed
32
33
34
35
36
37
38
        ],
    ],
    ```
    
3. Apply migrations
    
    ```bash
waltermazza's avatar
waltermazza committed
39
    php yii migrate/up --migrationPath=@vendor/arter/amos-social-auth/src/migrations
Marcello Pivanti's avatar
Marcello Pivanti committed
40
41
42
43
44
45
46
47
48
49
50
51
    ```



Configuration
-------------

* Sample configuration
    ```php
    <?php
        'modules' => [
            'socialauth' => [
waltermazza's avatar
waltermazza committed
52
                'class' => 'arter\amos\socialauth\Module',
Marcello Pivanti's avatar
Marcello Pivanti committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
                'enableLogin' => true,
                'enableLink' => false,
                'enableRegister' => false,
                'providers' => [
                   "Facebook" => [
                        "enabled" => true,
                        "keys" => [
                            "id" => "",
                            "secret" => ""
                        ],
                        "scope" => "email"
                    ],
                    "Twitter" => [
                        "enabled" => true,
                        "keys" => [
                            "key" => "",
                            "secret" => ""
                        ],
                        "scope" => 'email',
                        "includeEmail" => true
                    ],
                    "Google" => [
                        "enabled" => true,
                        "keys" => [
                            "id" => "",
                            "secret" => ""
                        ],
                        "scope" => 'email',
                        "includeEmail" => true
                    ],
                ]
            ],
        ],
    ```
    see configuration doc: https://hybridauth.github.io/hybridauth/userguide/Configuration.html

* Action enable/disable

    * `enableLogin` To alow Social Login
    * `enableLink` To Enable Social Account Linking (my-profile 'settings' tab)
    * `enableRegister` To Enable Registration with Social
    * `enableServices` To list enabled services related to social accounts. By default the array contains `calendar` and `contacts`  

The provider linking functionality is managed in 'My Profile', amos-admin.
To enable social links check in admin configuraion the visibility for box social-accounts and for the the providers buttons.

```php
$modules['admin'] =  [
waltermazza's avatar
waltermazza committed
101
    'class' => 'arter\amos\admin\AmosAdmin',
Marcello Pivanti's avatar
Marcello Pivanti committed
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
	'enableRegister' => true,
         'fieldsConfigurations' => [
                'boxes' => [
                    .
                    .
                    .
                    'box_social_account' => ['form' => true, 'view' => true],
                ],
                'fields' => [
                    .
                    .
                    .   
                    'facebook' => ['form' => true, 'view' => true, 'referToBox' => 'box_social_account'],
                    'google' => ['form' => true, 'view' => true, 'referToBox' => 'box_social_account'],
                    'linkedin' => ['form' => true, 'view' => true, 'referToBox' => 'box_social_account'],
                    'twitter' => ['form' => true, 'view' => true, 'referToBox' => 'box_social_account'],
                    .
                    .
                    .
                ]
            ]
        ];
```

Providers
------------

Providers configuration doc: https://hybridauth.github.io/hybridauth/userguide.html section 'Popular Providers'
    
* Google  
    (guide from https://hybridauth.github.io/hybridauth/userguide/IDProvider_info_Google.html)
    1. Go to the Google Developers Console
        https://console.developers.google.com/projectselector/apis/library?supportedpurview=project.  
    2. From the project drop-down, select a project, or create a new one.  
    3. Enable the Google API services:
        In the list of Google APIs, search for the Google+ API service.
        Select Google+ API from the results list.
        Press the Enable API button.
        The same for People API and Calendar API
         * Enable API in Google console  
            **for account and contacts:**  People API, Google+ API  
            **for calendar events:** Google Calendar API
    4. When the process completes, enabled APIs appears in the list of enabled APIs. To access, select API Manager on the left sidebar menu, then select the Enabled APIs tab.  
    5. In the sidebar under "API Manager", select Credentials.
       In the Credentials tab, select the New credentials drop-down list, and choose **OAuth client ID**.  
    6. From the Application type list, choose the Web application.  
    7. Enter a name and provide this URLs as Authorized redirect URIs:
     http://YourPlatformUrl/socialauth/social-auth/endpoint?action=done&provider=google  
     http://YourPlatformUrl/admin/user-profile/enable-google-service
     https://YourPlatformUrl/socialauth/social-auth/endpoint?action=done&provider=google  
     https://YourPlatformUrl/admin/user-profile/enable-google-service
     
     8. Once you have registered, copy and past the created application credentials (Client ID and Secret) into the HybridAuth config file.