Skip to content

Commit a81aa85

Browse files
authored
Merge branch 'master' into DXCDT-1261-bot-detection-support
2 parents 4262cec + 307224d commit a81aa85

4 files changed

Lines changed: 169 additions & 0 deletions

File tree

src/tools/auth0/handlers/clients.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ export const schema = {
160160
enum: ['email', 'organization_name'],
161161
},
162162
},
163+
async_approval_notification_channels: {
164+
type: ['array', 'null'],
165+
description:
166+
'An ordered array of notification channels enabled for CIBA (Client-Initiated Backchannel Authentication) requests. Channels are evaluated in the order specified.',
167+
items: {
168+
type: 'string',
169+
enum: ['guardian-push', 'email'],
170+
},
171+
},
163172
skip_non_verifiable_callback_uri_confirmation_prompt: {
164173
type: ['boolean', 'null'],
165174
description: 'Whether to skip the confirmation prompt for non-verifiable callback URIs',

test/context/directory/clients.test.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,72 @@ describe('#directory context clients', () => {
153153
context.assets.clients[1]
154154
);
155155
});
156+
157+
it('should process clients with async_approval_notification_channels', async () => {
158+
const files = {
159+
[constants.CLIENTS_DIRECTORY]: {
160+
'cibaClient.json':
161+
'{ "app_type": "spa", "name": "cibaClient", "async_approval_notification_channels": ["email", "guardian-push"] }',
162+
'channelClient.json':
163+
'{ "app_type": "native", "name": "channelClient", "async_approval_notification_channels": @@channels@@ }',
164+
},
165+
};
166+
167+
const repoDir = path.join(testDataDir, 'directory', 'clientsWithChannels');
168+
createDir(repoDir, files);
169+
170+
const config = {
171+
AUTH0_INPUT_FILE: repoDir,
172+
AUTH0_KEYWORD_REPLACE_MAPPINGS: { channels: ['guardian-push'] },
173+
};
174+
const context = new Context(config, mockMgmtClient());
175+
await context.loadAssetsFromLocal();
176+
177+
const target = [
178+
{
179+
app_type: 'native',
180+
name: 'channelClient',
181+
async_approval_notification_channels: ['guardian-push'],
182+
},
183+
{
184+
app_type: 'spa',
185+
name: 'cibaClient',
186+
async_approval_notification_channels: ['email', 'guardian-push'],
187+
},
188+
];
189+
190+
expect(context.assets.clients).to.deep.equal(target);
191+
});
192+
193+
it('should dump clients with async_approval_notification_channels', async () => {
194+
const dir = path.join(testDataDir, 'directory', 'clientsChannelsDump');
195+
cleanThenMkdir(dir);
196+
const context = new Context({ AUTH0_INPUT_FILE: dir }, mockMgmtClient());
197+
198+
context.assets.clients = [
199+
{
200+
app_type: 'spa',
201+
name: 'cibaClient',
202+
async_approval_notification_channels: ['guardian-push', 'email'],
203+
},
204+
{
205+
app_type: 'native',
206+
name: 'standardClient',
207+
},
208+
];
209+
210+
await handler.dump(context);
211+
const clientFolder = path.join(dir, constants.CLIENTS_DIRECTORY);
212+
213+
expect(loadJSON(path.join(clientFolder, 'cibaClient.json'))).to.deep.equal({
214+
app_type: 'spa',
215+
name: 'cibaClient',
216+
async_approval_notification_channels: ['guardian-push', 'email'],
217+
});
218+
219+
expect(loadJSON(path.join(clientFolder, 'standardClient.json'))).to.deep.equal({
220+
app_type: 'native',
221+
name: 'standardClient',
222+
});
223+
});
156224
});

