open20/amos-social-auth

该包的最新版本(1.12.2)没有提供许可信息。

社交认证


README

Amos 社交认证

安装

  1. 通过 composer 安装此扩展是首选方式。

    运行以下命令之一

    composer require open20/amos-social-auth

    或者

    "open20/amos-social-auth": "~1.0"
    

    将以下内容添加到您的 composer.json 文件的 require 部分中。

  2. 将模块添加到主配置文件 common 中

    <?php
    'modules' => [
        'socialauth' => [
            'class' => 'open20\amos\socialauth\Module'
        ],
    ],
  3. 应用迁移

    php yii migrate/up --migrationPath=@vendor/open20/amos-social-auth/src/migrations

配置

  • 示例配置

    <?php
        'modules' => [
            'socialauth' => [
                'class' => 'open20\amos\socialauth\Module',
                '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
                    ],
                ]
            ],
        ],

    查看配置文档: https://hybridauth.github.io/hybridauth/userguide/Configuration.html

  • 启用/禁用操作

    • enableLogin 允许社交登录
    • enableLink 启用社交账户链接(我的资料 '设置' 标签页)
    • enableRegister 启用通过社交账户注册
    • enableServices 列出与社交账户相关的已启用服务。默认数组包含 calendarcontacts

提供者链接功能在 '我的资料',amos-admin 中管理。要启用社交链接,请在管理员配置中检查社交账户框的可见性和提供者按钮。

$modules['admin'] =  [
    'class' => 'open20\amos\admin\AmosAdmin',
	'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'],
                    .
                    .
                    .
                ]
            ]
        ];

提供者

提供者配置文档: https://hybridauth.github.io/hybridauth/userguide.html 部分 '流行提供者'