Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e0cfef1
feat: add ABAC classification banner engine
KevLehman Jul 9, 2026
189dd75
feat: add ABAC classification banner settings, endpoint and schema docs
KevLehman Jul 9, 2026
f60109a
feat: render classification banner in ABAC rooms
KevLehman Jul 9, 2026
7228534
feat: add classification banner config builder page
KevLehman Jul 9, 2026
6062f07
chore: add changeset for ABAC classification banners
KevLehman Jul 9, 2026
c20d819
feat: move classification banner settings into their own ABAC accordion
KevLehman Jul 9, 2026
7c24288
feat: improve classification banner builder UX
KevLehman Jul 9, 2026
1deeb28
feat: dark mode for classification banner builder
KevLehman Jul 9, 2026
af44b0b
feat: align banner builder palettes with Fuselage theme tokens
KevLehman Jul 9, 2026
0020520
refactor: remove banner position option, banner always renders above …
KevLehman Jul 9, 2026
505f814
chore: sync banner builder with position removal
KevLehman Jul 9, 2026
4066893
chore: sync banner builder UX fixes
KevLehman Jul 9, 2026
bcd31d4
refactor!: rank banner values most restrictive first (index 0 = highest)
KevLehman Jul 9, 2026
b50d10a
chore: sync banner builder validation panel move
KevLehman Jul 9, 2026
f13e6ee
chore: sync banner builder persistence and copy button change
KevLehman Jul 9, 2026
647e597
chore: sync banner builder confirm modal
KevLehman Jul 9, 2026
d412646
chore: sync banner builder dialog centering fix
KevLehman Jul 9, 2026
300c0b4
refactor: make banner config a public setting and build the banner cl…
KevLehman Jul 10, 2026
1c00163
chore: sync banner builder collapsible attributes
KevLehman Jul 10, 2026
d54e8c2
chore: fix prettier formatting in banner engine spec
KevLehman Jul 10, 2026
7a8b90a
refactor: simplify banner engine surface and reuse ABAC room hooks
KevLehman Jul 10, 2026
3ba2353
refactor: style classification banner with css-in-js instead of inlin…
KevLehman Jul 10, 2026
a6e55a5
refactor: rename RoomLayout banner slot to classificationBanner
KevLehman Jul 10, 2026
26f27a0
chore: sync banner builder engine parity
KevLehman Jul 10, 2026
c28c070
docs: state id/source uniqueness in the banner config schema
KevLehman Jul 10, 2026
b056f1c
refactor: move banner docs into the builder docs modal
KevLehman Jul 10, 2026
9b094e4
refactor: extract config shape guard and fallback constants, inline r…
KevLehman Jul 10, 2026
93ddf92
refactor: move banner engine into the client and drop the vendored bu…
KevLehman Jul 10, 2026
7580128
refactor: trust the saved config, parse-only guard on the client
KevLehman Jul 10, 2026
e4607a0
style: prefer falsy length checks in banner engine
KevLehman Jul 10, 2026
32f52c6
refactor: require all config fields per schema, extract documented co…
KevLehman Jul 10, 2026
9b0d698
test: lock the banner config schema as the enforcement contract
KevLehman Jul 10, 2026
e28f700
test: document why schema spec clones via JSON round-trip
KevLehman Jul 10, 2026
a4ee987
test: validate banner schema with the shared rest-typings ajv instance
KevLehman Jul 10, 2026
3f66514
test: express schema rejection cases as plain object literals
KevLehman Jul 10, 2026
789daf1
refactor: collapse resolveColor into a single ordered find
KevLehman Jul 10, 2026
4ad9c52
feat: render unmapped values of configured attributes as raw text in …
KevLehman Jul 16, 2026
ba115cf
order
KevLehman Jul 16, 2026
0ec0412
feat: validate the classification banners config against its JSON sch…
KevLehman Jul 20, 2026
20dc820
fix: address review feedback on banner contrast, keys, and test hygiene
KevLehman Jul 21, 2026
ba380a8
fix: ui review
dougfabris Jul 23, 2026
8671417
chore: remove style values from classification schema
dougfabris Jul 23, 2026
1455f76
test: match banner locator to region role and static aria-label
KevLehman Jul 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/abac-classification-banners.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Adds classification banners to ABAC-managed rooms: admins can describe US-Government-style classification markings (levels, special access programs, releasability, colors) in a new JSON setting, and matching rooms display a colored classification banner above the room header for all members.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ const SettingsPage = () => {
)}

<Accordion>
<AccordionItem title={t('ABAC_Classification_Banners')}>
<FieldGroup>
<SettingField settingId='ABAC_Classification_Banners_Enabled' />
<SettingField settingId='ABAC_Classification_Banners_Config' />
</FieldGroup>
</AccordionItem>

<AccordionItem title={t('LDAP_DataSync_ABAC')}>
<FieldGroup>
<SettingField settingId='LDAP_Background_Sync_ABAC_Attributes' />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import type { IRoom, RoomType } from '@rocket.chat/core-typings';
import { mockAppRoot } from '@rocket.chat/mock-providers';
import type { Meta, StoryObj } from '@storybook/react';

import ClassificationBanner from './ClassificationBanner';
import type { ClassificationBannersConfig } from './lib/types';
import FakeRoomProvider from '../../../../tests/mocks/client/FakeRoomProvider';
import { createFakeLicenseInfo } from '../../../../tests/mocks/data';

const config: ClassificationBannersConfig = {
version: 1,
enabled: true,
banner: {
style: 'classic',
uppercase: true,
monospace: false,
delimiter: ' // ',
colorMode: 'highest',
fallbackText: 'NO CLASSIFICATION DATA',
fallbackColor: '#6C727A',
},
attributes: [
{
id: 'classification',
source: 'clearance.level',
label: 'Classification level',
showInBanner: true,
showLabel: false,
bannerLabel: '',
labelSeparator: '',
valueSeparator: '/',
sortAlpha: false,
groupThreshold: 0,
multipleLabel: '',
drivesColor: true,
values: [
{ source: 'TS-SCI', label: 'TOP SECRET//SCI', color: '#fce100' },
{ source: 'TS', label: 'TOP SECRET', color: '#ff8c00' },
{ source: 'S', label: 'SECRET', color: '#c8102e' },
{ source: 'C', label: 'CONFIDENTIAL', color: '#0033a0' },
{ source: 'CUI', label: 'CUI', color: '#502b85' },
{ source: 'U', label: 'UNCLASSIFIED', color: '#007a33' },
],
},
{
id: 'sar',
source: 'access.programs',
label: 'Special access programs',
showInBanner: true,
showLabel: true,
bannerLabel: 'SAR',
labelSeparator: '-',
valueSeparator: '/',
sortAlpha: true,
groupThreshold: 4,
multipleLabel: 'MULTIPLE PROGRAMS',
drivesColor: false,
values: [
{ source: 'SAP-1042', label: 'APPLES', color: '#c8102e' },
{ source: 'SAP-2271', label: 'BANANAS', color: '#ff8c00' },
{ source: 'SAP-3380', label: 'ORANGES', color: '#0033a0' },
{ source: 'SAP-4419', label: 'PEACHES', color: '#007a33' },
{ source: 'SAP-5567', label: 'GRAPES', color: '#502b85' },
],
},
{
id: 'relto',
source: 'dissem.relto',
label: 'Releasable to',
showInBanner: true,
showLabel: true,
bannerLabel: 'RELTO',
labelSeparator: ' ',
valueSeparator: '/',
sortAlpha: false,
groupThreshold: 0,
multipleLabel: '',
drivesColor: false,
values: [
{ source: 'USA', label: 'USA', color: '#0033a0' },
{ source: 'FVEY', label: 'FVEY', color: '#007a33' },
{ source: 'NATO', label: 'NATO', color: '#502b85' },
],
},
],
};

const roomAttributes = [
{ key: 'clearance.level', values: ['TS'] },
{ key: 'access.programs', values: ['SAP-1042', 'SAP-2271', 'SAP-3380'] },
{ key: 'dissem.relto', values: ['USA'] },
];

const roomArgs: Partial<IRoom> = {
_id: 'classifiedRoom',
t: 'p' as RoomType,
name: 'operation-nightingale',
fname: 'operation-nightingale',
abacAttributes: roomAttributes,
};

const withBanner = (bannerConfig: ClassificationBannersConfig, room: Partial<IRoom> = roomArgs) =>
mockAppRoot()
.withJohnDoe()
.withSetting('ABAC_Enabled', true)
.withSetting('ABAC_Classification_Banners_Enabled', true)
.withSetting('ABAC_Classification_Banners_Config', JSON.stringify(bannerConfig))
.withEndpoint('GET', '/v1/licenses.info', () => ({
license: createFakeLicenseInfo({ activeModules: ['abac'] }),
}))
.wrap((children) => <FakeRoomProvider roomOverrides={room}>{children}</FakeRoomProvider>)
.buildStoryDecorator();

