From 93795b6eda17bec0e39d93841af13a102f588ea7 Mon Sep 17 00:00:00 2001 From: Timo B Date: Thu, 28 Jun 2018 09:01:36 +0200 Subject: [PATCH] add everything needed to use discord as social login provider --- .env.example | 2 + app/Providers/EventServiceProvider.php | 1 + app/Services/SocialAuthService.php | 2 +- composer.json | 3 +- composer.lock | 51 +++++++++++++++++++++---- config/services.php | 6 +++ resources/assets/icons/auth/discord.svg | 1 + 7 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 resources/assets/icons/auth/discord.svg diff --git a/.env.example b/.env.example index ccafaf4fb..68d268635 100644 --- a/.env.example +++ b/.env.example @@ -56,6 +56,8 @@ TWITCH_APP_SECRET=false GITLAB_APP_ID=false GITLAB_APP_SECRET=false GITLAB_BASE_URI=false +DISCORD_APP_ID=false +DISCORD_APP_SECRET=false # External services such as Gravatar and Draw.IO DISABLE_EXTERNAL_SERVICES=false diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index cc3e4d993..00eeb036c 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -20,6 +20,7 @@ class EventServiceProvider extends ServiceProvider 'SocialiteProviders\Okta\OktaExtendSocialite@handle', 'SocialiteProviders\GitLab\GitLabExtendSocialite@handle', 'SocialiteProviders\Twitch\TwitchExtendSocialite@handle', + 'SocialiteProviders\Discord\DiscordExtendSocialite@handle', ], ]; diff --git a/app/Services/SocialAuthService.php b/app/Services/SocialAuthService.php index 02361e59b..dac6b7773 100644 --- a/app/Services/SocialAuthService.php +++ b/app/Services/SocialAuthService.php @@ -16,7 +16,7 @@ class SocialAuthService protected $socialite; protected $socialAccount; - protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter', 'azure', 'okta', 'gitlab', 'twitch']; + protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter', 'azure', 'okta', 'gitlab', 'twitch', 'discord']; /** * SocialAuthService constructor. diff --git a/composer.json b/composer.json index 3de0cb5f7..757b0982c 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,8 @@ "socialiteproviders/microsoft-azure": "^3.0", "socialiteproviders/okta": "^1.0", "socialiteproviders/gitlab": "^3.0", - "socialiteproviders/twitch": "^3.0" + "socialiteproviders/twitch": "^3.0", + "socialiteproviders/discord": "^2.0" }, "require-dev": { "filp/whoops": "~2.0", diff --git a/composer.lock b/composer.lock index 6e0a35323..a06cbbef9 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3bf33ab103b15b06ca06c85fd8ae3b78", + "content-hash": "b9ea2a42e2f7780b3a54d4b7327750e0", "packages": [ { "name": "aws/aws-sdk-php", @@ -1665,16 +1665,16 @@ }, { "name": "phenx/php-svg-lib", - "version": "v0.3", + "version": "v0.3.0", "source": { "type": "git", "url": "https://github.com/PhenX/php-svg-lib.git", - "reference": "a85f7fe9fe08d093a4a8583cdd306b553ff918aa" + "reference": "8f543ede60386faec9b0012833536de4b6083bb9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PhenX/php-svg-lib/zipball/a85f7fe9fe08d093a4a8583cdd306b553ff918aa", - "reference": "a85f7fe9fe08d093a4a8583cdd306b553ff918aa", + "url": "https://api.github.com/repos/PhenX/php-svg-lib/zipball/8f543ede60386faec9b0012833536de4b6083bb9", + "reference": "8f543ede60386faec9b0012833536de4b6083bb9", "shasum": "" }, "require": { @@ -1701,7 +1701,7 @@ ], "description": "A library to read, parse and export to PDF SVG files.", "homepage": "https://github.com/PhenX/php-svg-lib", - "time": "2017-05-24T10:07:27+00:00" + "time": "2018-04-14T14:36:18+00:00" }, { "name": "predis/predis", @@ -2071,6 +2071,43 @@ ], "time": "2016-07-19T19:14:21+00:00" }, + { + "name": "socialiteproviders/discord", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/SocialiteProviders/Discord.git", + "reference": "f934ca3f4fa5ea915c1d20852b826e860aa64727" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/SocialiteProviders/Discord/zipball/f934ca3f4fa5ea915c1d20852b826e860aa64727", + "reference": "f934ca3f4fa5ea915c1d20852b826e860aa64727", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0", + "socialiteproviders/manager": "~2.0 || ~3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "SocialiteProviders\\Discord\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christopher Eklund", + "email": "eklundchristopher@gmail.com" + } + ], + "description": "Discord OAuth2 Provider for Laravel Socialite", + "time": "2017-08-28T02:20:40+00:00" + }, { "name": "socialiteproviders/gitlab", "version": "v3.0.2", diff --git a/config/services.php b/config/services.php index 825b1f109..05ec09ec0 100644 --- a/config/services.php +++ b/config/services.php @@ -108,6 +108,12 @@ return [ 'redirect' => env('APP_URL') . '/login/service/twitch/callback', 'name' => 'Twitch', ], + 'discord' => [ + 'client_id' => env('DISCORD_APP_ID'), + 'client_secret' => env('DISCORD_APP_SECRET'), + 'redirect' => env('APP_URL') . '/login/service/discord/callback', + 'name' => 'Discord', + ], 'ldap' => [ 'server' => env('LDAP_SERVER', false), diff --git a/resources/assets/icons/auth/discord.svg b/resources/assets/icons/auth/discord.svg new file mode 100644 index 000000000..65c9fccff --- /dev/null +++ b/resources/assets/icons/auth/discord.svg @@ -0,0 +1 @@ + \ No newline at end of file