@actsecurity/iam-simulate 0.1.184 → 0.1.186
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/dist/cjs/services/StsServiceAuthorizer.d.ts +7 -1
- package/dist/cjs/services/StsServiceAuthorizer.d.ts.map +1 -1
- package/dist/cjs/services/StsServiceAuthorizer.js +26 -4
- package/dist/cjs/services/StsServiceAuthorizer.js.map +1 -1
- package/dist/esm/services/StsServiceAuthorizer.d.ts +7 -1
- package/dist/esm/services/StsServiceAuthorizer.d.ts.map +1 -1
- package/dist/esm/services/StsServiceAuthorizer.js +26 -4
- package/dist/esm/services/StsServiceAuthorizer.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,9 +3,15 @@ import { type RequestResource } from '../request/requestResource.js';
|
|
|
3
3
|
import { DefaultServiceAuthorizer, type PrincipalAccountTrust } from './DefaultServiceAuthorizer.js';
|
|
4
4
|
import { type ServiceAuthorizationRequest } from './ServiceAuthorizer.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Service authorizer for AWS Security Token Service requests.
|
|
7
7
|
*/
|
|
8
8
|
export declare class StsServiceAuthorizer extends DefaultServiceAuthorizer {
|
|
9
|
+
/**
|
|
10
|
+
* Authorizes an STS request, accounting for STS actions that cannot be called anonymously.
|
|
11
|
+
*
|
|
12
|
+
* @param request the service authorization request containing the principal and policy analyses.
|
|
13
|
+
* @returns the final STS authorization analysis.
|
|
14
|
+
*/
|
|
9
15
|
authorize(request: ServiceAuthorizationRequest): RequestAnalysis;
|
|
10
16
|
/**
|
|
11
17
|
* Determines if the service trusts the principal's Account's IAM policies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StsServiceAuthorizer.d.ts","sourceRoot":"","sources":["../../../src/services/StsServiceAuthorizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACpG,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"StsServiceAuthorizer.d.ts","sourceRoot":"","sources":["../../../src/services/StsServiceAuthorizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACpG,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;AAQzE;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,wBAAwB;IAChE;;;;;OAKG;IACa,SAAS,CAAC,OAAO,EAAE,2BAA2B,GAAG,eAAe;IA8BhF;;;;;;OAMG;IACM,6BAA6B,CACpC,WAAW,EAAE,OAAO,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,eAAe,GACxB,qBAAqB;CAkBzB"}
|
|
@@ -2,20 +2,42 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StsServiceAuthorizer = void 0;
|
|
4
4
|
const DefaultServiceAuthorizer_js_1 = require("./DefaultServiceAuthorizer.js");
|
|
5
|
+
const actionsRequiringAuthenticatedPrincipal = new Set([
|
|
6
|
+
'sts:assumerole',
|
|
7
|
+
'sts:getcalleridentity',
|
|
8
|
+
'sts:getsessiontoken'
|
|
9
|
+
]);
|
|
5
10
|
/**
|
|
6
|
-
*
|
|
11
|
+
* Service authorizer for AWS Security Token Service requests.
|
|
7
12
|
*/
|
|
8
13
|
class StsServiceAuthorizer extends DefaultServiceAuthorizer_js_1.DefaultServiceAuthorizer {
|
|
14
|
+
/**
|
|
15
|
+
* Authorizes an STS request, accounting for STS actions that cannot be called anonymously.
|
|
16
|
+
*
|
|
17
|
+
* @param request the service authorization request containing the principal and policy analyses.
|
|
18
|
+
* @returns the final STS authorization analysis.
|
|
19
|
+
*/
|
|
9
20
|
authorize(request) {
|
|
10
|
-
|
|
11
|
-
|
|
21
|
+
const action = request.request.action.value();
|
|
22
|
+
const principal = request.request.principal;
|
|
23
|
+
if (action.localeCompare('sts:getcalleridentity', undefined, { sensitivity: 'accent' }) === 0 &&
|
|
24
|
+
principal.isAuthenticated()) {
|
|
12
25
|
return {
|
|
13
26
|
result: 'Allowed',
|
|
14
27
|
sameAccount: true,
|
|
15
28
|
conditions: undefined
|
|
16
29
|
};
|
|
17
30
|
}
|
|
18
|
-
|
|
31
|
+
const baseResult = super.authorize(request);
|
|
32
|
+
if (principal.isAnonymous() &&
|
|
33
|
+
actionsRequiringAuthenticatedPrincipal.has(action.toLowerCase())) {
|
|
34
|
+
return {
|
|
35
|
+
...baseResult,
|
|
36
|
+
result: 'ImplicitlyDenied',
|
|
37
|
+
conditions: undefined
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return baseResult;
|
|
19
41
|
}
|
|
20
42
|
/**
|
|
21
43
|
* Determines if the service trusts the principal's Account's IAM policies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StsServiceAuthorizer.js","sourceRoot":"","sources":["../../../src/services/StsServiceAuthorizer.ts"],"names":[],"mappings":";;;AAEA,+EAAoG;AAGpG;;GAEG;AACH,MAAa,oBAAqB,SAAQ,sDAAwB;
|
|
1
|
+
{"version":3,"file":"StsServiceAuthorizer.js","sourceRoot":"","sources":["../../../src/services/StsServiceAuthorizer.ts"],"names":[],"mappings":";;;AAEA,+EAAoG;AAGpG,MAAM,sCAAsC,GAAG,IAAI,GAAG,CAAC;IACrD,gBAAgB;IAChB,uBAAuB;IACvB,qBAAqB;CACtB,CA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sBAAsB,EAAE,CAAA;QACtE,CAAC;QAED,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAA;IAC9B,CAAC;CACF;AAlED,oDAkEC"}
|
|
@@ -3,9 +3,15 @@ import { type RequestResource } from '../request/requestResource.js';
|
|
|
3
3
|
import { DefaultServiceAuthorizer, type PrincipalAccountTrust } from './DefaultServiceAuthorizer.js';
|
|
4
4
|
import { type ServiceAuthorizationRequest } from './ServiceAuthorizer.js';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Service authorizer for AWS Security Token Service requests.
|
|
7
7
|
*/
|
|
8
8
|
export declare class StsServiceAuthorizer extends DefaultServiceAuthorizer {
|
|
9
|
+
/**
|
|
10
|
+
* Authorizes an STS request, accounting for STS actions that cannot be called anonymously.
|
|
11
|
+
*
|
|
12
|
+
* @param request the service authorization request containing the principal and policy analyses.
|
|
13
|
+
* @returns the final STS authorization analysis.
|
|
14
|
+
*/
|
|
9
15
|
authorize(request: ServiceAuthorizationRequest): RequestAnalysis;
|
|
10
16
|
/**
|
|
11
17
|
* Determines if the service trusts the principal's Account's IAM policies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StsServiceAuthorizer.d.ts","sourceRoot":"","sources":["../../../src/services/StsServiceAuthorizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACpG,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"StsServiceAuthorizer.d.ts","sourceRoot":"","sources":["../../../src/services/StsServiceAuthorizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAC5E,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAAE,KAAK,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACpG,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,wBAAwB,CAAA;AAQzE;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,wBAAwB;IAChE;;;;;OAKG;IACa,SAAS,CAAC,OAAO,EAAE,2BAA2B,GAAG,eAAe;IA8BhF;;;;;;OAMG;IACM,6BAA6B,CACpC,WAAW,EAAE,OAAO,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,QAAQ,EAAE,eAAe,GACxB,qBAAqB;CAkBzB"}
|
|
@@ -2,20 +2,42 @@ import {} from '../evaluate.js';
|
|
|
2
2
|
import {} from '../request/requestResource.js';
|
|
3
3
|
import { DefaultServiceAuthorizer } from './DefaultServiceAuthorizer.js';
|
|
4
4
|
import {} from './ServiceAuthorizer.js';
|
|
5
|
+
const actionsRequiringAuthenticatedPrincipal = new Set([
|
|
6
|
+
'sts:assumerole',
|
|
7
|
+
'sts:getcalleridentity',
|
|
8
|
+
'sts:getsessiontoken'
|
|
9
|
+
]);
|
|
5
10
|
/**
|
|
6
|
-
*
|
|
11
|
+
* Service authorizer for AWS Security Token Service requests.
|
|
7
12
|
*/
|
|
8
13
|
export class StsServiceAuthorizer extends DefaultServiceAuthorizer {
|
|
14
|
+
/**
|
|
15
|
+
* Authorizes an STS request, accounting for STS actions that cannot be called anonymously.
|
|
16
|
+
*
|
|
17
|
+
* @param request the service authorization request containing the principal and policy analyses.
|
|
18
|
+
* @returns the final STS authorization analysis.
|
|
19
|
+
*/
|
|
9
20
|
authorize(request) {
|
|
10
|
-
|
|
11
|
-
|
|
21
|
+
const action = request.request.action.value();
|
|
22
|
+
const principal = request.request.principal;
|
|
23
|
+
if (action.localeCompare('sts:getcalleridentity', undefined, { sensitivity: 'accent' }) === 0 &&
|
|
24
|
+
principal.isAuthenticated()) {
|
|
12
25
|
return {
|
|
13
26
|
result: 'Allowed',
|
|
14
27
|
sameAccount: true,
|
|
15
28
|
conditions: undefined
|
|
16
29
|
};
|
|
17
30
|
}
|
|
18
|
-
|
|
31
|
+
const baseResult = super.authorize(request);
|
|
32
|
+
if (principal.isAnonymous() &&
|
|
33
|
+
actionsRequiringAuthenticatedPrincipal.has(action.toLowerCase())) {
|
|
34
|
+
return {
|
|
35
|
+
...baseResult,
|
|
36
|
+
result: 'ImplicitlyDenied',
|
|
37
|
+
conditions: undefined
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return baseResult;
|
|
19
41
|
}
|
|
20
42
|
/**
|
|
21
43
|
* Determines if the service trusts the principal's Account's IAM policies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StsServiceAuthorizer.js","sourceRoot":"","sources":["../../../src/services/StsServiceAuthorizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,MAAM,gBAAgB,CAAA;AAC5E,OAAO,EAAwB,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAA8B,MAAM,+BAA+B,CAAA;AACpG,OAAO,EAAoC,MAAM,wBAAwB,CAAA;AAEzE;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,wBAAwB;
|
|
1
|
+
{"version":3,"file":"StsServiceAuthorizer.js","sourceRoot":"","sources":["../../../src/services/StsServiceAuthorizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,MAAM,gBAAgB,CAAA;AAC5E,OAAO,EAAwB,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,wBAAwB,EAA8B,MAAM,+BAA+B,CAAA;AACpG,OAAO,EAAoC,MAAM,wBAAwB,CAAA;AAEzE,MAAM,sCAAsC,GAAG,IAAI,GAAG,CAAC;IACrD,gBAAgB;IAChB,uBAAuB;IACvB,qBAAqB;CACtB,CAAC,CAAA;AAEF;;GAEG;AACH,MAA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