export default {
component: ClassificationBanner,
parameters: {
layout: 'fullscreen',
},
decorators: [withBanner(config)],
} satisfies Meta<typeof ClassificationBanner>;

export const Classic: StoryObj<typeof ClassificationBanner> = {};

export const TopSecret: StoryObj<typeof ClassificationBanner> = {
decorators: [withBanner(config, { ...roomArgs, abacAttributes: [{ key: 'clearance.level', values: ['TS-SCI'] }] })],
};

export const Unclassified: StoryObj<typeof ClassificationBanner> = {
decorators: [withBanner(config, { ...roomArgs, abacAttributes: [{ key: 'clearance.level', values: ['U'] }] })],
};

export const GroupedPrograms: StoryObj<typeof ClassificationBanner> = {
decorators: [
withBanner(config, {
...roomArgs,
abacAttributes: [
{ key: 'clearance.level', values: ['S'] },
{ key: 'access.programs', values: ['SAP-1042', 'SAP-2271', 'SAP-3380', 'SAP-4419', 'SAP-5567'] },
],
}),
],
};

export const Fallback: StoryObj<typeof ClassificationBanner> = {
decorators: [withBanner(config, { ...roomArgs, abacAttributes: [{ key: 'unmapped.attribute', values: ['whatever'] }] })],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { Box } from '@rocket.chat/fuselage';
import { useSetting } from '@rocket.chat/ui-contexts';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';

import { buildClassificationBanner, parseClassificationBannersConfig } from './lib/engine';
import { useIsABACManagedRoom } from '../../admin/ABAC/hooks/useIsABACManagedRoom';
import { useRoom } from '../contexts/RoomContext';

const ClassificationBanner = () => {
const { t } = useTranslation();
const room = useRoom();
const isABACRoom = useIsABACManagedRoom(room);
const bannersEnabled = useSetting('ABAC_Classification_Banners_Enabled', false);
const rawConfig = useSetting('ABAC_Classification_Banners_Config', '');
const enabled = bannersEnabled && isABACRoom;

const banner = useMemo(() => {
if (!enabled) {
return null;
}

const config = parseClassificationBannersConfig(rawConfig);
return config?.enabled ? buildClassificationBanner(config, room.abacAttributes ?? []) : null;
}, [enabled, rawConfig, room.abacAttributes]);

if (!banner) {
return null;
}

return (
<Box
role='region'
aria-live='polite'
aria-label={t('ABAC_Room_Attributes')}
Comment thread
KevLehman marked this conversation as resolved.
{...(banner.monospace && { fontFamily: 'mono' })}
backgroundColor={banner.backgroundColor}
color={banner.color}
textTransform={banner.uppercase ? 'uppercase' : 'none'}
fontScale='c2'
height='x20'
display='flex'
alignItems='center'
justifyContent='center'
>
<Box is='span' withTruncatedText>
{banner.text}
</Box>
</Box>
);
};

export default ClassificationBanner;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ClassificationBanner';
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Picks a readable text color for a solid background fill.
*
* Computes each candidate's WCAG contrast ratio against the background (sRGB channels are
* gamma-decoded to linear light, then weighted by how strongly the eye perceives each: 21% red,
* 72% green, 7% blue) and keeps the higher-contrast one — so admins can pick any banner color
* and the label stays legible.
*/
export const readableTextColor = (hex: string): '#1F2329' | '#FFFFFF' => {
Comment thread
KevLehman marked this conversation as resolved.
const luminanceOf = (color: string): number => {
const [r, g, b] = [0, 2, 4].map((offset) => parseInt(color.replace('#', '').slice(offset, offset + 2), 16) / 255);
const linearize = (channel: number): number => (channel <= 0.04045 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4);
return 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b);
};

const background = luminanceOf(hex);
const contrastWith = (ink: string): number => {
const text = luminanceOf(ink);
return (Math.max(background, text) + 0.05) / (Math.min(background, text) + 0.05);
};

return contrastWith('#1F2329') >= contrastWith('#FFFFFF') ? '#1F2329' : '#FFFFFF';
};
Loading
Loading