tollbridge/laravel-socialite 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tollbridge/laravel-socialite

Composer 安装命令:

composer require tollbridge/laravel-socialite

包简介

Tollbridge.co service provider for Laravel Socialite authentication.

README 文档

README

Tollbridge is a user-authentication, subscription and paywall software as a service. This package will help you to implement Tollbridge's based authentication in your Laravel application in just a few minutes.

Installation

Install via composer

composer require tollbridge/laravel-socialite

Configuration

To access your Tollbridge credentials, visit the Integrations section in the Tollbridge admin. Add the provided credentials on the Tollbridge platform to your .env file:

TOLLBRIDGE_APP_ID=
TOLLBRIDGE_CLIENT_ID=
TOLLBRIDGE_CLIENT_SECRET=

Callback URL

In the Tollbridge Integrations section, you will need to set the Callback URL to match the correct path in your application. By default this URL will be your full protocol/hostname along with the path /tollbridge/callback. Note that this callback path is fully configurable within the tollbridge config file.

url(config('tollbridge.routing.callback')) e.g. https://www.example.test/tollbridge/callback

Tollbridge Configuration File

You can publish the configuration file to the local project directory using artisan:

php artisan vendor:publish --tag=tollbridge-config

This is the content of the config file:

<?php

return [
    'app_id' => env('TOLLBRIDGE_APP_ID'),
    'client_id' => env('TOLLBRIDGE_CLIENT_ID'),
    'client_secret' => env('TOLLBRIDGE_CLIENT_SECRET'),
    'routing' => [
        'login' => '/tollbridge/login',
        'logout' => '/tollbridge/logout',
        'callback' => '/tollbridge/callback',
    ],
];

Usage

After install, just add the authentication routes to /routes/web.php

Route::get(config('tollbridge.routing.login'), function () {
    //session()->set('url.intended', request()->input('url'));
    //..
    return Socialite::driver('tollbridge')->redirect();
});

Route::get(config('tollbridge.routing.logout'), function () {
    //session()->flush();
    //..
    return redirect()->intended();
});

Route::get(config('tollbridge.routing.callback'), function () {
    $user = Socialite::driver('tollbridge')->user();
    //session()->put('user', $user);
    //$user = Socialite::driver('tollbridge')->userFromToken($user->token);
    //$user->getName();
    //$user->getEmail();
    //$user->getPlan();
    //..
    return redirect()->intended();
});

To start the authentication process, add a link to the login URL:

<a href="{{ url(config('tollbridge.routing.login')) }}">Login</a>

Included Middleware

The Tollbridge\Socialite\Middleware\TollbridgeRedirects middleware is automatically loaded.

If the param _tollbridge_logout is set the user will get redirected to config('tollbridge.routing.logout')

If the param _tollbridge_reauth is set the user will get redirected to config('tollbridge.routing.login'). This will in turn re-initiate an OAuth session.

Local Development

First link up your local repository:

composer config repositories.local '{"type": "path", "url": "../tollbridge-laravel-socialite"}' --file composer.json

Then install as normal via composer:

composer require tollbridge/laravel-socialite

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固