From 44d8f39037dfc23520fd2b0698785b148dd8c512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Balu=CC=81n?= Date: Wed, 31 Jan 2018 16:02:07 +0100 Subject: [PATCH 1/3] add support for gitlab authentification --- .env.example | 6 +++++- app/Providers/EventServiceProvider.php | 1 + app/Services/SocialAuthService.php | 2 +- composer.json | 3 ++- config/services.php | 10 +++++++++- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index ddb32c0bc..279d0f5e9 100644 --- a/.env.example +++ b/.env.example @@ -50,6 +50,10 @@ OKTA_BASE_URL=false OKTA_KEY=false OKTA_SECRET=false +GITLAB_KEY=false +GITLAB_SECRET=false +GITLAB_INSTANCE_URI=false + # External services such as Gravatar DISABLE_EXTERNAL_SERVICES=false @@ -67,4 +71,4 @@ MAIL_HOST=localhost MAIL_PORT=1025 MAIL_USERNAME=null MAIL_PASSWORD=null -MAIL_ENCRYPTION=null \ No newline at end of file +MAIL_ENCRYPTION=null diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 05f9c57c1..dec7b98c6 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -18,6 +18,7 @@ class EventServiceProvider extends ServiceProvider 'SocialiteProviders\Slack\SlackExtendSocialite@handle', 'SocialiteProviders\Azure\AzureExtendSocialite@handle', 'SocialiteProviders\Okta\OktaExtendSocialite@handle', + 'SocialiteProviders\GitLab\GitLabExtendSocialite@handle', ], ]; diff --git a/app/Services/SocialAuthService.php b/app/Services/SocialAuthService.php index 30f7eed0e..c31e67d0d 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']; + protected $validSocialDrivers = ['google', 'github', 'facebook', 'slack', 'twitter', 'azure', 'okta', 'gitlab']; /** * SocialAuthService constructor. diff --git a/composer.json b/composer.json index 2750b7cb3..10b3592c8 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "barryvdh/laravel-snappy": "^0.4.0", "socialiteproviders/slack": "^3.0", "socialiteproviders/microsoft-azure": "^3.0", - "socialiteproviders/okta": "^1.0" + "socialiteproviders/okta": "^1.0", + "socialiteproviders/gitlab": "^3.0" }, "require-dev": { "filp/whoops": "~2.0", diff --git a/config/services.php b/config/services.php index 18649c093..17f54ab45 100644 --- a/config/services.php +++ b/config/services.php @@ -92,7 +92,15 @@ return [ 'redirect' => env('APP_URL') . '/login/service/okta/callback', 'base_url' => env('OKTA_BASE_URL'), 'name' => 'Okta', - ], + ], + + 'gitlab' => [ + 'client_id' => env('GITLAB_KEY'), + 'client_secret' => env('GITLAB_SECRET'), + 'redirect' => env('APP_URL') . '/login/service/gitlab/callback', + 'instance_uri' => env('GITLAB_INSTANCE_URI'), // needs only for GitLab self hosted + 'name' => 'Gitlab', + ], 'ldap' => [ 'server' => env('LDAP_SERVER', false), From 8b125be8f62e21993f08e0c9fd3fa743b6ef9b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Balu=CC=81n?= Date: Wed, 31 Jan 2018 16:08:39 +0100 Subject: [PATCH 2/3] add missing lock file --- composer.lock | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 9db080bab..f36355797 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "8ad5cb7acc1115a77404d1be899984ac", + "content-hash": "210685bb4ecd91f015682f5cf03ba84d", "packages": [ { "name": "aws/aws-sdk-php", @@ -2075,6 +2075,43 @@ ], "time": "2016-07-19T19:14:21+00:00" }, + { + "name": "socialiteproviders/gitlab", + "version": "v3.0.1", + "source": { + "type": "git", + "url": "https://github.com/SocialiteProviders/GitLab.git", + "reference": "c96dc004563a3caf157608fe9aa9e45c79065d00" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/SocialiteProviders/GitLab/zipball/c96dc004563a3caf157608fe9aa9e45c79065d00", + "reference": "c96dc004563a3caf157608fe9aa9e45c79065d00", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0", + "socialiteproviders/manager": "~3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "SocialiteProviders\\GitLab\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christoffer Martinsen", + "email": "christoffermartinsen@gmail.com" + } + ], + "description": "GitLab OAuth2 Provider for Laravel Socialite", + "time": "2017-01-31T05:06:13+00:00" + }, { "name": "socialiteproviders/manager", "version": "v3.3.0", From 194bb0f042c6b6d94c810520ffdafb86f90aa254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jozef=20Balu=CC=81n?= Date: Thu, 1 Feb 2018 18:26:19 +0100 Subject: [PATCH 3/3] add missing icon, fix name conventions --- .env.example | 6 +++--- config/services.php | 10 +++++----- resources/assets/icons/gitlab.svg | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 resources/assets/icons/gitlab.svg diff --git a/.env.example b/.env.example index 279d0f5e9..a5184a789 100644 --- a/.env.example +++ b/.env.example @@ -50,9 +50,9 @@ OKTA_BASE_URL=false OKTA_KEY=false OKTA_SECRET=false -GITLAB_KEY=false -GITLAB_SECRET=false -GITLAB_INSTANCE_URI=false +GITLAB_APP_ID=false +GITLAB_APP_SECRET=false +GITLAB_BASE_URI=false # External services such as Gravatar DISABLE_EXTERNAL_SERVICES=false diff --git a/config/services.php b/config/services.php index 17f54ab45..31d5a09cf 100644 --- a/config/services.php +++ b/config/services.php @@ -95,11 +95,11 @@ return [ ], 'gitlab' => [ - 'client_id' => env('GITLAB_KEY'), - 'client_secret' => env('GITLAB_SECRET'), - 'redirect' => env('APP_URL') . '/login/service/gitlab/callback', - 'instance_uri' => env('GITLAB_INSTANCE_URI'), // needs only for GitLab self hosted - 'name' => 'Gitlab', + 'client_id' => env('GITLAB_APP_ID'), + 'client_secret' => env('GITLAB_APP_SECRET'), + 'redirect' => env('APP_URL') . '/login/service/gitlab/callback', + 'instance_uri' => env('GITLAB_BASE_URI'), // needs only for GitLab self hosted + 'name' => 'Gitlab', ], 'ldap' => [ diff --git a/resources/assets/icons/gitlab.svg b/resources/assets/icons/gitlab.svg new file mode 100644 index 000000000..fa1e92a56 --- /dev/null +++ b/resources/assets/icons/gitlab.svg @@ -0,0 +1 @@ +