* add new pluginapi methods

* SAML login hook

* set ReAddRemovedMembers to true for plugin groups

* change to DoLogin signature for SAML
Этот коммит содержится в:
Ben Cooke
2025-03-13 12:00:15 -04:00
коммит произвёл GitHub
родитель 0e0e54446d
Коммит ccd8a60168
44 изменённых файлов: 2119 добавлений и 213 удалений

Просмотреть файл

@@ -10,6 +10,7 @@ import (
"fmt"
"log"
saml2 "github.com/mattermost/gosaml2"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/mlog"
)
@@ -1161,6 +1162,43 @@ func (s *hooksRPCServer) GenerateSupportData(args *Z_GenerateSupportDataArgs, re
return nil
}
func init() {
hookNameToId["OnSAMLLogin"] = OnSAMLLoginID
}
type Z_OnSAMLLoginArgs struct {
A *Context
B *model.User
C *saml2.AssertionInfo
}
type Z_OnSAMLLoginReturns struct {
A error
}
func (g *hooksRPCClient) OnSAMLLogin(c *Context, user *model.User, assertion *saml2.AssertionInfo) error {
_args := &Z_OnSAMLLoginArgs{c, user, assertion}
_returns := &Z_OnSAMLLoginReturns{}
if g.implemented[OnSAMLLoginID] {
if err := g.client.Call("Plugin.OnSAMLLogin", _args, _returns); err != nil {
g.log.Error("RPC call OnSAMLLogin to plugin failed.", mlog.Err(err))
}
}
return _returns.A
}
func (s *hooksRPCServer) OnSAMLLogin(args *Z_OnSAMLLoginArgs, returns *Z_OnSAMLLoginReturns) error {
if hook, ok := s.impl.(interface {
OnSAMLLogin(c *Context, user *model.User, assertion *saml2.AssertionInfo) error
}); ok {
returns.A = hook.OnSAMLLogin(args.A, args.B, args.C)
returns.A = encodableError(returns.A)
} else {
return encodableError(fmt.Errorf("Hook OnSAMLLogin called but not implemented."))
}
return nil
}
type Z_RegisterCommandArgs struct {
A *model.Command
}
@@ -6601,6 +6639,392 @@ func (s *apiRPCServer) UninviteRemoteFromChannel(args *Z_UninviteRemoteFromChann
return nil
}
type Z_UpsertGroupMemberArgs struct {
A string
B string
}
type Z_UpsertGroupMemberReturns struct {
A *model.GroupMember
B *model.AppError
}
func (g *apiRPCClient) UpsertGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError) {
_args := &Z_UpsertGroupMemberArgs{groupID, userID}
_returns := &Z_UpsertGroupMemberReturns{}
if err := g.client.Call("Plugin.UpsertGroupMember", _args, _returns); err != nil {
log.Printf("RPC call to UpsertGroupMember API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) UpsertGroupMember(args *Z_UpsertGroupMemberArgs, returns *Z_UpsertGroupMemberReturns) error {
if hook, ok := s.impl.(interface {
UpsertGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError)
}); ok {
returns.A, returns.B = hook.UpsertGroupMember(args.A, args.B)
} else {
return encodableError(fmt.Errorf("API UpsertGroupMember called but not implemented."))
}
return nil
}
type Z_UpsertGroupMembersArgs struct {
A string
B []string
}
type Z_UpsertGroupMembersReturns struct {
A []*model.GroupMember
B *model.AppError
}
func (g *apiRPCClient) UpsertGroupMembers(groupID string, userIDs []string) ([]*model.GroupMember, *model.AppError) {
_args := &Z_UpsertGroupMembersArgs{groupID, userIDs}
_returns := &Z_UpsertGroupMembersReturns{}
if err := g.client.Call("Plugin.UpsertGroupMembers", _args, _returns); err != nil {
log.Printf("RPC call to UpsertGroupMembers API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) UpsertGroupMembers(args *Z_UpsertGroupMembersArgs, returns *Z_UpsertGroupMembersReturns) error {
if hook, ok := s.impl.(interface {
UpsertGroupMembers(groupID string, userIDs []string) ([]*model.GroupMember, *model.AppError)
}); ok {
returns.A, returns.B = hook.UpsertGroupMembers(args.A, args.B)
} else {
return encodableError(fmt.Errorf("API UpsertGroupMembers called but not implemented."))
}
return nil
}
type Z_GetGroupByRemoteIDArgs struct {
A string
B model.GroupSource
}
type Z_GetGroupByRemoteIDReturns struct {
A *model.Group
B *model.AppError
}
func (g *apiRPCClient) GetGroupByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, *model.AppError) {
_args := &Z_GetGroupByRemoteIDArgs{remoteID, groupSource}
_returns := &Z_GetGroupByRemoteIDReturns{}
if err := g.client.Call("Plugin.GetGroupByRemoteID", _args, _returns); err != nil {
log.Printf("RPC call to GetGroupByRemoteID API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) GetGroupByRemoteID(args *Z_GetGroupByRemoteIDArgs, returns *Z_GetGroupByRemoteIDReturns) error {
if hook, ok := s.impl.(interface {
GetGroupByRemoteID(remoteID string, groupSource model.GroupSource) (*model.Group, *model.AppError)
}); ok {
returns.A, returns.B = hook.GetGroupByRemoteID(args.A, args.B)
} else {
return encodableError(fmt.Errorf("API GetGroupByRemoteID called but not implemented."))
}
return nil
}
type Z_CreateGroupArgs struct {
A *model.Group
}
type Z_CreateGroupReturns struct {
A *model.Group
B *model.AppError
}
func (g *apiRPCClient) CreateGroup(group *model.Group) (*model.Group, *model.AppError) {
_args := &Z_CreateGroupArgs{group}
_returns := &Z_CreateGroupReturns{}
if err := g.client.Call("Plugin.CreateGroup", _args, _returns); err != nil {
log.Printf("RPC call to CreateGroup API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) CreateGroup(args *Z_CreateGroupArgs, returns *Z_CreateGroupReturns) error {
if hook, ok := s.impl.(interface {
CreateGroup(group *model.Group) (*model.Group, *model.AppError)
}); ok {
returns.A, returns.B = hook.CreateGroup(args.A)
} else {
return encodableError(fmt.Errorf("API CreateGroup called but not implemented."))
}
return nil
}
type Z_UpdateGroupArgs struct {
A *model.Group
}
type Z_UpdateGroupReturns struct {
A *model.Group
B *model.AppError
}
func (g *apiRPCClient) UpdateGroup(group *model.Group) (*model.Group, *model.AppError) {
_args := &Z_UpdateGroupArgs{group}
_returns := &Z_UpdateGroupReturns{}
if err := g.client.Call("Plugin.UpdateGroup", _args, _returns); err != nil {
log.Printf("RPC call to UpdateGroup API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) UpdateGroup(args *Z_UpdateGroupArgs, returns *Z_UpdateGroupReturns) error {
if hook, ok := s.impl.(interface {
UpdateGroup(group *model.Group) (*model.Group, *model.AppError)
}); ok {
returns.A, returns.B = hook.UpdateGroup(args.A)
} else {
return encodableError(fmt.Errorf("API UpdateGroup called but not implemented."))
}
return nil
}
type Z_DeleteGroupArgs struct {
A string
}
type Z_DeleteGroupReturns struct {
A *model.Group
B *model.AppError
}
func (g *apiRPCClient) DeleteGroup(groupID string) (*model.Group, *model.AppError) {
_args := &Z_DeleteGroupArgs{groupID}
_returns := &Z_DeleteGroupReturns{}
if err := g.client.Call("Plugin.DeleteGroup", _args, _returns); err != nil {
log.Printf("RPC call to DeleteGroup API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) DeleteGroup(args *Z_DeleteGroupArgs, returns *Z_DeleteGroupReturns) error {
if hook, ok := s.impl.(interface {
DeleteGroup(groupID string) (*model.Group, *model.AppError)
}); ok {
returns.A, returns.B = hook.DeleteGroup(args.A)
} else {
return encodableError(fmt.Errorf("API DeleteGroup called but not implemented."))
}
return nil
}
type Z_RestoreGroupArgs struct {
A string
}
type Z_RestoreGroupReturns struct {
A *model.Group
B *model.AppError
}
func (g *apiRPCClient) RestoreGroup(groupID string) (*model.Group, *model.AppError) {
_args := &Z_RestoreGroupArgs{groupID}
_returns := &Z_RestoreGroupReturns{}
if err := g.client.Call("Plugin.RestoreGroup", _args, _returns); err != nil {
log.Printf("RPC call to RestoreGroup API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) RestoreGroup(args *Z_RestoreGroupArgs, returns *Z_RestoreGroupReturns) error {
if hook, ok := s.impl.(interface {
RestoreGroup(groupID string) (*model.Group, *model.AppError)
}); ok {
returns.A, returns.B = hook.RestoreGroup(args.A)
} else {
return encodableError(fmt.Errorf("API RestoreGroup called but not implemented."))
}
return nil
}
type Z_DeleteGroupMemberArgs struct {
A string
B string
}
type Z_DeleteGroupMemberReturns struct {
A *model.GroupMember
B *model.AppError
}
func (g *apiRPCClient) DeleteGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError) {
_args := &Z_DeleteGroupMemberArgs{groupID, userID}
_returns := &Z_DeleteGroupMemberReturns{}
if err := g.client.Call("Plugin.DeleteGroupMember", _args, _returns); err != nil {
log.Printf("RPC call to DeleteGroupMember API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) DeleteGroupMember(args *Z_DeleteGroupMemberArgs, returns *Z_DeleteGroupMemberReturns) error {
if hook, ok := s.impl.(interface {
DeleteGroupMember(groupID string, userID string) (*model.GroupMember, *model.AppError)
}); ok {
returns.A, returns.B = hook.DeleteGroupMember(args.A, args.B)
} else {
return encodableError(fmt.Errorf("API DeleteGroupMember called but not implemented."))
}
return nil
}
type Z_GetGroupSyncableArgs struct {
A string
B string
C model.GroupSyncableType
}
type Z_GetGroupSyncableReturns struct {
A *model.GroupSyncable
B *model.AppError
}
func (g *apiRPCClient) GetGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError) {
_args := &Z_GetGroupSyncableArgs{groupID, syncableID, syncableType}
_returns := &Z_GetGroupSyncableReturns{}
if err := g.client.Call("Plugin.GetGroupSyncable", _args, _returns); err != nil {
log.Printf("RPC call to GetGroupSyncable API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) GetGroupSyncable(args *Z_GetGroupSyncableArgs, returns *Z_GetGroupSyncableReturns) error {
if hook, ok := s.impl.(interface {
GetGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError)
}); ok {
returns.A, returns.B = hook.GetGroupSyncable(args.A, args.B, args.C)
} else {
return encodableError(fmt.Errorf("API GetGroupSyncable called but not implemented."))
}
return nil
}
type Z_GetGroupSyncablesArgs struct {
A string
B model.GroupSyncableType
}
type Z_GetGroupSyncablesReturns struct {
A []*model.GroupSyncable
B *model.AppError
}
func (g *apiRPCClient) GetGroupSyncables(groupID string, syncableType model.GroupSyncableType) ([]*model.GroupSyncable, *model.AppError) {
_args := &Z_GetGroupSyncablesArgs{groupID, syncableType}
_returns := &Z_GetGroupSyncablesReturns{}
if err := g.client.Call("Plugin.GetGroupSyncables", _args, _returns); err != nil {
log.Printf("RPC call to GetGroupSyncables API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) GetGroupSyncables(args *Z_GetGroupSyncablesArgs, returns *Z_GetGroupSyncablesReturns) error {
if hook, ok := s.impl.(interface {
GetGroupSyncables(groupID string, syncableType model.GroupSyncableType) ([]*model.GroupSyncable, *model.AppError)
}); ok {
returns.A, returns.B = hook.GetGroupSyncables(args.A, args.B)
} else {
return encodableError(fmt.Errorf("API GetGroupSyncables called but not implemented."))
}
return nil
}
type Z_UpsertGroupSyncableArgs struct {
A *model.GroupSyncable
}
type Z_UpsertGroupSyncableReturns struct {
A *model.GroupSyncable
B *model.AppError
}
func (g *apiRPCClient) UpsertGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError) {
_args := &Z_UpsertGroupSyncableArgs{groupSyncable}
_returns := &Z_UpsertGroupSyncableReturns{}
if err := g.client.Call("Plugin.UpsertGroupSyncable", _args, _returns); err != nil {
log.Printf("RPC call to UpsertGroupSyncable API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) UpsertGroupSyncable(args *Z_UpsertGroupSyncableArgs, returns *Z_UpsertGroupSyncableReturns) error {
if hook, ok := s.impl.(interface {
UpsertGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError)
}); ok {
returns.A, returns.B = hook.UpsertGroupSyncable(args.A)
} else {
return encodableError(fmt.Errorf("API UpsertGroupSyncable called but not implemented."))
}
return nil
}
type Z_UpdateGroupSyncableArgs struct {
A *model.GroupSyncable
}
type Z_UpdateGroupSyncableReturns struct {
A *model.GroupSyncable
B *model.AppError
}
func (g *apiRPCClient) UpdateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError) {
_args := &Z_UpdateGroupSyncableArgs{groupSyncable}
_returns := &Z_UpdateGroupSyncableReturns{}
if err := g.client.Call("Plugin.UpdateGroupSyncable", _args, _returns); err != nil {
log.Printf("RPC call to UpdateGroupSyncable API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) UpdateGroupSyncable(args *Z_UpdateGroupSyncableArgs, returns *Z_UpdateGroupSyncableReturns) error {
if hook, ok := s.impl.(interface {
UpdateGroupSyncable(groupSyncable *model.GroupSyncable) (*model.GroupSyncable, *model.AppError)
}); ok {
returns.A, returns.B = hook.UpdateGroupSyncable(args.A)
} else {
return encodableError(fmt.Errorf("API UpdateGroupSyncable called but not implemented."))
}
return nil
}
type Z_DeleteGroupSyncableArgs struct {
A string
B string
C model.GroupSyncableType
}
type Z_DeleteGroupSyncableReturns struct {
A *model.GroupSyncable
B *model.AppError
}
func (g *apiRPCClient) DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError) {
_args := &Z_DeleteGroupSyncableArgs{groupID, syncableID, syncableType}
_returns := &Z_DeleteGroupSyncableReturns{}
if err := g.client.Call("Plugin.DeleteGroupSyncable", _args, _returns); err != nil {
log.Printf("RPC call to DeleteGroupSyncable API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) DeleteGroupSyncable(args *Z_DeleteGroupSyncableArgs, returns *Z_DeleteGroupSyncableReturns) error {
if hook, ok := s.impl.(interface {
DeleteGroupSyncable(groupID string, syncableID string, syncableType model.GroupSyncableType) (*model.GroupSyncable, *model.AppError)
}); ok {
returns.A, returns.B = hook.DeleteGroupSyncable(args.A, args.B, args.C)
} else {
return encodableError(fmt.Errorf("API DeleteGroupSyncable called but not implemented."))
}
return nil
}
type Z_UpdateUserRolesArgs struct {
A string
B string
@@ -6657,3 +7081,35 @@ func (s *apiRPCServer) GetPluginID(args *Z_GetPluginIDArgs, returns *Z_GetPlugin
}
return nil
}
type Z_GetGroupsArgs struct {
A int
B int
C model.GroupSearchOpts
D *model.ViewUsersRestrictions
}
type Z_GetGroupsReturns struct {
A []*model.Group
B *model.AppError
}
func (g *apiRPCClient) GetGroups(page, perPage int, opts model.GroupSearchOpts, viewRestrictions *model.ViewUsersRestrictions) ([]*model.Group, *model.AppError) {
_args := &Z_GetGroupsArgs{page, perPage, opts, viewRestrictions}
_returns := &Z_GetGroupsReturns{}
if err := g.client.Call("Plugin.GetGroups", _args, _returns); err != nil {
log.Printf("RPC call to GetGroups API failed: %s", err.Error())
}
return _returns.A, _returns.B
}
func (s *apiRPCServer) GetGroups(args *Z_GetGroupsArgs, returns *Z_GetGroupsReturns) error {
if hook, ok := s.impl.(interface {
GetGroups(page, perPage int, opts model.GroupSearchOpts, viewRestrictions *model.ViewUsersRestrictions) ([]*model.Group, *model.AppError)
}); ok {
returns.A, returns.B = hook.GetGroups(args.A, args.B, args.C, args.D)
} else {
return encodableError(fmt.Errorf("API GetGroups called but not implemented."))
}
return nil
}