This plugin provides a GitLab integration for Social 2 for Craft CMS.
This plugin requires Social 2.0.0 or later.
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project -
Then tell Composer to load the plugin:
composer require skayocrafts/social-gitlab -
In the Control Panel, go to Settings → Plugins and click the “Install” button for GitLab.
To enable the GitLab login provider, go to Social → Settings → Login Providers, and configure the “GitLab” login provider.
If you have a self-hosted GitLab and want to use it instead of gitlab.com for OAuth,
then you can set the domain in config/social.php like this:
<?php
return [
'loginProviders' => [
// ... some other config ...
'gitlab' => [
// ... some other config ...
'oauth' => [
// ... some other config ...
'options' => [
// ... some other config ...
'domain' => 'https://gitlab.example.com'
]
],
]
]
];For more information about the social configuration, look here
The GitLab login provider defines the following user field mapping by default:
[
'id' => '{{ profile.getId() }}',
'email' => '{{ profile.getEmail() }}',
'username' => '{{ profile.getUsername() }}',
'photo' => '{{ profile.getAvatarUrl() }}',
]
You can override and extend the default mapping using the loginProviders config.
The profile response for the GitLab login provider is a GitlabResourceOwner object.
getId()getName()getUsername()getEmail()getAvatarUrl()getProfileUrl()getToken()isActive()isAdmin()isExternal()toArray()getDomain()setDomain()getApiClient()get()