jitesoft/socialite-hub

Jetbrains Hub OAuth2 提供商,用于 Laravel Socialite。

1.0.1 2017-09-08 20:11 UTC

This package is not auto-updated.

Last update: 2024-09-15 02:43:20 UTC


README

require jitesoft/socialite-hub

需要 socialite 并将 SocialiteServiceProviderManager\ServiceProvider 添加到 app.php 文件中的 providers 数组

'providers' => [
    Laravel\Socialite\SocialiteServiceProvider::class,
    SocialiteProviders\Manager\ServiceProvider::class,
]

如果需要,您可以将 Socialite 门面添加到别名类(我更喜欢并推荐这样做)

'aliases' => [
    'Socialite' => Laravel\Socialite\Facades\Socialite::class
]

将提供者添加到 'services' 配置数组

return [
    'jetbrains-hub' => [
        'client_id'     => env('JB_HUB_CLIENT_ID', ''),
        'client_secret' => env('JB_HUB_CLIENT_SECRET', ''),
        'base_url'      => env('JB_HUB_URL', 'https://hub.yourpage.tld'),
        'redirect'      => env('APP_URL', 'https://') . "/your/callback"
    ],
];

将 socialite 扩展添加到事件提供者

protected $listen = [
    SocialiteWasCalled::class => [
        JetbrainsHubExtendSocialite::class . "@handle"
    ]
];

添加您的回调路由

$router->get('/your/redirect', function() {        
    // Redirect!
    return Socialite::driver('jetbrains-hub')->redirect();
});

$router->get('/your/callback', function() {
    $user = Socialite::driver('jetbrains-hub')->user();
    // Yay you got your user (I hope!)    
});

创建一个登录表单并将按钮重定向到 your/redirect 终端。

许可证

MIT License
  
  Copyright (c) 2017 JiteSoft
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.