11 Commits
Author SHA1 Message Date
f5de797495 Plugin API: EvaluateAccessControlBatch, CheckAccessControlExpressionForSearch, and ABAC-unavailable Get/Delete fallback (#39895)
* MM: add EvaluateAccessControlBatch and CheckAccessControlExpressionForSearch plugin APIs

EvaluateAccessControlBatch builds the subject once and evaluates up to 500
distinct resource IDs for one user, returning decisions keyed by ID; IDs that
could not be evaluated are omitted so callers fail closed. When the ABAC engine
is unavailable, existence is resolved for the whole batch with one
type-filtered SearchPolicies.

CheckAccessControlExpressionForSearch exposes the enterprise membership check
(lint + session-attribute rejection + CheckSqlizable) so plugins whose policies
must also drive user searches can gate saves on it.

GetAccessControlPolicy and DeleteAccessControlPolicy now fall back to the raw
store when the engine is unavailable, so a plugin can still show and clear its
restrictions after a license lapse.

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Make plugin ABAC batch existence fallback primary-backed and consistent with single-ID path

Add AccessControlPolicyStore.GetTypesByIDs (primary read, one query) and use it
for the batch existence probe instead of the replica-backed SearchPolicies, so a
just-saved restriction cannot be reported as no_policy. Batch evaluator errors
now resolve existence per ID like EvaluateAccessControl, document the Get/Delete
fallback behavior and the read-only stored form, and extend tests.

Co-authored-by: joram <joram@mattermost.com>

* docs: document batch evaluation, search expression check and ABAC-unavailable Get/Delete for plugins

Co-authored-by: joram <joram@mattermost.com>

* Return error from new plugin access control app functions (appErrorReturn vet)

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Address review: log batch evaluator failures once, clarify batch and fallback docs

Co-authored-by: Joram Wilander <joram@mattermost.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-19 19:12:38 +00:00
01c5cda69b MM-71346 Plugin testhelper: run integration tests against an HA cluster (#39403)
* MM-71346 Plugin testhelper: run integration tests against an HA cluster

Plugins that use cluster events had no way to test their cross-node
behaviour: the testhelper starts a single Mattermost container.

- Add SetupCluster(t, n), which starts n nodes forming a real HA
  cluster. The nodes share one Postgres database, also used as the
  config store (MM_CONFIG), and one file store volume, so the plugin is
  deployed once and runs on every node.
- Expose the servers as TestHelper.Nodes, each with its cluster ID,
  hostname, URL, and admin and user clients aimed at it, plus Exec,
  Pause/Unpause and Stop/Start for fault injection. Setup gets a single
  node.
- Clustering needs a license with the Cluster feature (Mattermost Entry
  has none). Read it from MM_LICENSE, start the nodes with
  MM_SERVICEENVIRONMENT=test, skip without a license, and fail when the
  server rejects it or it lacks the Cluster feature.
- Reset the database through the first node with the others stopped,
  wait for the cluster to form, and wait for the plugin on every node.
- Log the tail of each node's container log when a test fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015bYRkFZXxqdgiFMsh8MPVm

* MM-71346 Tidy server/public go.sum

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015bYRkFZXxqdgiFMsh8MPVm

* MM-71346 Fix node state tracking in the cluster testhelper

- Clear a node's paused flag when it is stopped: Docker stops paused
  containers, and a stale flag made waitForCluster skip the node after a
  restart and the Pause cleanup unpause a container that wasn't paused.
- Ignore a restarted node's old member while waiting for the cluster, so
  Start can't return early with the old ID when Docker reuses the address.
- Give stopped nodes an empty ID and let paused nodes keep theirs, rather
  than matching every node by a possibly reused address.
- Start the other nodes in parallel after a database reset.
- Report which node failed to join when the cluster doesn't form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015bYRkFZXxqdgiFMsh8MPVm

* MM-71346 Simplify the cluster testhelper

- Read whether a node is paused from Docker instead of tracking a flag.
- Record a stopped node's cluster ID as stale in Stop, so waitForCluster
  needs no stale-ID parameter and covers every stop/restart order.
- Make Node.Hostname and Node.URL methods reading the container, so
  Start has nothing to copy.
- Key the shared containers by node count; a cluster is more than one node.
- Share one inParallel helper for starting and stopping nodes, which also
  stops the other nodes in parallel on reset and reports every failed
  start instead of the last.
- Drop the admin creation at container start: every Setup resets the
  database and creates the admin.
- Reuse execInContainer for Node.Exec, share the per-node client helper,
  and poll the cluster status every 250ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015bYRkFZXxqdgiFMsh8MPVm

* MM-71346 Docs: test a plugin in high availability mode

Document testhelper.SetupCluster, the Node fault-injection methods and
the MM_LICENSE requirement in the plugin HA guide.

* MM-71346 Docs: trim the Node API list in the HA testing section

* MM-71346 Fix plugin deploy race and stale node ID in the cluster testhelper

deployPlugin removed and re-uploaded the plugin as two separate cluster
messages, which receivers handle concurrently, so a node could apply the
remove after the install and lose the plugin. A forced upload replaces the
existing install in one step.

Node.Start now forgets the node's old cluster ID before starting, so a node
that stopped other than through Stop doesn't keep a dead ID after rejoining.

* MM-71346 Wait for the plugin on each cluster node by ID, and remove the test network on failure

deployPlugin now waits until the plugin runs on every current cluster node,
matched by ID, rather than on as many nodes as there are. A failed container
start also removes the Docker network instead of leaving it to the reaper.
Document that Setup and SetupCluster in one test binary run side by side.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015vpi5iekJF1wHe68kShpjr

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: wiggin77 <wiggin77@warpmail.net>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: mattermost-code <matty-code@mattermost.com>
Co-authored-by: maria.nunez <maria.nunez@mattermost.com>
2026-11-12 09:27:27 +01:00
2cce4231cb docs: fix broken internal links and fail CI on new ones (#39953)
* docs: fix broken internal links in developer and product docs

Contributor guide linked to root-level /why-contribute, /good-decisions,
/expectations and /more-info; switch these and other root-relative or
moved-page links to relative file links or current paths. Repoint absolute
docs.mattermost.com links that no longer resolve, demote body-level H1s
that Docusaurus renders without ids, and fix stale anchors.

* docs: register plugin reference anchors with the broken-link checker

The generated server/webapp/manifest reference components render raw
elements with ids, which Docusaurus does not see, so every deep link into
them was reported as a broken anchor.

* docs: fail CI on broken links and unresolvable absolute docs links

Set onBrokenLinks and onBrokenMarkdownLinks to throw now that the build is
clean, keep onBrokenAnchors at warn, and add check:absolute-links to Docs CI
to validate absolute https://docs.mattermost.com links against the build.

* chore(docs): refresh rendered IME diagram

Auto-generated by .github/workflows/docs-ime-render.yml.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-11-12 09:36:39 +02:00
b9eed09fde Docs: Update ABAC and property system docs for v12.0 (#39297)
* Docs: Add an access policy expression reference

Access rule syntax was spread across several pages and the v12
changelog, and the multiselect, hierarchical, IP range, version and
account-age operators and the native user fields weren't documented
anywhere. Add one reference page that covers the values a rule can
use, every Simple Mode operator and the expression it produces, the
full set of operators Advanced Mode accepts, ranked, hierarchical,
channel and session attributes, how rules combine, and what happens
when a rule can't be evaluated. List it in the attribute-based access
control section of the sidebar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Document channel attributes in access rules

Channel attributes can be compared with user attributes in membership
and permission policy rules, but the docs still described them, and
Classification Markings, as informational only. Replace those claims
with a section on using channel attributes in access rules: linking
the attributes, adding one in the editor, the supported comparisons,
and the warning that a channel missing a value denies everyone.

Also document the Classification Markings clearance attribute, drop the
feature flag instructions for channel attributes, and correct the
license badge to Entry or Enterprise Advanced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Update ABAC overview and system-wide policies for v12

Point navigation at the Membership Policies and Permission Policies
pages, describe per-channel auto-add and the "Enforce policy
immediately" option, and add steps for creating a permission policy.
Explain that simulation is available in permission policy editors via
Simulate rules, including session attribute overrides.

Replace the Simple Mode operator lists with a link to the expression
reference, fix the Advanced Mode syntax to user.attributes.<name>, drop
instructions for feature flags that are now on by default, align
versions (permission policies in v11.7, burn-on-read in v12.1), update
the license tier to Entry or Enterprise Advanced, and shorten the team
assignment section in favour of the team membership page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Update channel and team-scoped channel policy pages for v12

Team Admins can assign team-level channel membership policies to public
as well as private channels, so the team channel policies page now
describes both and explains that public channels are advisory. The
self-inclusion filter and self-exclusion check only apply when a policy
covers a private channel.

Auto-add is described as a per-channel setting that isn't inherited
from system policies, replacing the old active-state wording. On public
channels with auto-add on, a matching user who leaves is added again at
the next sync, and both pages now say so. Policy inheritance now says
plainly that every applicable policy must allow access. The duplicated
Team Settings section on the channel access rules page is replaced with
a link, operator lists link to the expression reference, and
instructions for feature flags that are on by default are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Fix team membership policy labels and licensing

Quote the System Console setting as it appears in the UI ("Allow
attribute based access controls on this server") and describe the
license as Entry or Enterprise Advanced throughout. Drop the feature
flag instructions and the flag on/off table, since team membership
policies are on by default.

Call the editor Simple Mode, as the UI does, and point the operator
lists at the expression reference rather than repeating an incomplete
list. Link the sync interval settings and the ABAC setting to the
System Attributes settings reference, and align the team settings
entry in the user management configuration page with these pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Document hierarchical attributes and attribute sync in Attribute Management

Add a Hierarchical attributes section covering how to build the value
tree (top-level and child values, multiple parents, moving and deleting
values), the create-only type, the parent and depth limits, where values
are set, and how the attribute is used in access rules.

Correct the licensing badges to Entry, Enterprise, or Enterprise Advanced
for the page and Entry or Enterprise Advanced for the Channels resource,
drop the feature-flag conditions, and fix the Channels display location
choices. Note that AD/LDAP takes precedence when both sources are linked,
that hierarchical attributes can't be linked, and point the user-managed
attributes link at the System Attributes settings reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Document mmctl user attributes commands

The mmctl reference described a top-level `mmctl cpa` command with flags
and field types that don't exist. Replace it with the real
`mmctl user attributes` command (aliases `attrs` and `cpa`), covering the
field list/create/edit/delete and value list/set subcommands with their
actual arguments and flags.

Explain that from v12.0, field edit and delete fail for attributes linked
to Attribute Management, that the underlying User Attributes API is
deprecated, and correct the license badge to Entry, Enterprise, or
Enterprise Advanced. Point existing links at the new section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Point user attribute links at Attribute Management

The User attributes page describes the System Console page from before
v12.0, which now redirects to Attribute Management. Retitle it and state
plainly that it covers earlier releases only, fix its malformed
EnableUserManagedAttributes config example, and use the UI's own
"Editable by users" label throughout.

Links elsewhere that mean the current feature (zero trust, plans, profile,
calls, session attributes, user management, mission partner and Slack
migration pages) now go to Attribute Management, and the calls page uses
the current "Profile display: Hidden" label. Also fixes a typo on the
editions page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Add System Attributes settings reference and ABAC audit events

The System attributes page listed features but documented none of the
AccessControlSettings. It is now a settings reference: an index of the
System Attributes console pages, then one entry per setting with its
console label, default, config.json key and environment variable,
including the four settings that have no console option.

The audit log schema now lists the per-user membership records written
by sync jobs when ABAC audit logging is enabled, with their parameters
and reason values. The access control events table now describes what
each event records today and adds the plugin policy, team policy cleanup
and batch auto-add events. User attributes events gain cpaValueChange.

Links that pointed at the legacy user attributes page for the
user-managed attributes setting now point at the new reference entry,
and the team membership page no longer says that an attribute refresh
interval of 0 disables refreshing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Document user attribute sync in AD/LDAP and SAML settings

The AD/LDAP and SAML settings pages covered only the built-in profile
fields, so admins setting up an identity provider couldn't find the
User attributes sync section. Add a settings entry for it in both
sections, describing how mappings are saved, which attribute types can
be synced, how values and options are managed, AD/LDAP precedence, and
when each source syncs. Point to it from the AD/LDAP and SAML setup
pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Document bot attributes and user attribute values

Bot accounts can carry user attribute values from v12.1, so access
policies check them like any user. The integrations settings page now
explains where to set them, who can, and how they interact with access
rules and the user-managed attributes setting.

The profile page now covers user attributes from the user's side: where
they appear, which values users can change and why some are read-only,
how each kind of value is chosen (including the hierarchical picker),
and how the profile popover shows them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Correct v12 ABAC and attribute notes in changelog and upgrade guides

The v12 release notes pointed integrations at an undefined "Global
Attributes API" and never said the User Attributes (Custom Profile
Attributes) API is deprecated. Name the Properties API endpoints for user
attributes and templates instead, and add a deprecation entry that covers
the HTTP 400 on linked fields, the effect on mmctl user attributes field
edit and delete, and the planned removal.

Also correct the session attributes note (they're available by default but
each one starts disabled), drop feature flag conditions for channel
attributes that were already on by default, and link the hierarchical
functions and channel attributes notes to their reference pages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Remove the bot attributes section from integrations settings

Setting user attribute values on bot accounts isn't in a released
version yet, so the Bot attributes subsection described a feature
readers can't use. Remove it until the feature ships.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Limit AD/LDAP and SAML attribute sync notes to current behavior

The AD/LDAP, SAML and Attribute Management pages described attribute
sync behavior that hasn't shipped in a release: Select and Multiselect
attributes keeping their type, sync-managed options and the option
limit, clearing values the identity provider stops sending, and AD/LDAP
taking precedence over SAML. Remove those notes. Linking an attribute to
AD/LDAP or SAML changes it to Text, and an external source can be added
only before the attribute applies to a resource, as the Attribute
Management page said before.

The User attributes sync settings entries, when each source syncs, and
the links from Attribute Management are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Remove the burn-on-read permission from permission policy pages

Restricting who can send burn-on-read messages with a permission policy
isn't in a released version yet; released permission policies cover
file upload and file download only. Remove the burn-on-read permission
from the system-wide and channel permission policy pages, the ABAC
overview, the System Attributes settings and audit log pages, and the
end-user burn-on-read section. Burn-on-read messages themselves are
still documented, along with the setting that turns them off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Remove hierarchical "has any of" against channel attributes

In v12.0, hasAnyOf and hasAllOf need a multiselect user attribute, and
Simple Mode doesn't offer a channel attribute for "has any of" or "has
all of" on a hierarchical attribute. Hierarchical attributes compare
with a channel attribute only through the covers and within operators,
so the expression reference and the channel attributes page no longer
say otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Limit the permission policy warning to file actions

In v12.0, permission policies cover only file upload and file download,
so posting a message is never evaluated against them. The warning no
longer describes incoming webhooks and custom slash commands, which
can't attach files, or plugins posting messages.

It also said scheduled messages are evaluated when they're scheduled.
In v12.0 nothing is checked at scheduling or at send time: the upload
restriction is checked when each file is uploaded, so the warning now
says that instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Drop required channel attribute claims from the v12.0 changelog

In v12.0, required channel attributes are enforced only when the
off-by-default ChannelAttributesRequired feature flag is on. By default
the create-channel dialog doesn't ask for channel attributes and the
channels API doesn't refuse a channel without a required value, so the
channel attributes entry no longer says either.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Remove the Managed by indicator from Attribute Management

The Users resource settings in v12.0 don't show which external source
an attribute is synced from; the Managed by indicator isn't in a
released version yet. Linked sources are still listed under Synced with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Restore existing burn-on-read and permission policy text

Recent edits removed text about restricting burn-on-read messages with a
permission policy, and rewrote the permission policy warning about
plugins, webhooks, slash commands and scheduled messages. That text was
already in the docs before these edits, so put it back as it was: the
burn-on-read permission and the setting it works with on the system-wide
policies page, the warning, the burn-on-read mentions on the ABAC
overview and channel access rules pages, and the end-user burn-on-read
section.

Label, version and typo fixes made to those pages since are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Restore existing attribute sync notes in Attribute Management

Recent edits removed or reworded notes in the Link an attribute to
AD/LDAP or SAML section that were already in the docs: Select and
Multiselect attributes keeping their type, sync-managed options, which
types keep their type when linked, the Managed by indicator, and values
cleared when the identity provider stops sending them. The note that an
attribute linked to an external source doesn't need options was removed
too. Put that text back as it was.

The correction that Ranked attributes change to Text and Hierarchical
attributes can't be linked is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Restore required channel attribute notes in the v12 changelog

The channel attributes entry in the v12.0 release notes said that users
are asked for required channel attributes when creating a channel, and
that the channels API refuses a channel missing a required value. Those
sentences were in the release notes before recent edits removed them, so
put them back. The entry's licensing wording is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* API docs: Correct access control policy schemas

The access control policy schema described fields the server never
had (display_name, description, a policy-level expression, is_active,
update_at, delete_at). It now matches the policy model: type, version,
roles, imports, scope and a rules array, with each rule's role,
actions, expression and auto_add metadata. The deprecated active
field is marked as such.

Also fix the related schemas: list and test responses return total,
the policy search accepts auto_add, actions, team_id and scope, the
expression error has no field property, the expression test and
visual AST requests take teamId, and the visual AST condition's
value_type is an integer with an attribute_type. Simulation results
gain the missing blame sources, merged_rules, the evaluation tree
node and the session id; use_active_session is marked as ignored.
The Action Search schemas list the supported resource type, actions
and denial reason. The fields autocomplete endpoint returns an array
of property fields, so its unused response schema is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* API docs: Document delegated access control permissions and parameters

The access control routes said "requires manage_system" almost
everywhere, but team admins and channel admins can call most of them
through team_id, teamId and channelId, which weren't documented either.
Each route now lists the permissions its handler checks and the
parameters it reads, with the minimum server version.

Also corrects several responses and conditions: the batch activate
endpoint returns an array and sets auto-add, the deprecated single
activate endpoint rejects cookie sessions, the channel attributes
response is a map of value arrays and is empty when channel access
indicators are off, the team policy response includes parent_policies,
policy search and simulation describe when they return 501, and Action
Search describes its real permission check and supported actions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* API docs: Document property field option routes and v12 property types

Add the property field options endpoints (list, create, update, delete)
with their option and page schemas, so large and hierarchical option
sets can be read and edited one option at a time.

Add the rank and graph field types, the session and system object
types, how fields with more than 1000 options are returned, and the
value shape for each field type. Note per-route minimum server
versions, license requirements, permissions, the value patch limits and
the access control group field limits, and correct the delta sync
boundary on the value routes, which is inclusive.

Document property_values on channel creation, which sets channel
attribute values when the channel is created.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* API docs: Deprecate custom profile attribute endpoints and fix their schemas

Mark every custom profile attributes endpoint as deprecated since v12.0,
pointing each one at its Properties API replacement. Document the 400
that field patch and delete return for fields linked to a global
attribute template, and how to create a linked attribute instead.

Fix the value shapes: the values endpoints take and return a map from
field ID to value (at most 50 entries), and listing a user's values
returns a map too; its response schema was also detached by its
indentation. Add the rank and graph field types, option rank and
parents, the managed attribute, the omitted-options markers, the
license requirement and the permission for setting another user's
values.

Declare the access control, properties, custom profile attributes and
permissions tags, so each gets a description and its own page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Plugin API docs: Correct minimum versions and document access control methods

The plugin access control methods first shipped in 11.11, the property
field option methods in 12.0, and HasPermissionToFileAction in 12.0
(with backports to 11.7.12, 11.10.3 and 11.11.1), so their minimum
server version tags now say so.

The godoc also now describes what plugin authors need to call these
methods correctly: the access_control group and the refused
custom_profile_attributes name, required field properties and field
types, value shapes per type, the no-policy decision and fail-closed
errors, plugin policy validation rules, what actingUserID is used for,
and a link to the access policy expression reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Add developer guides for the property system and plugin access control

Plugin authors had only the generated SDK reference for the property
system and attribute-based access control. Add two server plugin guides:
one on groups, fields, values, templates, options and the property
websocket events, with plugin API examples; and one on protecting
plugin-owned resources with access policies, checking decisions safely,
reusing the System Console rule editors in a web app plugin, and
respecting file upload and download policies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Reorganize attribute-based access control navigation

List the attribute-based access control pages in task order: define
user, channel and session attributes first, then system-wide, team and
channel policies, then the expression reference, with the page for the
User Attributes screen of releases before v12.0 last. The sidebar
comment now explains that order.

Also tidy a few pages found while checking the section:
- The ABAC overview links to the System Attributes settings reference.
- The session attributes operator table links to the expression
  reference.
- The legacy User attributes page shows the Entry, Enterprise and
  Enterprise Advanced badge, matching its license gate.
- The channel and team channel policy pages describe the attribute
  refresh interval as the delay before searches and rule tests see an
  attribute change, rather than a fixed refresh schedule.
- The server plugins overview links to the property system and plugin
  access control guides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Leave the v12 changelog and plugin API comments unchanged

Keep this change to the documentation pages and the REST API reference.
The v12 changelog and the plugin API comments go back to their current
text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Leave the important upgrade notes unchanged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Leave the deprecated features page unchanged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Mark custom property groups as deprecated

Tell plugin developers to put new attributes in a built-in group, and
that fields used in access control decisions must be in the
access_control group. Plugin-registered groups belong to version 1 of
the property system and are now described as deprecated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Address CodeRabbit review on ABAC and property docs

Align OpenAPI responses and tag text with existing endpoint docs, fix a
repeated word, list the missing permission in the policy steps, and nest
mmctl user attributes under mmctl user.

Co-authored-by: mattermost-code <matty-code@mattermost.com>

* Docs: Name the action decisions endpoint in the access control tag

Co-authored-by: mattermost-code <matty-code@mattermost.com>

* Docs: Address remaining CodeRabbit notes on ABAC and CPA docs

Document inherited auto-add, async policy sync, JSON null value
clearing, the 401 on PatchCPAValuesForUser, and which pre-v12
attributes are not linked.

Co-authored-by: mattermost-code <matty-code@mattermost.com>

* Docs: Address review feedback and trim API descriptions

Shorten the API descriptions this branch added. License requirements
are stated once in the properties and custom profile attributes tag
descriptions instead of on every endpoint, error conditions move into
the description of the response they produce, and operation
descriptions keep what a caller needs to make the request.

Document attrs.display_name and the access_control naming rules on
PropertyField, with the matching 422 on field create and patch. Clarify
which fields channel creation accepts in property_values. On the
end-user banners page, say that markings don't control access on their
own and that from v12.0 an access rule can restrict a channel by
classification.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Fix CPA list replacement route and discovery-mode wording

The Properties API returns 400 for a user field list without a scope,
so the replacement for listing custom profile attribute fields now
includes target_type=system. The action decisions request schema now
says that an empty or omitted actions list both select discovery mode,
matching the endpoint description.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Generalize permission policies and drop window editor guidance

Describe file upload and download as one example of permission
policies, clarify that the policy editor methods run in the plugin's
server, and remove the section on the rule editors exported on
window.Components, which the web app marks as internal plugin use only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Docs: Address review feedback on ABAC docs

- Remove EnableUserManagedAttributes documentation
- Drop mid-page license notes covered by the plan label
- Describe channel permission rules generically instead of listing actions
- Clarify that OR-combined rules apply to channel permission rules

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: mattermost-code <matty-code@mattermost.com>
2026-11-06 12:23:34 -05:00
e8c7307f42 Restrict unauthenticated webapp plugin manifests to pre-auth plugins (#39433)
* Add pre_auth webapp manifest flag and RestrictUnauthenticatedWebappPlugins setting

Unauthenticated GET /api/v4/plugins/webapp now only returns plugins whose
manifest sets webapp.pre_auth, with a trimmed manifest, when the new
PluginSettings.RestrictUnauthenticatedWebappPlugins setting is enabled. The
setting defaults to true for new installations and is turned off by a one-time
migration on existing installations.

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Add server tests for pre-auth webapp plugin filtering

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Load remaining webapp plugins after login and add admin console toggle

The login page may only receive pre-auth plugins, so performLogin now awaits a
plugin re-sync before callers navigate, and LoggedIn re-syncs as a fallback
when the plugin list was last fetched for a different session.

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Add webapp tests for post-login plugin re-sync

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Add Playwright E2E coverage for pre-auth webapp plugins

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Add system console E2E spec for the RestrictUnauthenticatedWebappPlugins toggle

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Add upgrade E2E check that existing installs keep unauthenticated webapp plugins

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Fix err shadowing lint failure in TestGetWebappPluginsUnauthenticated

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Only record the plugin fetch session after a successful fetch

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Document RestrictUnauthenticatedWebappPlugins and webapp.pre_auth

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Note that pre-auth webapp plugin filtering is available from v12.2

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Reword pre_auth version note in OpenAPI schema

Co-authored-by: Joram Wilander <joram@mattermost.com>

* Revert "Reword pre_auth version note in OpenAPI schema"

This reverts commit f5660f836b.

Co-authored-by: Joram Wilander <joram@mattermost.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-03 09:28:23 -05:00
Felipe Martin 2b3fb21fe3 Add KVListWithOptions for server-side prefix filtering in plugin KV store (#35441)
* Add KVListWithOptions to push prefix filtering into SQL

Add server-side prefix filtering for plugin KV store key listing via
KVListWithOptions across the full stack: store interface, SQL
implementation, platform service, app layer, plugin API, pluginapi
helper, and memory store.

Previously, WithPrefix in pluginapi.ListKeys performed client-side
filtering after fetching all keys. This pushes the LIKE filter into
the SQL query for efficiency, using sanitizeSearchTerm to escape
SQL wildcards.

* Add KVListWithOptions backward-compat fallback for old servers

Manually implement the KVListWithOptions RPC glue instead of generating
it so the client can detect "rpc: can't find method" errors from
pre-11.5 servers and return a proper AppError with StatusNotImplemented.
The generated version silently returns (nil, nil) on RPC errors, which
is indistinguishable from an empty result due to encoding/gob conflating
nil and empty slices. The pluginapi helper already checks for
StatusNotImplemented and falls back to KVList with client-side prefix
filtering.

* Address review findings on KVListWithOptions

- Escape backslashes in the SQL prefix instead of stripping them.
- Return an AppError for every RPC failure in the KVListWithOptions client.
- AND multiple WithPrefix options again; extra prefixes become checkers.
- Make the old-server fallback page over prefix-filtered keys and trigger
  only on StatusNotImplemented.
- Set the minimum server version to 12.2 and fix the WithChecker doc.
- Remove the unused PlatformService.KVListWithOptions.
- Route List and ListPluginKeys through their WithOptions variants.

* Tighten KV list tests from CodeRabbit nitpicks

- Assert exact keys per page in the prefix pagination store test.
- Drop unused pgHost/pgPort lookups in the KV integration test.
- Include compiler output in the plugin build failure message.

* Use snake_case mlog field key in ListPluginKeysWithOptions

* Move KVListWithOptions integration tests into regular test suites

- Cover the plugin-to-SQL path with a test_kv_list_with_options plugin run by TestBasicAPIPlugins.
- Cover the old-server RPC error mapping with a unit test against an RPC server that lacks the method.
- Remove server/integration/pluginapi and the testcontainers dependency it pulled into server/go.mod.

* Combine WithPrefix prefixes so all prefix filtering stays server-side

A second prefix ran as a checker after page and count were applied, so
pages came back short. Nested prefixes now collapse to the longest one,
and prefixes that cannot both match return no keys.

* Use a fixed batch size for the ListKeys prefix fallback scan

The scan read the caller's count keys per KVList call, so a small count
made many RPCs. It now reads 1000 keys per call, independent of count.

* Use an explicit ESCAPE '*' for the plugin KV prefix LIKE

Matches the other LIKE queries in the store and does not depend on the
default backslash escape of Postgres.

* Rename the KVListWithOptions RPC error ids to plugin.api.kv_list_with_options.*

Matches the naming of the other plugin API error ids.

* Add a benchmark for listing plugin keys with a prefix

Compares paging through KVList and filtering in Go with KVListWithOptions,
for 10k, 100k and 1M keys.

* Document KVListWithOptions and prefix listing for plugins

Expands the doc comments that generate the server plugin reference, and
adds a best-practices section on listing KV store keys with a prefix.
2026-11-01 09:37:48 +01:00
mattermost-docs-ai[bot]andmattermost-docs-ai[bot] 1ac3eb8c28 docs: AI draft for MM-71344 Plugin API: expose cluster node identity (#39401)
Co-authored-by: mattermost-docs-ai[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-10-26 07:55:39 +01:00
e97df5b6e1 [MM-70687] Expose host JSX runtimes to web app plugins (#38489)
* chore(webapp): upgrade to React 19

Bump react, react-dom and react-is to 19.2.8 across the webapp
workspaces along with their @types packages, and upgrade the React
ecosystem packages that needed newer releases to support React 19:

- @mui/material, @mui/base and @mui/styled-engine-sc
- @floating-ui/react
- react-day-picker
- @types/react-transition-group, @types/styled-components

Replace the unmaintained react-beautiful-dnd with its actively
maintained fork @hello-pangea/dnd, which is API compatible, ships its
own types and supports React 19. This drops both the
@types/react-beautiful-dnd dependency and the local patch that forced
react-redux 9 compatibility.

React 19 removes the legacy ReactDOM.render entry point, so the app now
always mounts through createRoot and the webapp side of the
EnableConcurrentReact feature flag is gone.

Apply the types-react-codemod scoped-jsx and
react-element-default-any-props presets to account for React 19 removing
the global JSX namespace and defaulting ReactElement props to unknown,
plus the manual type fixes those changes surfaced.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* chore(webapp): pin react at the workspace root so a single copy resolves

With react bumped to 19 only inside the workspaces, npm kept an older
react at the hoisted root to satisfy the peer requirements of packages
such as react-intl, leaving the app with two React copies. Declare react,
react-dom and their types at the webapp root the same way react-intl is
already declared, which is the existing pattern for singleton packages
shared across workspaces, and regenerate the lockfile.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* fix(webapp): read a tooltip child's ref from its props

React 19 moved ref into props and made element.ref throw a deprecation error on
access. Read children.props.ref instead, and apply the merged ref after spreading
the child's props so the child's own ref no longer overwrites it.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* chore(webapp): resolve a single react-is that matches React 19

react-is 18 does not recognize React 19's react.transitional.element symbol,
so every consumer that inspects elements through it - pretty-format's snapshot
serializer and styled-components among them - silently failed its checks.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* test(webapp): expect no legacy context argument on component calls

React 19 drops legacy context, so it now hands function components undefined
as the second argument instead of an empty context object.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* test(webapp): re-record snapshots for React 19 and dependency updates

The recorded output changes because React 19 keeps ref in props and omits an
empty value attribute, @hello-pangea/dnd uses data-rfd-* in place of
data-rbd-*, styled-components and MUI generate different class hashes, and the
image asset mock no longer resolves to an empty string.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* fix(webapp): keep createRoot available to plugins on window.ReactDOM

React 19 serves createRoot and hydrateRoot only from react-dom/client. Plugins
are built against React 18 and reach them through react-dom's root entry, which
react-dom 18's client.js re-exports from, so every plugin that mounts its own
root got undefined instead of a function. Because a plugin's initialize call is
not guarded, the throw took the whole web app down with it: with plugins enabled
nothing rendered at all, which failed essentially the entire e2e suite.

Exposing react-dom and react-dom/client as one object keeps both surfaces
available to plugins built against either version.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* test(e2e): wait for lazy views to mount instead of racing them

React 19 throttles revealing a Suspense boundary's content for ~300ms once a
fallback has been shown, so the first navigation to a lazily-loaded chunk
commits later than it did on React 18. Two specs sampled state within that
window:

- last_viewed_spec asserted on the team's last viewed type immediately after
  clicking Threads, but that is recorded when GlobalThreads mounts. Wait for
  the view instead, which is the condition the assertion depends on.
- channel_name_tooltips_spec reached the direct message search box via
  cy.focused(), which resolved to the button that opened the modal before
  focus moved into it. Select the input directly, as every other spec does.

Both specs pass on React 18 and React 19 with these changes.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* fix(threads): guard clear() so it cannot undo a later navigation

useThreadRouting's clear() unconditionally replaced the URL with the threads
route of the team captured when the callback was created. GlobalThreads calls it
from an effect that fires once its threads finish loading, so a navigation that
landed between the render and that effect flush was silently undone.

React 19 makes this reachable in practice: its Suspense fallback-reveal throttle
delays the lazily loaded threads view by ~300ms, widening the window enough that
switching teams right after opening Threads bounced back to the previous team.

The test file moves to .tsx so it can render the hook inside a route match.

Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>

* fix(webapp): preserve live history and React 18 plugin compatibility

* DO NOT MERGE: run React 19 StrictMode E2E discovery

Port Jesse Hallam's discovery tooling from #38235 onto the React 19
upgrade, adapting the development runtime loader and warning detector.
Force StrictMode and E2E exception detection on for this experiment.
Keep NODE_ENV=production outside React and preserve component names.

Both E2E self-tests require instrumentation in discovery mode and use a
React 19 warning. Local Playwright and Cypress self-tests, 13 diagnostic
unit tests, the production build, webapp style/types, and Playwright
checks pass. Cypress lint passes; its typecheck reports errors in
unchanged bot-account and collapsed-thread specs.

Revert this entire commit after collecting the full CI/E2E results.

* Revert "DO NOT MERGE: run React 19 StrictMode E2E discovery"

This reverts commit 564757d380.

* fix(webapp): cover upstream React 19 types and stabilize ranked policy tests

* test(webapp): increase convert GM modal test timeout

* MM-70612 Log plugin React DOM root calls

* MM-70612 Use real script elements in plugin lifecycle tests

* guard against plugin failures (sync and async); don't hang webapp

* MM-70678 Sample plugin startup failure reports at 5%

* export jsx-runtime; tests; docs

* MM-70687 Simplify JSX runtime docs to require Mattermost 12.0

* fix(webapp): deactivate superseded plugin scripts

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Jesse Hallam <lieut-data@users.noreply.github.com>
2026-09-14 16:23:30 +00:00
Christopher PoileandMattermost Build afc8def801 [MM-70573] Propagate context through plugin HTTP (#38354)
* add context-aware plugin requests; tests

* improve comments

* fix PluginHTTP stream cleanup

* close unexpected PluginHTTP test response

* synchronize plugin response writer shutdown

* linting

* address context-aware plugin HTTP review feedback

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2026-09-11 17:26:26 -04:00
Eva SarafianouandCursor b9c2bd733f docs: restore generated plugin SDK reference pages (#37788)
* docs: restore generated plugin SDK reference pages

Reimplements the Hugo-era plugingodocs/pluginjsdocs/pluginmanifestdocs
shortcode pipeline natively in Docusaurus, so the server plugin SDK,
web app plugin SDK, and manifest reference pages render full generated
content again instead of "Generated content (migrating)" placeholders.

Two new Go generators (gen-plugin-godocs, gen-plugin-manifest-docs) and
one Node generator (gen-plugin-jsdocs.mjs) read server/public/plugin,
server/public/model, and webapp/channels/src/plugins/registry.ts
directly from this monorepo and emit gitignored JSON consumed by new
PluginGoDocs/PluginGoExample/PluginJsDocs/PluginManifestDocs React
components, wired into prestart/prebuild alongside the existing
sidebar/OpenAPI generators.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: remove migration plan doc from this PR

Was a handoff/status doc for the implementing agent, not meant to ship
as part of the change itself.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: make plugin-godocs/manifest-docs builds atomic

build:plugin-godocs and build:plugin-manifest-docs redirected straight
into data/plugin-*.json, which doesn't exist on a clean checkout (the
redirection itself would fail before the generator ever ran) and, on a
subsequent failed run, would truncate a previously-good JSON file
before failing. Create data/ up front, write to a .tmp file, and only
mv it into place once the generator exits successfully.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: fix review findings in plugin doc generators

gen-plugin-manifest-docs:
- jsonFieldName now excludes unexported fields (matching encoding/json)
  and falls back to the Go field name when there's no tag or the tag's
  name component is empty (e.g. json:",omitempty"), instead of
  dropping the field entirely.
- exprTypeDocs's SelectorExpr case now resolves a qualified type only
  when its package qualifier actually points at the model package
  (checked against the declaring file's imports), instead of matching
  any x.Sel identifier by name alone regardless of which package it
  qualifies.

gen-plugin-godocs:
- The example-code loop now falls back to example.Code when
  example.Play is nil (go/doc leaves Play nil when it can't synthesize
  a whole runnable program), and propagates printer.Fprint errors
  instead of discarding them.

No output change for the current server/public/plugin or
server/public/model content — verified via a full regen.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: drop legacy-repo comment references, align jsdocs generator parser

Remove "port of the old mattermost-developer-documentation Hugo
shortcode" comments from the plugin doc generators/components now that
they're fully native to this monorepo, and switch gen-plugin-jsdocs.mjs
from the TypeScript compiler API to @typescript-eslint/typescript-estree
to match the old script's parser/shape, while keeping the more robust
reArg-declared-parameter-name and node-scoped comment-attachment logic.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: bump plugin doc generators' go.mod to go 1.26

go 1.23 was arbitrarily low; align with a current Go version. go run
auto-downloads a matching toolchain on older local installs, so this
doesn't reintroduce a dependency on server/public/go.mod's version.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: handle RestElement in gen-plugin-jsdocs parameter extraction

paramNamesFromPattern silently dropped rest parameters/destructured rest
members (e.g. (a, ...rest) or {a, ...rest}), since RestElement matched
none of its type checks. No effect on today's registry.ts output (no
rest patterns currently used there), but keeps the extraction correct if
one is ever introduced.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: simplify plugin doc generators README note

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: check stdout write errors in plugin doc generators

os.Stdout.Write's return errors were discarded, so a failed/partial
write (e.g. broken pipe, disk full) would still exit 0. Combined with
the npm scripts' > file.tmp && mv pattern, a truncated write could be
treated as a successful generation. Fatal on either write failing.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: flatten Server/Webapp plugin SDK reference sidebar nesting

server/server-reference.md and webapp/webapp-reference.md were the only
file in their respective folders, so the sidebar generator (which only
collapses a folder into a single entry when it has an index.md) rendered
them as a "Server" > "Server plugin SDK reference" category with one
child instead of one flat entry, unlike every sibling reference folder
(rest-api/index.md, bot-accounts/index.md, etc.).

Rename both to index.md to match that convention, and update the ~20
cross-referencing links (many with #anchor fragments) that pointed at
the old /reference/server/server-reference and /reference/webapp/webapp-
reference paths.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-21 15:21:21 +03:00
Eva SarafianouandCursor 1d3bbc638b feat(docs): move docs-experimental content into monorepo docs/ (#37330)
* feat(docs): move docs-experimental content into monorepo docs/

Co-authored-by: Cursor <cursoragent@cursor.com>

* Remove plan related files and comments

* Cleanup comments, remove generated files

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-02 18:42:57 +03:00