Skip to content

Commit e46ecdc

Browse files
Migrate from NPM token to OIDC authentication (v4) (#1250)
1 parent f5aa6fe commit e46ecdc

11 files changed

Lines changed: 94 additions & 67 deletions

File tree

.github/actions/npm-publish/action.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Publish release to npm
33
inputs:
44
node-version:
55
required: true
6-
npm-token:
7-
required: true
86
version:
97
required: true
108
require-build:
@@ -48,5 +46,4 @@ runs:
4846
fi
4947
npm publish --provenance --tag $TAG
5048
env:
51-
NODE_AUTH_TOKEN: ${{ inputs.npm-token }}
5249
VERSION: ${{ inputs.version }}

.github/actions/release-create/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ runs:
3333
using: composite
3434

3535
steps:
36-
- uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
36+
- uses: softprops/action-gh-release@5be0e66d93ac7ed76da52eca8bb058f665c3a5fe # pin@v2.4.2
3737
with:
3838
body: ${{ inputs.body }}
3939
name: ${{ inputs.name }}
4040
tag_name: ${{ inputs.tag }}
4141
target_commitish: ${{ inputs.commit }}
4242
draft: ${{ inputs.draft }}
4343
prerelease: ${{ inputs.prerelease }}
44+
make_latest: false
4445
fail_on_unmatched_files: ${{ inputs.fail_on_unmatched_files }}
4546
files: ${{ inputs.files }}
4647
env:

.github/workflows/npm-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ on:
1515
secrets:
1616
github-token:
1717
required: true
18-
npm-token:
19-
required: true
2018

2119
### TODO: Replace instances of './.github/actions/' w/ `auth0/dx-sdk-actions/` and append `@latest` after the common `dx-sdk-actions` repo is made public.
2220
### TODO: Also remove `get-prerelease`, `get-version`, `release-create`, `tag-create` and `tag-exists` actions from this repo's .github/actions folder once the repo is public.
@@ -26,6 +24,9 @@ jobs:
2624
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged && startsWith(github.event.pull_request.head.ref, 'release/'))
2725
runs-on: ubuntu-latest
2826
environment: release
27+
permissions:
28+
contents: write
29+
id-token: write
2930

3031
steps:
3132
# Checkout the code
@@ -70,7 +71,6 @@ jobs:
7071
require-build: ${{ inputs.require-build }}
7172
release-directory: ${{ inputs.release-directory }}
7273
version: ${{ steps.get_version.outputs.version }}
73-
npm-token: ${{ secrets.npm-token }}
7474

7575
# Create a release for the tag
7676
- uses: ./.github/actions/release-create

.github/workflows/release.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@ jobs:
3535
node-version: 18
3636
require-build: true
3737
secrets:
38-
npm-token: ${{ secrets.NPM_TOKEN }}
3938
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,18 @@ on:
66
pull_request:
77
branches:
88
- master
9+
- v4
910
push:
1011
branches:
1112
- master
13+
- v4
1214

1315
permissions:
1416
contents: read
1517

1618
concurrency:
1719
group: ${{ github.workflow }}-${{ github.ref }}
18-
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
20+
cancel-in-progress: ${{ !contains(fromJSON('["refs/heads/master", "refs/heads/v4"]'), github.ref) }}
1921

2022
jobs:
2123
build:

src/auth/database.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,17 @@ export class Database extends BaseAuthAPI {
156156
);
157157

158158
// Transform the response to ensure id field is always available
159-
const jsonResponse = await JSONApiResponse.fromResponse(response);
159+
const jsonResponse = await JSONApiResponse.fromResponse(response);
160160

161-
if (jsonResponse.data) {
162-
const data = jsonResponse.data as Record<string, unknown>;
163-
// Map _id or user_id to id
164-
if (!data.id && (data._id || data.user_id)) {
165-
data.id = data._id || data.user_id;
166-
}
167-
}
161+
if (jsonResponse.data) {
162+
const data = jsonResponse.data as Record<string, unknown>;
163+
// Map _id or user_id to id
164+
if (!data.id && (data._id || data.user_id)) {
165+
data.id = data._id || data.user_id;
166+
}
167+
}
168168

169-
return jsonResponse as JSONApiResponse<SignUpResponse>;
169+
return jsonResponse as JSONApiResponse<SignUpResponse>;
170170
}
171171

172172
/**

src/management/__generated/models/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export interface Auth0V2CaptchaConfig {
275275
/**
276276
* List of IP addresses or CIDR blocks to allowlist
277277
*/
278-
export interface BotDetectionAllowlist extends Array<BotDetectionIpAddressOrCidrBlock> {}
278+
export type BotDetectionAllowlist = Array<BotDetectionIpAddressOrCidrBlock>;
279279

