Better enterprise integration
This commit is contained in:
parent
94a1a16f5f
commit
a8d3d98881
7 changed files with 98 additions and 2 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -34,6 +34,10 @@ coverage
|
|||
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Enterprise files
|
||||
server/main/imports.go
|
||||
server/enterprise
|
||||
|
||||
# Dependency directory
|
||||
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
|
||||
node_modules
|
||||
|
|
29
Makefile
29
Makefile
|
@ -11,6 +11,35 @@ ifeq ($(BUILD_NUMBER),)
|
|||
BUILD_NUMBER := dev
|
||||
endif
|
||||
|
||||
BUILD_ENTERPRISE_DIR ?= ../focalboard-enterprise
|
||||
BUILD_ENTERPRISE ?= true
|
||||
BUILD_ENTERPRISE_READY = false
|
||||
BUILD_TYPE_NAME = team
|
||||
BUILD_HASH_ENTERPRISE = none
|
||||
ifneq ($(wildcard $(BUILD_ENTERPRISE_DIR)/.),)
|
||||
ifeq ($(BUILD_ENTERPRISE),true)
|
||||
BUILD_ENTERPRISE_READY = true
|
||||
BUILD_TYPE_NAME = enterprise
|
||||
BUILD_HASH_ENTERPRISE = $(shell cd $(BUILD_ENTERPRISE_DIR) && git rev-parse HEAD)
|
||||
else
|
||||
BUILD_ENTERPRISE_READY = false
|
||||
BUILD_TYPE_NAME = team
|
||||
endif
|
||||
else
|
||||
BUILD_ENTERPRISE_READY = false
|
||||
BUILD_TYPE_NAME = team
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_ENTERPRISE_READY),true)
|
||||
IGNORE:=$(shell echo Enterprise build selected, preparing)
|
||||
IGNORE:=$(shell rm -f server/main/imports.go)
|
||||
IGNORE:=$(shell cp $(BUILD_ENTERPRISE_DIR)/imports/imports.go server/main/)
|
||||
IGNORE:=$(shell rm -f server/enterprise)
|
||||
IGNORE:=$(shell ln -s ../$(BUILD_ENTERPRISE_DIR) server/enterprise)
|
||||
else
|
||||
IGNORE:=$(shell rm -f server/main/imports.go)
|
||||
endif
|
||||
|
||||
LDFLAGS += -X "github.com/mattermost/focalboard/server/model.BuildNumber=$(BUILD_NUMBER)"
|
||||
LDFLAGS += -X "github.com/mattermost/focalboard/server/model.BuildDate=$(BUILD_DATE)"
|
||||
LDFLAGS += -X "github.com/mattermost/focalboard/server/model.BuildHash=$(BUILD_HASH)"
|
||||
|
|
|
@ -15,5 +15,9 @@
|
|||
"session_refresh_time": 18000,
|
||||
"localOnly": false,
|
||||
"enableLocalMode": true,
|
||||
"localModeSocketLocation": "/var/tmp/focalboard_local.socket"
|
||||
"localModeSocketLocation": "/var/tmp/focalboard_local.socket",
|
||||
"authMode": "native",
|
||||
"mattermostURL": "",
|
||||
"mattermostClientID": "",
|
||||
"mattermostClientSecret": ""
|
||||
}
|
||||
|
|
25
server/einterfaces/einterfaces.go
Normal file
25
server/einterfaces/einterfaces.go
Normal file
|
@ -0,0 +1,25 @@
|
|||
package einterfaces
|
||||
|
||||
import (
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mattermost/focalboard/server/model"
|
||||
)
|
||||
|
||||
type MattermostAuth interface {
|
||||
RegisterRoutes(*mux.Router)
|
||||
DoesUserHaveWorkspaceAccess(session *model.Session, workspaceID string) bool
|
||||
}
|
||||
|
||||
type MattermostAuthParameters struct {
|
||||
ServerRoot string
|
||||
MattermostURL string
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
UseSecureCookie bool
|
||||
}
|
||||
|
||||
type MattermostAuthStore interface {
|
||||
GetUserById(userID string) (*model.User, error)
|
||||
CreateUser(user *model.User) error
|
||||
CreateSession(session *model.Session) error
|
||||
}
|
|
@ -30,6 +30,7 @@ require (
|
|||
github.com/tidwall/gjson v1.7.3 // indirect
|
||||
go.uber.org/zap v1.16.0
|
||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
||||
golang.org/x/sys v0.0.0-20210324051608-47abb6519492 // indirect
|
||||
google.golang.org/grpc v1.35.0
|
||||
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect
|
||||
|
|
11
server/server/enterprise.go
Normal file
11
server/server/enterprise.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"github.com/mattermost/focalboard/server/einterfaces"
|
||||
)
|
||||
|
||||
var mattermostAuth func(einterfaces.MattermostAuthParameters, einterfaces.MattermostAuthStore) einterfaces.MattermostAuth
|
||||
|
||||
func RegisterMattermostAuth(f func(einterfaces.MattermostAuthParameters, einterfaces.MattermostAuthStore) einterfaces.MattermostAuth) {
|
||||
mattermostAuth = f
|
||||
}
|
|
@ -1,5 +1,27 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/mattermost/focalboard/server/einterfaces"
|
||||
)
|
||||
|
||||
func (s *Server) initHandlers() {
|
||||
// Additional init handlers go here
|
||||
cfg := s.config
|
||||
if cfg.AuthMode == "mattermost" && mattermostAuth != nil {
|
||||
log.Println("Using Mattermost Auth")
|
||||
params := einterfaces.MattermostAuthParameters{
|
||||
ServerRoot: cfg.ServerRoot,
|
||||
MattermostURL: cfg.MattermostURL,
|
||||
ClientID: cfg.MattermostClientID,
|
||||
ClientSecret: cfg.MattermostClientSecret,
|
||||
UseSecureCookie: cfg.SecureCookie,
|
||||
}
|
||||
mmauthHandler := mattermostAuth(params, s.store)
|
||||
log.Println("CREATING AUTH")
|
||||
s.webServer.AddRoutes(mmauthHandler)
|
||||
log.Println("ADDING ROUTES")
|
||||
s.api.WorkspaceAuthenticator = mmauthHandler
|
||||
log.Println("SETTING THE AUTHENTICATOR")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue