Channel attributes
From Mattermost v12.0, system admins can define attributes once in System Console > System Attributes > Attribute Management, then apply those attributes to channels. Channel attributes provide structured information about a channel, such as its classification, department, region, or project.
Channel attribute values can be displayed in the channel header, the channel banner, and Channel Info. Access rules can also compare a user's attributes with a channel's attributes, so one policy can apply a different requirement to each channel. See Use channel attributes in access rules.
Apply an attribute to channels
Before a value can be assigned to a channel, the global attribute must have a Channels resource:
- Go to System Console > System Attributes > Attribute Management.
- Create a global attribute, or select an existing attribute.
- In Applies to, select Add resource, then select Channels.
- Configure how the attribute behaves:
- Changing the value controls whether a channel's value can be changed at any time, can only be raised or lowered, or can't be changed after its first value is set. Raising and lowering are available only for Ranked attributes.
- Display location > Header displays the value as a label beside the channel name.
- Display location > Banner makes the value available to the channel banner.
- Select Save.
You can select both display locations. Channel Info isn't a selectable display location because channel attributes are always available there. Attributes without values aren't displayed to channel members.
Removing the Channels resource makes every channel value stored for the attribute inaccessible. Adding the resource again creates a new channel field and doesn't restore those values.
Set channel attribute values
Users with the Manage Channel Roles permission can set channel attribute values. This includes system admins, team admins, and channel admins by default. Regular channel members can view values that have been set, but can't add or change them.
Values managed by an external integration can't be changed in Mattermost. An attribute configured so its value can't be changed becomes locked after its first value is saved.
From Channel Info
To manage values directly from a channel:
- Open the channel.
- Select the View Info icon to open Channel Info.
- In Channel Attributes, select an existing attribute to change its value, or select Add attribute to set an optional attribute that doesn't have a value.
Changes made in Channel Info are saved immediately.
From Channel Settings
To manage values together with the channel's other information:
- Select the channel name, then select Channel Settings.
- Select Info.
- In Channel Attributes, add or change values.
- Select Save.
Changes made in Channel Settings remain pending until you select Save. Channel attributes aren't available for direct message or group message channels.
Use channel attributes in access rules
From Mattermost v12.0, a membership or permission policy rule can compare a user attribute with an attribute of the channel being accessed. For example, a single system-wide policy assigned to many channels can require each user's clearance to be at least the clearance set on each channel. Rules are written in CEL, the expression language Mattermost uses for access rules:
user.attributes.Clearance >= resource.attributes.Clearance
In a rule, user.attributes.<name> is the user's value and resource.attributes.<name> is the channel's value.
Before you begin
A channel attribute can be compared only with a user attribute of the same type. For attributes with options (Select, Multiselect, Ranked, and Hierarchical), both must also come from the same global attribute, so that the options match. The simplest approach is one global attribute that applies to both users and channels:
- Go to System Console > System Attributes > Attribute Management.
- Create or select the global attribute, such as a Ranked attribute named Clearance.
- Make sure it applies to both Users and Channels. See Choose the resources an attribute applies to.
- Set a value for each user, or sync the values from your identity provider.
- Set a value on every channel the policy will be assigned to. See Set channel attribute values.
Add a channel attribute to a rule
Channel attributes are offered in the policy editors under System Console > System Attributes > Membership Policies and System Console > System Attributes > Permission Policies, and in the Membership Policy and Permissions Policy tabs of Channel Settings.
- In Simple Mode, select Add attribute, then select the user attribute, such as Clearance.
- Select an operator, such as is at least.
- Open the value menu. Under Channel attributes, select the channel attribute to compare against. The value then shows as Channel: Clearance.
- Save the policy.
The value menu lists only channel attributes that can be compared with the selected user attribute and operator. In Advanced Mode, write the comparison directly, using resource.attributes.<name>.
The following comparisons work with channel attributes:
- Text and Select attributes, with is and is not.
- Ranked attributes, with is exactly, is not, is at least, is greater than, is at most, and is less than.
- Hierarchical attributes, with covers all of, covers any of, is within all of, and is within any of.
- Multiselect attributes, with has any of and has all of.
See Channel attributes in the policy expression reference for the full rules.
Team membership policies can't use channel attributes, because teams don't have attributes. This includes system-wide policies assigned to a team.
Display attributes in the channel header
When Header is selected as a display location, each set value appears as a label beside the channel name. Select a label to open Channel Info.
If the labels don't fit in the available space, Mattermost replaces the remaining labels with a +N indicator. Open the indicator to review the remaining values or to view all attributes in Channel Info.
Multiselect attributes display one label for each selected value. Unset attributes don't appear in the header.
Display attributes in the channel banner
When Banner is selected as a display location, the attribute can contribute its value to the channel banner.
For a channel that has never customized its banner text, Mattermost creates the initial banner content from the banner attributes that have values. When multiple attributes contribute values, Mattermost separates them with a middle dot.
Users with permission to manage channel banners can customize the result by going to Channel Settings > Configuration > Channel Banner:
- Attribute references appear as tokens in the banner text editor.
- Use the attribute control to insert other channel attribute tokens.
- Combine tokens with text to add context around attribute values.
- Remove a token to stop displaying that attribute in the banner. This doesn't clear the channel attribute value.
- Use the preview to review the resolved banner before saving.
If a referenced attribute doesn't have a value, its token produces no text. Mattermost also removes adjacent single- or double-character separators, such as ·, ., /, or ?, where possible. The banner isn't displayed when no text remains after resolving its tokens.
Disabling Channel Banner suppresses the attribute-driven banner for that channel without clearing its attribute values. Enabling it again restores the saved banner template.
For more information about channel banner permissions and configuration, see Display channel banners.
Classification Markings and channel attributes
When Classification Markings are enabled, Mattermost represents Classification as a Ranked global attribute. This brings channel classification into the same resource and display model as other channel attributes.
Manage the Classification attribute
The Classification row appears in System Console > System Attributes > Attribute Management:
- Its display name, unique name, type, levels, ranks, and colors are read-only in Attribute Management.
- Select Open Classification Markings to manage presets, levels, ranks, colors, and the global classification banner under System Console > Site Configuration > Classification Markings.
- Select the Classification row to manage the resources it applies to and its channel behavior.
When Classification Markings are enabled, Mattermost adds the Channels resource to Classification and selects Banner as its default display location. A system admin can also enable Header or remove Banner.
Removing the Classification Channels resource makes the classification values assigned to channels inaccessible. Adding it again doesn't restore those values. Saving Classification Markings while the feature remains enabled doesn't automatically re-add a Channels resource that a system admin removed. Disabling and re-enabling Classification Markings creates the default Channels resource again.
Assign a classification to a channel
Classification is assigned through the channel attribute editor:
- Use Channel Info to assign a value immediately.
- Use Channel Settings > Info to assign a value and save it with the rest of the channel information.
The standalone Classification section previously available under Channel Settings > Configuration is hidden to avoid providing two controls for the same value.
Assigning a classification on its own doesn't control access to the channel, its messages, or its files. To restrict access by classification, use it in an access rule.
Use classification in access rules
Classification is a Ranked channel attribute, so a rule can compare it with a user attribute that uses the same classification levels. Classification Markings can create that user attribute for you:
- Go to System Console > Site Configuration > Classification Markings.
- Under Clearance attribute, select Enable clearance attribute, then select Save. This option is available when attribute-based access control is enabled.
Mattermost creates a Ranked user attribute named Classification clearance, with the unique name clearance, linked to the classification levels. Set each user's clearance, then add a rule that compares it with the channel's classification, either in Simple Mode or in Advanced Mode:
user.attributes.clearance >= resource.attributes.classification
Assign the policy only to channels that have a classification. A channel without one denies everyone, as described in Use channel attributes in access rules.
Classification banner behavior
When Classification has Banner selected and the channel has a classification value:
- Classification is included by default when the channel has never saved custom banner text. Existing custom banner templates aren't changed automatically.
- The selected classification level's color becomes the banner background color.
- Mattermost automatically uses a contrasting text color so the banner remains readable.
- The classification color takes precedence over a custom banner color while the Classification token remains in the banner text.
Channel banner managers can add text or other attribute tokens around Classification. Removing the Classification token from the banner doesn't clear the channel's classification value, but it does return control of the banner color to the channel. Classification can continue to appear in Channel Info and, when configured, in the channel header.
Disabling the channel banner hides all attribute-driven banner content, including Classification, without clearing the channel's attribute values or saved banner template.
Existing Classification Markings deployments
When upgrading an existing deployment:
- Existing classification levels and channel classification values are preserved.
- Classification levels are represented as Ranked attribute options.
- Existing classification banners continue to display.
- Channel admins assign and update classifications from Channel Info or Channel Settings > Info.
System admins should review the Classification Channels resource in Attribute Management before changing and saving its display settings.