280280
/**
281281
* The policy that defines how often to show CAPTCHA
@@ -6771,8 +6771,7 @@ export interface GetConnections200ResponseOneOf {
67716771
/**
67726772
*
67736773
*/
6774-
export interface GetConnectionsKeysResponseContent
6775-
extends Array<GetConnectionsKeysResponseContentInner> {}
6774+
export type GetConnectionsKeysResponseContent = Array<GetConnectionsKeysResponseContentInner>;
67766775
/**
67776776
*
67786777
*/
@@ -19972,7 +19971,7 @@ export type UserAttributeProfilePatchUserId = UserAttributeProfileUserId;
1997219971
/**
1997319972
* SAML mapping override for this strategy
1997419973
*/
19975-
export interface UserAttributeProfileSamlMapping extends Array<string> {}
19974+
export type UserAttributeProfileSamlMapping = Array<string>;
1997619975
/**
1997719976
* Strategy-specific overrides for this attribute
1997819977
*/
@@ -20186,7 +20185,7 @@ export type UserAttributeProfileUserIdOidcStrategyOverrideMapping =
2018620185
/**
2018720186
* SAML mapping for user ID
2018820187
*/
20189-
export interface UserAttributeProfileUserIdSamlMapping extends Array<string> {}
20188+
export type UserAttributeProfileUserIdSamlMapping = Array<string>;
2019020189
/**
2019120190
*
2019220191
*/

test/auth/database.test.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,35 @@ describe('Database', () => {
4242
});
4343

4444
it("should signup a user when response param for id is 'user_id'", async () => {
45-
const database = new Database(opts);
46-
const email = "test-email-1@example.com";
47-
const { data } = await database.signUp({
48-
email,
49-
password: PASSWORD,
50-
connection: "Username-Password-Authentication",
51-
});
52-
expect(data).toEqual({
53-
user_id: "test-id",
54-
id: "test-id",
55-
email_verified: false,
56-
email,
57-
});
58-
});
45+
const database = new Database(opts);
46+
const email = 'test-email-1@example.com';
47+
const { data } = await database.signUp({
48+
email,
49+
password: PASSWORD,
50+
connection: 'Username-Password-Authentication',
51+
});
52+
expect(data).toEqual({
53+
user_id: 'test-id',
54+
id: 'test-id',
55+
email_verified: false,
56+
email,
57+
});
58+
});
5959

60-
it("should signup a user when response param for id is 'id'", async () => {
61-
const database = new Database(opts);
62-
const email = "test-email-2@example.com";
63-
const { data } = await database.signUp({
64-
email,
65-
password: PASSWORD,
66-
connection: "Username-Password-Authentication",
67-
});
68-
expect(data).toEqual({
69-
id: "test-id",
70-
email_verified: false,
71-
email,
72-
});
73-
});
60+
it("should signup a user when response param for id is 'id'", async () => {
61+
const database = new Database(opts);
62+
const email = 'test-email-2@example.com';
63+
const { data } = await database.signUp({
64+
email,
65+
password: PASSWORD,
66+
connection: 'Username-Password-Authentication',
67+
});
68+
expect(data).toEqual({
69+
id: 'test-id',
70+
email_verified: false,
71+
email,
72+
});
73+
});
7474

