Fix issues with access_control_policies/search endpoint functionality and docs (#34564)
Some checks are pending
API / build (push) Waiting to run
Server CI / Compute Go Version (push) Waiting to run
Server CI / Check mocks (push) Blocked by required conditions
Server CI / Check go mod tidy (push) Blocked by required conditions
Server CI / check-style (push) Blocked by required conditions
Server CI / Check serialization methods for hot structs (push) Blocked by required conditions
Server CI / Vet API (push) Blocked by required conditions
Server CI / Check migration files (push) Blocked by required conditions
Server CI / Generate email templates (push) Blocked by required conditions
Server CI / Check store layers (push) Blocked by required conditions
Server CI / Check mmctl docs (push) Blocked by required conditions
Server CI / Postgres with binary parameters (push) Blocked by required conditions
Server CI / Postgres (push) Blocked by required conditions
Server CI / Postgres (FIPS) (push) Blocked by required conditions
Server CI / Generate Test Coverage (push) Blocked by required conditions
Server CI / Run mmctl tests (push) Blocked by required conditions
Server CI / Run mmctl tests (FIPS) (push) Blocked by required conditions
Server CI / Build mattermost server app (push) Blocked by required conditions
Web App CI / check-lint (push) Waiting to run
Web App CI / check-i18n (push) Waiting to run
Web App CI / check-types (push) Waiting to run
Web App CI / test (push) Waiting to run
Web App CI / build (push) Waiting to run

* Fix issues with access_control_policies/search endpoint functionality and docs

* Undo
This commit is contained in:
Nick Misasi 2025-11-25 14:04:14 -05:00 committed by GitHub
parent e905a36110
commit 5777dcd254
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 11 deletions

View file

@ -4324,16 +4324,34 @@ components:
term:
type: string
description: The search term to match against policy names or display names.
is_active:
type:
type: string
description: The type of policy (e.g., 'parent' or 'channel').
parent_id:
type: string
description: The ID of the parent policy to search within.
ids:
type: array
items:
type: string
description: List of policy IDs to filter by.
active:
type: boolean
description: Filter policies by active status.
page:
include_children:
type: boolean
description: Whether to include child policies in the result.
cursor:
$ref: "#/components/schemas/AccessControlPolicyCursor"
limit:
type: integer
description: The page number to return.
per_page:
type: integer
description: The number of policies to return per page.
# Add other potential search/filter fields like sort_by, sort_direction
description: The maximum number of policies to return.
AccessControlPolicyCursor:
type: object
properties:
id:
type: string
description: The ID of the policy to start searching after.
AccessControlPolicyTestResponse:
type: object
properties:
@ -4407,12 +4425,18 @@ components:
after:
type: string
description: The ID of the user to start the test after (for pagination).
channelId:
type: string
description: The channel ID to contextually test the expression against (required for channel admins).
CELExpression:
type: object
properties:
expression:
type: string
description: The CEL expression to visualize.
channelId:
type: string
description: The channel ID to contextually test the expression against (required for channel admins).
VisualExpression:
type: object
properties:

View file

@ -19,6 +19,7 @@ import (
)
const MaxPerPage = 1000
const DefaultPerPage = 10
// Usually rules are how we define the policy, hence the versioning. For v0.1, we also
// have the imports field which is used to link with the parent policy.
@ -561,7 +562,7 @@ func (s *SqlAccessControlPolicyStore) GetAll(_ request.CTX, opts model.GetAccess
limit := uint64(opts.Limit)
if limit < 1 {
limit = 1
limit = DefaultPerPage
} else if limit > MaxPerPage {
limit = MaxPerPage
}
@ -598,9 +599,9 @@ func (s *SqlAccessControlPolicyStore) SearchPolicies(rctx request.CTX, opts mode
var query sq.SelectBuilder
if opts.IncludeChildren && opts.ParentID == "" {
columns := accessControlPolicySliceColumns("p")
childIDs := `COALESCE((SELECT JSON_AGG(c.ID)
childIDs := `COALESCE((SELECT JSON_AGG(c.ID)
FROM AccessControlPolicies c
WHERE c.Type != 'parent'
WHERE c.Type != 'parent'
AND c.Data->'imports' @> JSONB_BUILD_ARRAY(p.ID)), '[]'::json) AS ChildIDs`
columns = append(columns, childIDs)
query = s.getQueryBuilder().Select(columns...).From("AccessControlPolicies p")
@ -647,7 +648,7 @@ func (s *SqlAccessControlPolicyStore) SearchPolicies(rctx request.CTX, opts mode
limit := uint64(opts.Limit)
if limit < 1 {
limit = 1
limit = DefaultPerPage
} else if limit > MaxPerPage {
limit = MaxPerPage
}