Skip to content

Commit df4420c

Browse files
authored
feat: add dpop_signing_alg validation for oidc and okta connections (#1343)
feat: Enhance connections schema and tests for DPoP signing algorithms - src/tools/auth0/handlers/connections.ts: Add schema for dpop_signing_alg options - test/tools/auth0/handlers/connections.tests.js: Implement tests for dpop_signing_alg validation - package.json: Update auth0 dependency to version 5.5.0
1 parent f1f9c91 commit df4420c

3 files changed

Lines changed: 70 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"homepage": "https://github.com/auth0/auth0-deploy-cli#readme",
3434
"dependencies": {
3535
"ajv": "^6.12.6",
36-
"auth0": "^5.4.0",
36+
"auth0": "^5.5.0",
3737
"dot-prop": "^5.3.0",
3838
"fs-extra": "^10.1.0",
3939
"js-yaml": "^4.1.1",

src/tools/auth0/handlers/connections.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,24 @@ import ScimHandler from './scimHandler';
1616
import log from '../../../logger';
1717
import { Client } from './clients';
1818

19+
const connectionOptionsSchema = {
20+
type: 'object',
21+
properties: {
22+
dpop_signing_alg: {
23+
type: 'string',
24+
enum: Object.values(Management.ConnectionDpopSigningAlgEnum),
25+
},
26+
},
27+
};
28+
1929
export const schema = {
2030
type: 'array',
2131
items: {
2232
type: 'object',
2333
properties: {
2434
name: { type: 'string' },
2535
strategy: { type: 'string' },
26-
options: { type: 'object' },
36+
options: connectionOptionsSchema,
2737
enabled_clients: { type: 'array', items: { type: 'string' } },
2838
realms: { type: 'array', items: { type: 'string' } },
2939
metadata: { type: 'object' },

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import pageClient from '../../../../src/tools/auth0/client';
22

33
/* eslint-disable consistent-return */
4+
const Ajv = require('ajv');
45
const { expect } = require('chai');
56
const sinon = require('sinon');
7+
const { Management } = require('auth0');
68
const connections = require('../../../../src/tools/auth0/handlers/connections');
79
const utils = require('../../../../src/tools/utils');
810
const { mockPagedData } = require('../../../utils');
@@ -30,6 +32,62 @@ describe('#connections handler', () => {
3032
AUTH0_ALLOW_DELETE: true,
3133
};
3234

35+
describe('#connections schema', () => {
36+
it('should expose the supported dpop_signing_alg values', () => {
37+
expect(connections.schema.items.properties.options.properties.dpop_signing_alg.enum).to.deep
38+
.equal(Object.values(Management.ConnectionDpopSigningAlgEnum));
39+
});
40+
41+
it('should allow supported dpop_signing_alg values', () => {
42+
const ajv = new Ajv({ useDefaults: true, nullable: true });
43+
const assets = [
44+
{
45+
name: 'oidc-connection',
46+
strategy: 'oidc',
47+
options: {
48+
dpop_signing_alg: 'ES256',
49+
},
50+
},
51+
{
52+
name: 'okta-connection',
53+
strategy: 'okta',
54+
options: {
55+
dpop_signing_alg: 'Ed25519',
56+
},
57+
},
58+
];
59+
60+
const valid = ajv.validate(connections.schema, assets);
61+
62+
expect(valid).to.equal(true);
63+
expect(ajv.errors).to.be.null;
64+
});
65+
66+
it('should reject unsupported dpop_signing_alg values', () => {
67+
const ajv = new Ajv({ useDefaults: true, nullable: true });
68+
const assets = [
69+
{
70+
name: 'oidc-connection',
71+
strategy: 'oidc',
72+
options: {
73+
dpop_signing_alg: 'RS256',
74+
},
75+
},
76+
];
77+
78+
const valid = ajv.validate(connections.schema, assets);
79+
80+
expect(valid).to.equal(false);
81+
expect(ajv.errors).to.have.length.greaterThan(0);
82+
expect(ajv.errors[0]).to.include({
83+
keyword: 'enum',
84+
});
85+
expect(ajv.errors[0].params).to.deep.equal({
86+
allowedValues: Object.values(Management.ConnectionDpopSigningAlgEnum),
87+
});
88+
});
89+
});
90+
3391
describe('#connections validate', () => {
3492
it('should not allow same names', async () => {
3593
const handler = new connections.default({ client: {}, config });

0 commit comments

Comments
 (0)