7575
it('should require connection', async () => {
7676
const database = new Database(opts);

test/management/organizations.test.ts

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ describe('OrganizationsManager', () => {
15321532
const operation = organizations.postOrganizationClientGrants(requestParameters, requestBody);
15331533
const expectedResponse: GetOrganizationClientGrants200ResponseOneOfInner = <
15341534
GetOrganizationClientGrants200ResponseOneOfInner
1535-
>{};
1535+
>{};
15361536
const uri = `/organizations/{id}/client-grants`.replace(
15371537
'{id}',
15381538
encodeURIComponent(String(requestParameters.id))
@@ -1571,7 +1571,9 @@ describe('OrganizationsManager', () => {
15711571
};
15721572

15731573
beforeEach(() => {
1574-
request = nock(API_URL).get(`/organizations/${data.id}/discovery-domains`).reply(200, responseData);
1574+
request = nock(API_URL)
1575+
.get(`/organizations/${data.id}/discovery-domains`)
1576+
.reply(200, responseData);
15751577
});
15761578

15771579
it('should return a promise when no callback is given', (done) => {
@@ -1652,7 +1654,10 @@ describe('OrganizationsManager', () => {
16521654
});
16531655

16541656
it('should return a promise if no callback is given', (done) => {
1655-
organizations.getDiscoveryDomain(data).then(done.bind(null, null)).catch(done.bind(null, null));
1657+
organizations
1658+
.getDiscoveryDomain(data)
1659+
.then(done.bind(null, null))
1660+
.catch(done.bind(null, null));
16561661
});
16571662

16581663
it('should perform a GET request to /api/v2/organizations/:id/discovery-domains/:discovery_domain_id', (done) => {
@@ -1690,11 +1695,15 @@ describe('OrganizationsManager', () => {
16901695
});
16911696

16921697
it('should return error when id is not sent', async () => {
1693-
await expect(organizations.getDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any)).rejects.toThrow(RequiredError);
1698+
await expect(
1699+
organizations.getDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any)
1700+
).rejects.toThrow(RequiredError);
16941701
});
16951702

16961703
it('should return error when discovery_domain_id is not sent', async () => {
1697-
await expect(organizations.getDiscoveryDomain({ id: 'org_123' } as any)).rejects.toThrow(RequiredError);
1704+
await expect(organizations.getDiscoveryDomain({ id: 'org_123' } as any)).rejects.toThrow(
1705+
RequiredError
1706+
);
16981707
});
16991708
});
17001709

@@ -1724,7 +1733,10 @@ describe('OrganizationsManager', () => {
17241733
});
17251734

17261735
it('should return a promise if no callback is given', (done) => {
1727-
organizations.createDiscoveryDomain(data, body).then(done.bind(null, null)).catch(done.bind(null, null));
1736+
organizations
1737+
.createDiscoveryDomain(data, body)
1738+
.then(done.bind(null, null))
1739+
.catch(done.bind(null, null));
17281740
});
17291741

17301742
it('should pass any errors to the promise catch handler', (done) => {
@@ -1746,7 +1758,9 @@ describe('OrganizationsManager', () => {
17461758
});
17471759

17481760
it('should return error when id is not sent', async () => {
1749-
await expect(organizations.createDiscoveryDomain({} as any, body)).rejects.toThrow(RequiredError);
1761+
await expect(organizations.createDiscoveryDomain({} as any, body)).rejects.toThrow(
1762+
RequiredError
1763+
);
17501764
});
17511765

17521766
it('should pass the data in the body of the request', (done) => {
@@ -1800,7 +1814,10 @@ describe('OrganizationsManager', () => {
18001814
});
18011815

18021816
it('should return a promise if no callback is given', (done) => {
1803-
organizations.updateDiscoveryDomain(data, body).then(done.bind(null, null)).catch(done.bind(null, null));
1817+
organizations
1818+
.updateDiscoveryDomain(data, body)
1819+
.then(done.bind(null, null))
1820+
.catch(done.bind(null, null));
18041821
});
18051822

18061823
it('should pass any errors to the promise catch handler', (done) => {
@@ -1824,11 +1841,15 @@ describe('OrganizationsManager', () => {
18241841
});
18251842

18261843
it('should return error when id is not sent', async () => {
1827-
await expect(organizations.updateDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any, body)).rejects.toThrow(RequiredError);
1844+
await expect(
1845+
organizations.updateDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any, body)
1846+
).rejects.toThrow(RequiredError);
18281847
});
18291848

18301849
it('should return error when discovery_domain_id is not sent', async () => {
1831-
await expect(organizations.updateDiscoveryDomain({ id: 'org_123' } as any, body)).rejects.toThrow(RequiredError);
1850+
await expect(
1851+
organizations.updateDiscoveryDomain({ id: 'org_123' } as any, body)
1852+
).rejects.toThrow(RequiredError);
18321853
});
18331854

18341855
it('should pass the data in the body of the request', (done) => {
@@ -1872,7 +1893,9 @@ describe('OrganizationsManager', () => {
18721893
});
18731894

18741895
it('should validate empty id', async () => {
1875-
await expect(organizations.deleteDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any)).rejects.toThrow(RequiredError);
1896+
await expect(
1897+
organizations.deleteDiscoveryDomain({ discovery_domain_id: 'ord_123' } as any)
1898+
).rejects.toThrow(RequiredError);
18761899
});
18771900

18781901
it('should return a promise if no callback is given', (done) => {
@@ -1900,7 +1923,9 @@ describe('OrganizationsManager', () => {
19001923
});
19011924

19021925
it('should return error when discovery_domain_id is not sent', async () => {
1903-
await expect(organizations.deleteDiscoveryDomain({ id: 'org_123' } as any)).rejects.toThrow(RequiredError);
1926+
await expect(organizations.deleteDiscoveryDomain({ id: 'org_123' } as any)).rejects.toThrow(
1927+
RequiredError
1928+
);
19041929
});
19051930

19061931
it('should include the token in the Authorization header', (done) => {

test/management/user-attribute-profiles.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ describe('UserAttributeProfilesManager', () => {
7171
auth0_mapping: 'testUser',
7272
oidc_mapping: {
7373
mapping: 'preferred_username',
74-
display_name: 'Display Name'
75-
}
74+
display_name: 'Display Name',
75+
},
7676
},
7777
},
7878
};

0 commit comments

Comments
 (0)