Make the Gitlab SSO Support compatible with Github Enterprise
See doc/integrations/Single-Sign-On/Github.md for the usage. Note: I thought it should work also with Github.com but it failed with "Bad token type" error.
Этот коммит содержится в:
18
doc/integrations/Single-Sign-On/Github.md
Обычный файл
18
doc/integrations/Single-Sign-On/Github.md
Обычный файл
@@ -0,0 +1,18 @@
|
|||||||
|
## Configuring GitHub Enterprise Single-Sign-On
|
||||||
|
|
||||||
|
Follow these steps to configure Mattermost to use GitHub Enterprise as a single-sign-on (SSO) service for team creation, account creation and sign-in.
|
||||||
|
|
||||||
|
1. Login to your GitHub Enterprise account and go to the Applications section in Profile Settings.
|
||||||
|
2. Add a new application called "Mattermost" with the following as Authorization callback URL:
|
||||||
|
* `<your-mattermost-url>` (example: http://localhost:8065)
|
||||||
|
|
||||||
|
3. Submit the application and copy the given _Id_ and _Secret_ into the appropriate _GitLabSettings_ fields in config/config.json
|
||||||
|
|
||||||
|
4. Also in config/config.json, set _Enable_ to `true` for the _gitlab_ section, leave _Scope_ blank and use the following for the endpoints:
|
||||||
|
* _AuthEndpoint_: `https://<your-github-enterprise-url>/oauth/authorize` (example https://github.com/oauth/authorize)
|
||||||
|
* _TokenEndpoint_: `https://<your-github-enterprise-url>/oauth/access_token`
|
||||||
|
* _UserApiEndpoint_: `https://<your-github-enterprise-url>/api/v3/user`
|
||||||
|
|
||||||
|
5. (Optional) If you would like to force all users to sign-up with GitHub Enterprise only, in the _ServiceSettings_ section of config/config.json set _DisableEmailSignUp_ to `true`.
|
||||||
|
|
||||||
|
6. Restart your Mattermost server to see the changes take effect.
|
||||||
@@ -17,13 +17,18 @@ const (
|
|||||||
type GitLabUser struct {
|
type GitLabUser struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
|
Login string `json:"login"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserFromGitLabUser(glu *GitLabUser) *User {
|
func UserFromGitLabUser(glu *GitLabUser) *User {
|
||||||
user := &User{}
|
user := &User{}
|
||||||
user.Username = CleanUsername(glu.Username)
|
username := glu.Username
|
||||||
|
if username == "" {
|
||||||
|
username = glu.Login
|
||||||
|
}
|
||||||
|
user.Username = CleanUsername(username)
|
||||||
splitName := strings.Split(glu.Name, " ")
|
splitName := strings.Split(glu.Name, " ")
|
||||||
if len(splitName) == 2 {
|
if len(splitName) == 2 {
|
||||||
user.FirstName = splitName[0]
|
user.FirstName = splitName[0]
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user