forked from mattermost-community/focalboard
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} | ||
} |