mattermost/server/einterfaces/pap.go
Ibrahim Serdar Acikgoz a344b3225b
[MM-61756] Attribute Based Access Control - Phase 1 (#30785)
Attribute Based Access Control - Base
* MM-63662

* MM-63919

* MM-63954

* MM-63955 

* MM-63425

* MM-63426

* MM-63458

* MM-63459

* MM-63603

* MM-63845

* MM-64146

* MM-64199

* MM-64201

* MM-64233

* MM-64247

* MM-64268

---------

Co-authored-by: Harshil Sharma <harshilsharma63@gmail.com>
Co-authored-by: Pablo Andrés Vélez Vidal <pablovv2012@gmail.com>
Co-authored-by: abhijit-singh <abhijitsingh0702@gmail.com>
Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
2025-05-15 11:33:08 +02:00

42 lines
2.8 KiB
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package einterfaces
import (
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/public/shared/request"
)
// PolicyAdministrationPointInterface is the service that manages access control policies.
// It is responsible for creating, updating, and deleting policies.
// Also, it provides methods to check the validity of expressions and to retrieve policies.
type PolicyAdministrationPointInterface interface {
// Init initializes the policy administration point and intiates the CEL engine.
// It is an idempotent operation, meaning that it can be called multiple times.
Init(rctx request.CTX) *model.AppError
// GetPolicyRuleAttributes retrieves the attributes of the given policy.
// It returns a map of attribute names to their values for given action.
GetPolicyRuleAttributes(rctx request.CTX, policyID string, action string) (map[string][]string, *model.AppError)
// CheckExpression checks the validity of the given expression using the CEL engine.
// It returns a list of CELExpressionError if the expression is invalid.
// If the expression is valid, it returns an empty list.
CheckExpression(rctx request.CTX, expression string) ([]model.CELExpressionError, *model.AppError)
// ExpressionToVisualAST converts the given expression to a visual AST.
ExpressionToVisualAST(rctx request.CTX, expression string) (*model.VisualExpression, *model.AppError)
// NormalizePolicy normalizes the given policy by restoring ids back to names.
NormalizePolicy(rctx request.CTX, policy *model.AccessControlPolicy) (*model.AccessControlPolicy, *model.AppError)
// QueryUsersForExpression evaluates the given expression using the CEL engine.
// It returns a list of users that match the expression.
QueryUsersForExpression(rctx request.CTX, expression string, opts model.SubjectSearchOptions) ([]*model.User, int64, *model.AppError)
// QueryUsersForResource evaluates finds the users match to the resource.
QueryUsersForResource(rctx request.CTX, resourceID, action string, opts model.SubjectSearchOptions) ([]*model.User, int64, *model.AppError)
// GetChannelMembersToRemove retrieves the channel members that need to be removed from the given channel.
GetChannelMembersToRemove(rctx request.CTX, channelID string) ([]*model.ChannelMember, *model.AppError)
// SavePolicy saves the given access control policy.
SavePolicy(rctx request.CTX, policy *model.AccessControlPolicy) (*model.AccessControlPolicy, *model.AppError)
// GetPolicy retrieves the access control policy with the given ID.
GetPolicy(rctx request.CTX, id string) (*model.AccessControlPolicy, *model.AppError)
// DeletePolicy deletes the access control policy with the given ID.
DeletePolicy(rctx request.CTX, id string) *model.AppError
}