Skip to content

Commit 5cf9de8

Browse files
authored
Support MRRT (EA): refresh token policies configuration (#1085)
* chore: update auth0 dependency to version 4.23.0 * test: add validation for client creation with refresh token policies
1 parent c97c897 commit 5cf9de8

File tree

4 files changed

+88
-9
lines changed

4 files changed

+88
-9
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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": "^4.22.0",
36+
"auth0": "^4.23.0",
3737
"dot-prop": "^5.3.0",
3838
"fs-extra": "^10.1.0",
3939
"js-yaml": "^4.1.0",

src/tools/auth0/handlers/clients.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1-
import { ApiResponse, Assets, PagePaginationParams } from '../../../types';
1+
import { Assets } from '../../../types';
22
import { paginate } from '../client';
33
import DefaultAPIHandler from './default';
44

5+
const multiResourceRefreshTokenPolicies = {
6+
type: ['array', 'null'],
7+
description:
8+
'A collection of policies governing multi-resource refresh token exchange (MRRT), defining how refresh tokens can be used across different resource servers',
9+
items: {
10+
type: 'object',
11+
properties: {
12+
audience: {
13+
type: 'string',
14+
},
15+
scope: {
16+
type: 'array',
17+
items: {
18+
type: 'string',
19+
},
20+
uniqueItems: true,
21+
},
22+
},
23+
required: ['audience', 'scope'],
24+
},
25+
};
26+
527
export const schema = {
628
type: 'array',
729
items: {
@@ -53,6 +75,13 @@ export const schema = {
5375
},
5476
},
5577
},
78+
refresh_token: {
79+
type: ['object', 'null'],
80+
description: 'Refresh token configuration',
81+
properties: {
82+
policies: multiResourceRefreshTokenPolicies,
83+
},
84+
},
5685
},
5786
required: ['name'],
5887
},

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,56 @@ describe('#clients handler', () => {
134134
await stageFn.apply(handler, [{ clients: [someNativeClient] }]);
135135
});
136136

137+
it('should create client with refresh token policies', async () => {
138+
const clientWithRefreshTokenPolicies = {
139+
name: 'clientWithRefreshTokenPolicies',
140+
refresh_token: {
141+
policies: [
142+
{
143+
audience: 'https://api.example.com',
144+
scope: ['read:users', 'write:users'],
145+
},
146+
{
147+
audience: 'https://other-api.example.com',
148+
scope: ['read:data'],
149+
},
150+
],
151+
},
152+
};
153+
154+
const auth0 = {
155+
clients: {
156+
create: function (data) {
157+
(() => expect(this).to.not.be.undefined)();
158+
expect(data).to.be.an('object');
159+
expect(data.name).to.equal('clientWithRefreshTokenPolicies');
160+
expect(data.refresh_token).to.be.an('object');
161+
expect(data.refresh_token.policies).to.be.an('array');
162+
expect(data.refresh_token.policies).to.deep.equal([
163+
{
164+
audience: 'https://api.example.com',
165+
scope: ['read:users', 'write:users'],
166+
},
167+
{
168+
audience: 'https://other-api.example.com',
169+
scope: ['read:data'],
170+
},
171+
]);
172+
return Promise.resolve({ data });
173+
},
174+
update: () => Promise.resolve({ data: [] }),
175+
delete: () => Promise.resolve({ data: [] }),
176+
getAll: (params) => mockPagedData(params, 'clients', []),
177+
},
178+
pool,
179+
};
180+
181+
const handler = new clients.default({ client: pageClient(auth0), config });
182+
const stageFn = Object.getPrototypeOf(handler).processChanges;
183+
184+
await stageFn.apply(handler, [{ clients: [clientWithRefreshTokenPolicies] }]);
185+
});
186+
137187
it('should get clients', async () => {
138188
const auth0 = {
139189
clients: {

0 commit comments

Comments
 (0)