test/context/yaml/clients.test.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,85 @@ describe('#YAML context clients', () => {
110110
fs.readFileSync(path.join(clientsFolder, 'customLoginClient_custom_login_page.html'), 'utf8')
111111
).to.deep.equal('html code');
112112
});
113+
114+
it('should process clients with async_approval_notification_channels', async () => {
115+
const dir = path.join(testDataDir, 'yaml', 'clientsWithChannels');
116+
cleanThenMkdir(dir);
117+
118+
const yaml = `
119+
clients:
120+
-
121+
name: "cibaClient"
122+
app_type: "spa"
123+
async_approval_notification_channels: ['guardian-push', 'email']
124+
-
125+
name: "emailOnlyClient"
126+
app_type: "native"
127+
async_approval_notification_channels: @@channels@@
128+
`;
129+
130+
const target = [
131+
{
132+
name: 'cibaClient',
133+
app_type: 'spa',
134+
async_approval_notification_channels: ['guardian-push', 'email'],
135+
},
136+
{
137+
name: 'emailOnlyClient',
138+
app_type: 'native',
139+
async_approval_notification_channels: ['email'],
140+
},
141+
];
142+
143+
const yamlFile = path.join(dir, 'clients.yaml');
144+
fs.writeFileSync(yamlFile, yaml);
145+
146+
const config = {
147+
AUTH0_INPUT_FILE: yamlFile,
148+
AUTH0_KEYWORD_REPLACE_MAPPINGS: { channels: ['email'] },
149+
};
150+
const context = new Context(config, mockMgmtClient());
151+
await context.loadAssetsFromLocal();
152+
153+
expect(context.assets.clients).to.deep.equal(target);
154+
});
155+
156+
it('should dump clients with async_approval_notification_channels', async () => {
157+
const dir = path.join(testDataDir, 'yaml', 'clientsChannelsDump');
158+
cleanThenMkdir(dir);
159+
const context = new Context(
160+
{ AUTH0_INPUT_FILE: path.join(dir, './test.yml') },
161+
mockMgmtClient()
162+
);
163+
164+
const clients = [
165+
{
166+
name: 'cibaClient',
167+
app_type: 'spa',
168+
async_approval_notification_channels: ['email', 'guardian-push'],
169+
},
170+
{
171+
name: 'standardClient',
172+
app_type: 'native',
173+
},
174+
];
175+
176+
const target = [
177+
{
178+
name: 'cibaClient',
179+
app_type: 'spa',
180+
async_approval_notification_channels: ['email', 'guardian-push'],
181+
},
182+
{
183+
name: 'standardClient',
184+
app_type: 'native',
185+
},
186+
];
187+
188+
context.assets.clients = clients;
189+
190+
const dumped = await handler.dump(context);
191+
192+
expect(dumped).to.deep.equal({ clients: target });
193+
});
113194
});

test/tools/auth0/handlers/clients.tests.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ describe('#clients handler', () => {
635635
organization_usage: 'require',
636636
organization_require_behavior: 'pre_login_prompt',
637637
organization_discovery_methods: ['email'],
638+
async_approval_notification_channels: ['guardian-push'],
638639
};
639640

640641
const auth0 = {
@@ -647,6 +648,7 @@ describe('#clients handler', () => {
647648
expect(data.organization_usage).to.equal('require');
648649
expect(data.organization_require_behavior).to.equal('pre_login_prompt');
649650
expect(data.organization_discovery_methods).to.deep.equal(['email']);
651+
expect(data.async_approval_notification_channels).to.deep.equal(['guardian-push']);
650652
return Promise.resolve({ data });
651653
},
652654
update: () => Promise.resolve({ data: [] }),
@@ -668,6 +670,7 @@ describe('#clients handler', () => {
668670
organization_usage: 'require',
669671
organization_require_behavior: 'pre_login_prompt',
670672
organization_discovery_methods: ['organization_name', 'email'],
673+
async_approval_notification_channels: ['email', 'guardian-push'],
671674
};
672675

673676
const auth0 = {
@@ -678,6 +681,10 @@ describe('#clients handler', () => {
678681
'organization_name',
679682
'email',
680683
]);
684+
expect(data.async_approval_notification_channels).to.deep.equal([
685+
'email',
686+
'guardian-push',
687+
]);
681688
return Promise.resolve({ data });
682689
},
683690
update: () => Promise.resolve({ data: [] }),
@@ -745,6 +752,8 @@ describe('#clients handler', () => {
745752
expect(data.organization_require_behavior).to.equal('post_login_prompt');
746753
// eslint-disable-next-line no-unused-expressions
747754
expect(data.organization_discovery_methods).to.be.null;
755+
// eslint-disable-next-line no-unused-expressions
756+
expect(data.async_approval_notification_channels).to.be.null;
748757
return Promise.resolve({ data });
749758
},
750759
delete: () => Promise.resolve({ data: [] }),
@@ -756,6 +765,7 @@ describe('#clients handler', () => {
756765
organization_usage: 'allow',
757766
organization_require_behavior: 'pre_login_prompt',
758767
organization_discovery_methods: ['email'],
768+
async_approval_notification_channels: ['guardian-push', 'email'],
759769
},
760770
]),
761771
},
@@ -772,6 +782,7 @@ describe('#clients handler', () => {
772782
name: 'My Client',
773783
organization_require_behavior: 'post_login_prompt',
774784
organization_discovery_methods: null,
785+
async_approval_notification_channels: null,
775786
},
776787
],
777788
},

0 commit comments

Comments
 (0)