@flipdish/authorization 0.0.3-rc.1756733706 → 0.0.5-rc.1756734017
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -39
- package/configuration.ts +1 -1
- package/dist/configuration.js +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Internally the package utilizes the [axios](https://github.com/axios/axios) as i
|
|
|
7
7
|
### Example code
|
|
8
8
|
|
|
9
9
|
```typescript
|
|
10
|
-
import { AuthorizationApi, Configuration, PermissionsApi, Permissions } from '@flipdish/
|
|
10
|
+
import { AuthorizationApi, Configuration, PermissionsApi, Permissions } from '@flipdish/authorization';
|
|
11
11
|
import { describe, expect, test, it } from '@jest/globals';
|
|
12
12
|
|
|
13
13
|
const basePath = "https://api.flipdish.co/auth/";
|
|
@@ -24,7 +24,7 @@ const configuration = new Configuration({
|
|
|
24
24
|
const authorization = new AuthorizationApi(configuration);
|
|
25
25
|
const permissions = new PermissionsApi(configuration);
|
|
26
26
|
|
|
27
|
-
describe('
|
|
27
|
+
describe('Authorization Tests', () => {
|
|
28
28
|
describe('Authorisation', () => {
|
|
29
29
|
|
|
30
30
|
test('List Permissions', async () => {
|
|
@@ -39,18 +39,16 @@ describe('Authorisation Tests', () => {
|
|
|
39
39
|
expect(permissionsResponse.data.permissions).toContain(Permissions.EditAppAssets);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
describe('Authenticate and
|
|
42
|
+
describe('Authenticate and Authorize', () => {
|
|
43
43
|
it('should authenticate and authorise with a valid FD-Authorization cookie', async () => {
|
|
44
44
|
const authorizationResponse = await authorization.authenticateAndAuthorize({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
type: "Org",
|
|
53
|
-
}
|
|
45
|
+
headers: {
|
|
46
|
+
'Cookie': `FD-Authorization=${process.env.FD_AUTH_COOKIE_PROD};`,
|
|
47
|
+
},
|
|
48
|
+
action: Permissions.AnyAuditLogs,
|
|
49
|
+
resource: {
|
|
50
|
+
id: "org12345",
|
|
51
|
+
type: "Org",
|
|
54
52
|
}
|
|
55
53
|
});
|
|
56
54
|
|
|
@@ -60,19 +58,17 @@ describe('Authorisation Tests', () => {
|
|
|
60
58
|
expect(authorizationResponse.data.authentication.principal?.id).toBe("8147747");
|
|
61
59
|
});
|
|
62
60
|
|
|
63
|
-
it('should not authenticate and
|
|
61
|
+
it('should not authenticate and authorize with an invalid FD-Authorization cookie', async () => {
|
|
64
62
|
try {
|
|
65
63
|
await authorization.authenticateAndAuthorize({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
}
|
|
64
|
+
headers: {
|
|
65
|
+
'Cookie': `FD-Authorization=not-a-valid-cookie;`,
|
|
66
|
+
},
|
|
67
|
+
action: Permissions.AnyAuditLogs,
|
|
68
|
+
resource: {
|
|
69
|
+
id: "org12345",
|
|
70
|
+
type: "Org",
|
|
71
|
+
},
|
|
76
72
|
});
|
|
77
73
|
} catch (error: any) {
|
|
78
74
|
expect(error.response.status).toBe(401);
|
|
@@ -80,17 +76,15 @@ describe('Authorisation Tests', () => {
|
|
|
80
76
|
}
|
|
81
77
|
});
|
|
82
78
|
|
|
83
|
-
it('should authenticate and
|
|
79
|
+
it('should authenticate and authorize with a valid Bearer token', async () => {
|
|
84
80
|
const authorizationResponse = await authorization.authenticateAndAuthorize({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
type: "Org",
|
|
93
|
-
}
|
|
81
|
+
headers: {
|
|
82
|
+
'Authorization': `Bearer ${process.env.FLIPDISH_BEARER_TOKEN_PROD}`,
|
|
83
|
+
},
|
|
84
|
+
action: Permissions.AnyAuditLogs,
|
|
85
|
+
resource: {
|
|
86
|
+
id: "org12345",
|
|
87
|
+
type: "Org",
|
|
94
88
|
}
|
|
95
89
|
});
|
|
96
90
|
|
|
@@ -102,7 +96,7 @@ describe('Authorisation Tests', () => {
|
|
|
102
96
|
});
|
|
103
97
|
|
|
104
98
|
|
|
105
|
-
test('
|
|
99
|
+
test('Authorize', async () => {
|
|
106
100
|
let testPrincipal: any = {
|
|
107
101
|
id: "12345",
|
|
108
102
|
type: "User",
|
|
@@ -114,11 +108,9 @@ describe('Authorisation Tests', () => {
|
|
|
114
108
|
};
|
|
115
109
|
|
|
116
110
|
const authorizationResponse = await authorization.authorize({
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
resource: testResource
|
|
121
|
-
}
|
|
111
|
+
principal: testPrincipal,
|
|
112
|
+
action: Permissions.AnyAuditLogs,
|
|
113
|
+
resource: testResource
|
|
122
114
|
});
|
|
123
115
|
expect(authorizationResponse.status).toBe(200);
|
|
124
116
|
expect(authorizationResponse.data.allowed).toBe(false);
|
package/configuration.ts
CHANGED
|
@@ -100,7 +100,7 @@ export class Configuration {
|
|
|
100
100
|
|
|
101
101
|
const extraHeaders = param.useDefaultUserAgent ? {} : {
|
|
102
102
|
headers: {
|
|
103
|
-
"user-agent": "Flipdish authorization typescript SDK / 0.0.
|
|
103
|
+
"user-agent": "Flipdish authorization typescript SDK / 0.0.5-rc.1756734017"
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
|
package/dist/configuration.js
CHANGED
|
@@ -36,7 +36,7 @@ var Configuration = /** @class */ (function () {
|
|
|
36
36
|
this.serverIndex = param.serverIndex;
|
|
37
37
|
var extraHeaders = param.useDefaultUserAgent ? {} : {
|
|
38
38
|
headers: {
|
|
39
|
-
"user-agent": "Flipdish authorization typescript SDK / 0.0.
|
|
39
|
+
"user-agent": "Flipdish authorization typescript SDK / 0.0.5-rc.1756734017"
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
this.baseOptions = __assign(__assign({}, extraHeaders), param.baseOptions);
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flipdish/authorization",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5-rc.1756734017",
|
|
4
4
|
"description": "OpenAPI client for @flipdish/authorization",
|
|
5
5
|
"author": "OpenAPI-Generator Contributors",
|
|
6
6
|
"repository": {
|
|
7
|
-
"type": "git"
|
|
8
|
-
"url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
|
|
7
|
+
"type": "git"
|
|
9
8
|
},
|
|
10
9
|
"keywords": [
|
|
11
10
|
"axios",
|