Registered personal-server specific APIs only when running as personal server (#3228)
This commit is contained in:
parent
fa6de94070
commit
6d243e1c0e
4 changed files with 22 additions and 7 deletions
|
@ -155,6 +155,7 @@ func (p *Plugin) OnActivate() error {
|
||||||
PermissionsService: permissionsService,
|
PermissionsService: permissionsService,
|
||||||
PluginAPI: p.API,
|
PluginAPI: p.API,
|
||||||
Client: client,
|
Client: client,
|
||||||
|
IsPlugin: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
server, err := server.New(params)
|
server, err := server.New(params)
|
||||||
|
|
|
@ -53,10 +53,18 @@ type API struct {
|
||||||
MattermostAuth bool
|
MattermostAuth bool
|
||||||
logger *mlog.Logger
|
logger *mlog.Logger
|
||||||
audit *audit.Audit
|
audit *audit.Audit
|
||||||
|
isPlugin bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAPI(app *app.App, singleUserToken string, authService string, permissions permissions.PermissionsService,
|
func NewAPI(
|
||||||
logger *mlog.Logger, audit *audit.Audit) *API {
|
app *app.App,
|
||||||
|
singleUserToken string,
|
||||||
|
authService string,
|
||||||
|
permissions permissions.PermissionsService,
|
||||||
|
logger *mlog.Logger,
|
||||||
|
audit *audit.Audit,
|
||||||
|
isPlugin bool,
|
||||||
|
) *API {
|
||||||
return &API{
|
return &API{
|
||||||
app: app,
|
app: app,
|
||||||
singleUserToken: singleUserToken,
|
singleUserToken: singleUserToken,
|
||||||
|
@ -64,6 +72,7 @@ func NewAPI(app *app.App, singleUserToken string, authService string, permission
|
||||||
permissions: permissions,
|
permissions: permissions,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
audit: audit,
|
audit: audit,
|
||||||
|
isPlugin: isPlugin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +81,14 @@ func (a *API) RegisterRoutes(r *mux.Router) {
|
||||||
apiv2.Use(a.panicHandler)
|
apiv2.Use(a.panicHandler)
|
||||||
apiv2.Use(a.requireCSRFToken)
|
apiv2.Use(a.requireCSRFToken)
|
||||||
|
|
||||||
|
// personal-server specific routes. These are not needed in plugin mode.
|
||||||
|
if !a.isPlugin {
|
||||||
|
apiv2.HandleFunc("/login", a.handleLogin).Methods("POST")
|
||||||
|
apiv2.HandleFunc("/logout", a.sessionRequired(a.handleLogout)).Methods("POST")
|
||||||
|
apiv2.HandleFunc("/register", a.handleRegister).Methods("POST")
|
||||||
|
apiv2.HandleFunc("/teams/{teamID}/regenerate_signup_token", a.sessionRequired(a.handlePostTeamRegenerateSignupToken)).Methods("POST")
|
||||||
|
}
|
||||||
|
|
||||||
// Board APIs
|
// Board APIs
|
||||||
apiv2.HandleFunc("/teams/{teamID}/boards", a.sessionRequired(a.handleGetBoards)).Methods("GET")
|
apiv2.HandleFunc("/teams/{teamID}/boards", a.sessionRequired(a.handleGetBoards)).Methods("GET")
|
||||||
apiv2.HandleFunc("/teams/{teamID}/boards/search", a.sessionRequired(a.handleSearchBoards)).Methods("GET")
|
apiv2.HandleFunc("/teams/{teamID}/boards/search", a.sessionRequired(a.handleSearchBoards)).Methods("GET")
|
||||||
|
@ -106,7 +123,6 @@ func (a *API) RegisterRoutes(r *mux.Router) {
|
||||||
// Team APIs
|
// Team APIs
|
||||||
apiv2.HandleFunc("/teams", a.sessionRequired(a.handleGetTeams)).Methods("GET")
|
apiv2.HandleFunc("/teams", a.sessionRequired(a.handleGetTeams)).Methods("GET")
|
||||||
apiv2.HandleFunc("/teams/{teamID}", a.sessionRequired(a.handleGetTeam)).Methods("GET")
|
apiv2.HandleFunc("/teams/{teamID}", a.sessionRequired(a.handleGetTeam)).Methods("GET")
|
||||||
apiv2.HandleFunc("/teams/{teamID}/regenerate_signup_token", a.sessionRequired(a.handlePostTeamRegenerateSignupToken)).Methods("POST")
|
|
||||||
apiv2.HandleFunc("/teams/{teamID}/users", a.sessionRequired(a.handleGetTeamUsers)).Methods("GET")
|
apiv2.HandleFunc("/teams/{teamID}/users", a.sessionRequired(a.handleGetTeamUsers)).Methods("GET")
|
||||||
apiv2.HandleFunc("/teams/{teamID}/archive/export", a.sessionRequired(a.handleArchiveExportTeam)).Methods("GET")
|
apiv2.HandleFunc("/teams/{teamID}/archive/export", a.sessionRequired(a.handleArchiveExportTeam)).Methods("GET")
|
||||||
apiv2.HandleFunc("/teams/{teamID}/{boardID}/files", a.sessionRequired(a.handleUploadFile)).Methods("POST")
|
apiv2.HandleFunc("/teams/{teamID}/{boardID}/files", a.sessionRequired(a.handleUploadFile)).Methods("POST")
|
||||||
|
@ -124,9 +140,6 @@ func (a *API) RegisterRoutes(r *mux.Router) {
|
||||||
apiv2.HandleFunc("/boards-and-blocks", a.sessionRequired(a.handleDeleteBoardsAndBlocks)).Methods("DELETE")
|
apiv2.HandleFunc("/boards-and-blocks", a.sessionRequired(a.handleDeleteBoardsAndBlocks)).Methods("DELETE")
|
||||||
|
|
||||||
// Auth APIs
|
// Auth APIs
|
||||||
apiv2.HandleFunc("/login", a.handleLogin).Methods("POST")
|
|
||||||
apiv2.HandleFunc("/logout", a.sessionRequired(a.handleLogout)).Methods("POST")
|
|
||||||
apiv2.HandleFunc("/register", a.handleRegister).Methods("POST")
|
|
||||||
apiv2.HandleFunc("/clientConfig", a.getClientConfig).Methods("GET")
|
apiv2.HandleFunc("/clientConfig", a.getClientConfig).Methods("GET")
|
||||||
|
|
||||||
// Category APIs
|
// Category APIs
|
||||||
|
|
|
@ -26,6 +26,7 @@ type Params struct {
|
||||||
PermissionsService permissions.PermissionsService
|
PermissionsService permissions.PermissionsService
|
||||||
PluginAPI plugin.API
|
PluginAPI plugin.API
|
||||||
Client *pluginapi.Client
|
Client *pluginapi.Client
|
||||||
|
IsPlugin bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Params) CheckValid() error {
|
func (p Params) CheckValid() error {
|
||||||
|
|
|
@ -142,7 +142,7 @@ func New(params Params) (*Server, error) {
|
||||||
}
|
}
|
||||||
app := app.New(params.Cfg, wsAdapter, appServices)
|
app := app.New(params.Cfg, wsAdapter, appServices)
|
||||||
|
|
||||||
focalboardAPI := api.NewAPI(app, params.SingleUserToken, params.Cfg.AuthMode, params.PermissionsService, params.Logger, auditService)
|
focalboardAPI := api.NewAPI(app, params.SingleUserToken, params.Cfg.AuthMode, params.PermissionsService, params.Logger, auditService, params.IsPlugin)
|
||||||
|
|
||||||
// Local router for admin APIs
|
// Local router for admin APIs
|
||||||
localRouter := mux.NewRouter()
|
localRouter := mux.NewRouter()
|
||||||
|
|
Loading…
Reference in a new issue