@kensio/yulin 0.36.0 → 0.37.0
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/service/aws/factory/sim-aws-account-service-cache.d.ts.map +1 -1
- package/dist/service/aws/factory/sim-aws-account-service-cache.js +3 -0
- package/dist/service/aws/factory/sim-aws-account-service-cache.js.map +1 -1
- package/dist/service/iam/authorize/allow/sim-iam-allow-requirement.d.ts +60 -0
- package/dist/service/iam/authorize/allow/sim-iam-allow-requirement.d.ts.map +1 -0
- package/dist/service/iam/authorize/allow/sim-iam-allow-requirement.js +60 -0
- package/dist/service/iam/authorize/allow/sim-iam-allow-requirement.js.map +1 -0
- package/dist/service/iam/authorize/allow/sim-iam-allow-statements.d.ts +46 -0
- package/dist/service/iam/authorize/allow/sim-iam-allow-statements.d.ts.map +1 -0
- package/dist/service/iam/authorize/allow/sim-iam-allow-statements.js +67 -0
- package/dist/service/iam/authorize/allow/sim-iam-allow-statements.js.map +1 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-caller-account-resolver.d.ts +37 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-caller-account-resolver.d.ts.map +1 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-caller-account-resolver.js +33 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-caller-account-resolver.js.map +1 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-caller-account.d.ts +21 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-caller-account.d.ts.map +1 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-caller-account.js +2 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-caller-account.js.map +1 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-cross-account-caller.d.ts +34 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-cross-account-caller.d.ts.map +1 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-cross-account-caller.js +22 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-cross-account-caller.js.map +1 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-same-account-caller.d.ts +18 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-same-account-caller.d.ts.map +1 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-same-account-caller.js +16 -0
- package/dist/service/iam/authorize/caller-account/sim-iam-same-account-caller.js.map +1 -0
- package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.d.ts +1 -2
- package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.d.ts.map +1 -1
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts +39 -2
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts.map +1 -1
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js +42 -8
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js.map +1 -1
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context.d.ts +9 -0
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context.d.ts.map +1 -1
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context.factory.d.ts.map +1 -1
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context.factory.js +2 -0
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context.factory.js.map +1 -1
- package/dist/service/iam/authorize/identity/sim-iam-account-identity-policies.d.ts +14 -0
- package/dist/service/iam/authorize/identity/sim-iam-account-identity-policies.d.ts.map +1 -0
- package/dist/service/iam/authorize/identity/sim-iam-account-identity-policies.js +2 -0
- package/dist/service/iam/authorize/identity/sim-iam-account-identity-policies.js.map +1 -0
- package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts +24 -1
- package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts.map +1 -1
- package/dist/service/iam/authorize/sim-iam-account-auth-z.js +18 -4
- package/dist/service/iam/authorize/sim-iam-account-auth-z.js.map +1 -1
- package/dist/service/iam/authorize/sim-iam-authorizer.d.ts +11 -2
- package/dist/service/iam/authorize/sim-iam-authorizer.d.ts.map +1 -1
- package/dist/service/iam/authorize/sim-iam-authorizer.js +14 -1
- package/dist/service/iam/authorize/sim-iam-authorizer.js.map +1 -1
- package/dist/service/iam/authorize/sim-iam-decision.d.ts +17 -5
- package/dist/service/iam/authorize/sim-iam-decision.d.ts.map +1 -1
- package/dist/service/iam/authorize/sim-iam-decision.js +27 -13
- package/dist/service/iam/authorize/sim-iam-decision.js.map +1 -1
- package/dist/service/iam/command/sim-iam-command-handlers.d.ts +41 -0
- package/dist/service/iam/command/sim-iam-command-handlers.d.ts.map +1 -0
- package/dist/service/iam/command/sim-iam-command-handlers.js +42 -0
- package/dist/service/iam/command/sim-iam-command-handlers.js.map +1 -0
- package/dist/service/iam/registry/sim-iam-account-resolver.d.ts +8 -0
- package/dist/service/iam/registry/sim-iam-account-resolver.d.ts.map +1 -1
- package/dist/service/iam/registry/sim-iam-registry.d.ts +4 -0
- package/dist/service/iam/registry/sim-iam-registry.d.ts.map +1 -1
- package/dist/service/iam/registry/sim-iam-registry.js +7 -1
- package/dist/service/iam/registry/sim-iam-registry.js.map +1 -1
- package/dist/service/iam/sim-iam-account-parts.d.ts +58 -0
- package/dist/service/iam/sim-iam-account-parts.d.ts.map +1 -0
- package/dist/service/iam/sim-iam-account-parts.js +72 -0
- package/dist/service/iam/sim-iam-account-parts.js.map +1 -0
- package/dist/service/iam/sim-iam.d.ts +28 -21
- package/dist/service/iam/sim-iam.d.ts.map +1 -1
- package/dist/service/iam/sim-iam.js +42 -71
- package/dist/service/iam/sim-iam.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SimIamActionAuthorizer } from "../authorize/sim-iam-action-authorizer.js";
|
|
2
|
+
import { SimIamPolicyCommandHandlers } from "./policy/sim-iam-policy-command-handlers.js";
|
|
3
|
+
import { SimIamRoleCommandHandlers } from "./role/sim-iam-role-command-handlers.js";
|
|
4
|
+
import { SimIamUserCommandHandlers } from "./user/sim-iam-user-command-handlers.js";
|
|
5
|
+
/**
|
|
6
|
+
* The command handlers of one simulated IAM Account, grouped by resource.
|
|
7
|
+
*
|
|
8
|
+
* Every group authorizes against the same IAM and mutates the same Account
|
|
9
|
+
* state, so they are wired together here rather than one at a time in the
|
|
10
|
+
* service facade. That keeps SimIam what it should be: state maps plus
|
|
11
|
+
* delegation.
|
|
12
|
+
*/
|
|
13
|
+
export class SimIamCommandHandlers {
|
|
14
|
+
roles;
|
|
15
|
+
users;
|
|
16
|
+
policies;
|
|
17
|
+
constructor(properties) {
|
|
18
|
+
const authorizer = new SimIamActionAuthorizer({ iam: properties.iam });
|
|
19
|
+
this.roles = new SimIamRoleCommandHandlers({
|
|
20
|
+
accountId: properties.accountId,
|
|
21
|
+
roles: properties.roles,
|
|
22
|
+
background: properties.background,
|
|
23
|
+
authorizer,
|
|
24
|
+
});
|
|
25
|
+
this.users = new SimIamUserCommandHandlers({
|
|
26
|
+
accountId: properties.accountId,
|
|
27
|
+
users: properties.users,
|
|
28
|
+
credentialRegistry: properties.credentialRegistry,
|
|
29
|
+
credentialGenerator: properties.userCredentialGenerator,
|
|
30
|
+
background: properties.background,
|
|
31
|
+
authorizer,
|
|
32
|
+
});
|
|
33
|
+
this.policies = new SimIamPolicyCommandHandlers({
|
|
34
|
+
accountId: properties.accountId,
|
|
35
|
+
policies: properties.policies,
|
|
36
|
+
users: properties.users,
|
|
37
|
+
background: properties.background,
|
|
38
|
+
authorizer,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=sim-iam-command-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-iam-command-handlers.js","sourceRoot":"","sources":["../../../../src/service/iam/command/sim-iam-command-handlers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AAOnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,6CAA6C,CAAC;AAC1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AACpF,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAiBpF;;;;;;;GAOG;AACH,MAAM,OAAO,qBAAqB;IACvB,KAAK,CAA4B;IACjC,KAAK,CAA4B;IACjC,QAAQ,CAA8B;IAE/C,YAAY,UAA2C;QACrD,MAAM,UAAU,GAAG,IAAI,sBAAsB,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;QAEvE,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAyB,CAAC;YACzC,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,UAAU,EAAE,UAAU,CAAC,UAAU;YACjC,UAAU;SACX,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAyB,CAAC;YACzC,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,kBAAkB,EAAE,UAAU,CAAC,kBAAkB;YACjD,mBAAmB,EAAE,UAAU,CAAC,uBAAuB;YACvD,UAAU,EAAE,UAAU,CAAC,UAAU;YACjC,UAAU;SACX,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAA2B,CAAC;YAC9C,SAAS,EAAE,UAAU,CAAC,SAAS;YAC/B,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,UAAU,EAAE,UAAU,CAAC,UAAU;YACjC,UAAU;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -12,5 +12,13 @@ export interface SimIamAccountResolver {
|
|
|
12
12
|
* registered for the requested Account.
|
|
13
13
|
*/
|
|
14
14
|
iamForAccount(accountId: SimAwsAccountId): SimIam;
|
|
15
|
+
/**
|
|
16
|
+
* Find simulated IAM for an Account, without requiring it to exist.
|
|
17
|
+
*
|
|
18
|
+
* An Account with no IAM registered is a legitimate answer rather than a
|
|
19
|
+
* fault: a request can name a principal in an Account the simulation was
|
|
20
|
+
* never told about, and that Account grants it nothing.
|
|
21
|
+
*/
|
|
22
|
+
findIamForAccount(accountId: SimAwsAccountId): SimIam | undefined;
|
|
15
23
|
}
|
|
16
24
|
//# sourceMappingURL=sim-iam-account-resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sim-iam-account-resolver.d.ts","sourceRoot":"","sources":["../../../../src/service/iam/registry/sim-iam-account-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,aAAa,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"sim-iam-account-resolver.d.ts","sourceRoot":"","sources":["../../../../src/service/iam/registry/sim-iam-account-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,aAAa,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAAC;IAElD;;;;;;OAMG;IACH,iBAAiB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAAC;CACnE"}
|
|
@@ -26,5 +26,9 @@ export declare class SimIamRegistry implements SimIamAccountResolver {
|
|
|
26
26
|
* rely on receiving a usable account-scoped service.
|
|
27
27
|
*/
|
|
28
28
|
iamForAccount(accountId: SimAwsAccountId): SimIam;
|
|
29
|
+
/**
|
|
30
|
+
* Find the registered IAM facade belonging to an Account, if there is one.
|
|
31
|
+
*/
|
|
32
|
+
findIamForAccount(accountId: SimAwsAccountId): SimIam | undefined;
|
|
29
33
|
}
|
|
30
34
|
//# sourceMappingURL=sim-iam-registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sim-iam-registry.d.ts","sourceRoot":"","sources":["../../../../src/service/iam/registry/sim-iam-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;;;;;;GAOG;AACH,qBAAa,cAAe,YAAW,qBAAqB;IAC1D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsC;IAErE;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CActD;IAED;;;;;OAKG;IACH,aAAa,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAQhD;CACF"}
|
|
1
|
+
{"version":3,"file":"sim-iam-registry.d.ts","sourceRoot":"","sources":["../../../../src/service/iam/registry/sim-iam-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAE3E;;;;;;;GAOG;AACH,qBAAa,cAAe,YAAW,qBAAqB;IAC1D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsC;IAErE;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CActD;IAED;;;;;OAKG;IACH,aAAa,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAQhD;IAED;;OAEG;IACH,iBAAiB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAEhE;CACF"}
|
|
@@ -32,11 +32,17 @@ export class SimIamRegistry {
|
|
|
32
32
|
* rely on receiving a usable account-scoped service.
|
|
33
33
|
*/
|
|
34
34
|
iamForAccount(accountId) {
|
|
35
|
-
const iam = this.
|
|
35
|
+
const iam = this.findIamForAccount(accountId);
|
|
36
36
|
if (iam === undefined) {
|
|
37
37
|
throw new Error(`Sim IAM is not registered for Account ${accountId}`);
|
|
38
38
|
}
|
|
39
39
|
return iam;
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Find the registered IAM facade belonging to an Account, if there is one.
|
|
43
|
+
*/
|
|
44
|
+
findIamForAccount(accountId) {
|
|
45
|
+
return this.iamByAccountId.get(accountId);
|
|
46
|
+
}
|
|
41
47
|
}
|
|
42
48
|
//# sourceMappingURL=sim-iam-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sim-iam-registry.js","sourceRoot":"","sources":["../../../../src/service/iam/registry/sim-iam-registry.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IACR,cAAc,GAAG,IAAI,GAAG,EAA2B,CAAC;IAErE;;;;;;OAMG;IACH,QAAQ,CAAC,SAA0B,EAAE,GAAW;QAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEvD,IAAI,WAAW,KAAK,GAAG,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,wDAAwD,SAAS,EAAE,CACpE,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,SAA0B;QACtC,MAAM,GAAG,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"sim-iam-registry.js","sourceRoot":"","sources":["../../../../src/service/iam/registry/sim-iam-registry.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IACR,cAAc,GAAG,IAAI,GAAG,EAA2B,CAAC;IAErE;;;;;;OAMG;IACH,QAAQ,CAAC,SAA0B,EAAE,GAAW;QAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEvD,IAAI,WAAW,KAAK,GAAG,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CACb,wDAAwD,SAAS,EAAE,CACpE,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,SAA0B;QACtC,MAAM,GAAG,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAE9C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,yCAAyC,SAAS,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,SAA0B;QAC1C,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type BackgroundScheduler } from "../../util/background/background.js";
|
|
2
|
+
import type { SimAwsAccountId } from "../aws/sim-aws-account.js";
|
|
3
|
+
import type { SimAwsAccountRegionScope } from "../aws/sim-aws-account-region-scope.js";
|
|
4
|
+
import { SimIamAccountAuthZ } from "./authorize/sim-iam-account-auth-z.js";
|
|
5
|
+
import type { SimIamInterServiceAuthZ } from "./authorize/sim-iam-inter-service-auth-z.js";
|
|
6
|
+
import { SimIamCommandHandlers } from "./command/sim-iam-command-handlers.js";
|
|
7
|
+
import { SimIamCredentialRegistry } from "./credential/sim-iam-credential-registry.js";
|
|
8
|
+
import { type SimIamSessionCredentialGenerator } from "./credential/session/sim-iam-session-cred-gen.js";
|
|
9
|
+
import { SimIamSessionManager } from "./credential/session/sim-iam-session-manager.js";
|
|
10
|
+
import { type SimIamUserCredentialGenerator } from "./credential/user/sim-iam-user-credential-generator.js";
|
|
11
|
+
import type { SimIamManagedPolicy } from "./policy/sim-iam-policy.js";
|
|
12
|
+
import type { SimIamAccountResolver } from "./registry/sim-iam-account-resolver.js";
|
|
13
|
+
import type { SimIamRole, SimIamRoleName } from "./role/sim-iam-role.js";
|
|
14
|
+
import type { SimIamUser, SimIamUsername } from "./user/sim-iam-user.js";
|
|
15
|
+
export interface SimIamProperties {
|
|
16
|
+
readonly accountRegionScope?: SimAwsAccountRegionScope;
|
|
17
|
+
readonly background?: BackgroundScheduler;
|
|
18
|
+
readonly credentialRegistry?: SimIamCredentialRegistry;
|
|
19
|
+
readonly sessionCredentialGenerator?: SimIamSessionCredentialGenerator;
|
|
20
|
+
readonly userCredentialGenerator?: SimIamUserCredentialGenerator;
|
|
21
|
+
/**
|
|
22
|
+
* Resolves the IAM of other Accounts in the same simulation.
|
|
23
|
+
*
|
|
24
|
+
* A cross-Account request is decided in both Accounts, so deciding one needs
|
|
25
|
+
* a way to reach the caller's own Account. A standalone SimIam has no
|
|
26
|
+
* simulation around it and so leaves this out.
|
|
27
|
+
*/
|
|
28
|
+
readonly iamResolver?: SimIamAccountResolver;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The state and collaborators of one simulated IAM Account.
|
|
32
|
+
*
|
|
33
|
+
* SimIam is the SDK-facing facade. This class is what it is a facade over: the
|
|
34
|
+
* Account's stored Roles, Users and Policies, the credential registry and
|
|
35
|
+
* session manager, and the authorization and command-handling collaborators
|
|
36
|
+
* that work on them. Keeping the construction and defaulting rules here leaves
|
|
37
|
+
* the facade as state plus delegation.
|
|
38
|
+
*/
|
|
39
|
+
export declare class SimIamAccountParts {
|
|
40
|
+
readonly accountId: SimAwsAccountId;
|
|
41
|
+
readonly background: BackgroundScheduler;
|
|
42
|
+
readonly credentials: SimIamCredentialRegistry;
|
|
43
|
+
readonly sessionManager: SimIamSessionManager;
|
|
44
|
+
readonly accountAuthZ: SimIamAccountAuthZ;
|
|
45
|
+
readonly policies: Map<`arn:aws:${string}:${string}:${string}:${string}/${string}`, SimIamManagedPolicy>;
|
|
46
|
+
readonly roles: Map<SimIamRoleName, SimIamRole>;
|
|
47
|
+
readonly users: Map<SimIamUsername, SimIamUser>;
|
|
48
|
+
private readonly userCredentialGenerator;
|
|
49
|
+
constructor(properties: SimIamProperties);
|
|
50
|
+
/**
|
|
51
|
+
* Make the command handlers for this Account.
|
|
52
|
+
*
|
|
53
|
+
* IAM authorizes its own control-plane commands, so the handlers need the
|
|
54
|
+
* service facade the commands arrive at and cannot be built before it.
|
|
55
|
+
*/
|
|
56
|
+
commandHandlers(iam: SimIamInterServiceAuthZ): SimIamCommandHandlers;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=sim-iam-account-parts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-iam-account-parts.d.ts","sourceRoot":"","sources":["../../../src/service/iam/sim-iam-account-parts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAEvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO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CAAyC;IACvD,QAAQ,CAAC,KAAK,kCAAyC;IAEvD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAgC;IAExE,YAAY,UAAU,EAAE,gBAAgB,EAgCvC;IAED;;;;;OAKG;IACH,eAAe,CAAC,GAAG,EAAE,uBAAuB,GAAG,qBAAqB,CAWnE;CACF"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { BackgroundTasks, } from "../../util/background/background.js";
|
|
2
|
+
import { simAwsAccountRegionScopeFactory } from "../aws/sim-aws-account-region-scope.factory.js";
|
|
3
|
+
import { SimIamAccountAuthZ } from "./authorize/sim-iam-account-auth-z.js";
|
|
4
|
+
import { SimIamCommandHandlers } from "./command/sim-iam-command-handlers.js";
|
|
5
|
+
import { SimIamCredentialRegistry } from "./credential/sim-iam-credential-registry.js";
|
|
6
|
+
import { SimIamRandomSessionCredentialGenerator, } from "./credential/session/sim-iam-session-cred-gen.js";
|
|
7
|
+
import { SimIamSessionManager } from "./credential/session/sim-iam-session-manager.js";
|
|
8
|
+
import { SimIamRandomUserCredentialGenerator, } from "./credential/user/sim-iam-user-credential-generator.js";
|
|
9
|
+
/**
|
|
10
|
+
* The state and collaborators of one simulated IAM Account.
|
|
11
|
+
*
|
|
12
|
+
* SimIam is the SDK-facing facade. This class is what it is a facade over: the
|
|
13
|
+
* Account's stored Roles, Users and Policies, the credential registry and
|
|
14
|
+
* session manager, and the authorization and command-handling collaborators
|
|
15
|
+
* that work on them. Keeping the construction and defaulting rules here leaves
|
|
16
|
+
* the facade as state plus delegation.
|
|
17
|
+
*/
|
|
18
|
+
export class SimIamAccountParts {
|
|
19
|
+
accountId;
|
|
20
|
+
background;
|
|
21
|
+
credentials;
|
|
22
|
+
sessionManager;
|
|
23
|
+
accountAuthZ;
|
|
24
|
+
policies = new Map();
|
|
25
|
+
roles = new Map();
|
|
26
|
+
users = new Map();
|
|
27
|
+
userCredentialGenerator;
|
|
28
|
+
constructor(properties) {
|
|
29
|
+
const { accountRegionScope = simAwsAccountRegionScopeFactory.make(), background = new BackgroundTasks(), sessionCredentialGenerator = new SimIamRandomSessionCredentialGenerator(), userCredentialGenerator = new SimIamRandomUserCredentialGenerator(), } = properties;
|
|
30
|
+
// The scheduler is this simulation's clock, so session expiry is judged in
|
|
31
|
+
// the same time as every other simulated timestamp.
|
|
32
|
+
const credentialRegistry = properties.credentialRegistry ??
|
|
33
|
+
new SimIamCredentialRegistry({ clock: background });
|
|
34
|
+
this.accountId = accountRegionScope.accountId;
|
|
35
|
+
this.background = background;
|
|
36
|
+
this.credentials = credentialRegistry;
|
|
37
|
+
this.userCredentialGenerator = userCredentialGenerator;
|
|
38
|
+
this.sessionManager = new SimIamSessionManager({
|
|
39
|
+
accountId: this.accountId,
|
|
40
|
+
roles: this.roles,
|
|
41
|
+
credentialRegistry,
|
|
42
|
+
credentialGenerator: sessionCredentialGenerator,
|
|
43
|
+
});
|
|
44
|
+
this.accountAuthZ = new SimIamAccountAuthZ({
|
|
45
|
+
accountId: this.accountId,
|
|
46
|
+
policies: this.policies,
|
|
47
|
+
roles: this.roles,
|
|
48
|
+
users: this.users,
|
|
49
|
+
credentialIdentityResolver: credentialRegistry,
|
|
50
|
+
iamResolver: properties.iamResolver,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Make the command handlers for this Account.
|
|
55
|
+
*
|
|
56
|
+
* IAM authorizes its own control-plane commands, so the handlers need the
|
|
57
|
+
* service facade the commands arrive at and cannot be built before it.
|
|
58
|
+
*/
|
|
59
|
+
commandHandlers(iam) {
|
|
60
|
+
return new SimIamCommandHandlers({
|
|
61
|
+
accountId: this.accountId,
|
|
62
|
+
policies: this.policies,
|
|
63
|
+
roles: this.roles,
|
|
64
|
+
users: this.users,
|
|
65
|
+
credentialRegistry: this.credentials,
|
|
66
|
+
userCredentialGenerator: this.userCredentialGenerator,
|
|
67
|
+
background: this.background,
|
|
68
|
+
iam,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=sim-iam-account-parts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sim-iam-account-parts.js","sourceRoot":"","sources":["../../../src/service/iam/sim-iam-account-parts.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,GAChB,MAAM,qCAAqC,CAAC;AAI7C,OAAO,EAAE,+BAA+B,EAAE,MAAM,gDAAgD,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAE3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,OAAO,EACL,sCAAsC,GAEvC,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EACL,mCAAmC,GAEpC,MAAM,wDAAwD,CAAC;AAuBhE;;;;;;;;GAQG;AACH,MAAM,OAAO,kBAAkB;IACpB,SAAS,CAAkB;IAC3B,UAAU,CAAsB;IAChC,WAAW,CAA2B;IACtC,cAAc,CAAuB;IACrC,YAAY,CAAqB;IAEjC,QAAQ,GAAG,IAAI,GAAG,EAA+B,CAAC;IAClD,KAAK,GAAG,IAAI,GAAG,EAA8B,CAAC;IAC9C,KAAK,GAAG,IAAI,GAAG,EAA8B,CAAC;IAEtC,uBAAuB,CAAgC;IAExE,YAAY,UAA4B;QACtC,MAAM,EACJ,kBAAkB,GAAG,+BAA+B,CAAC,IAAI,EAAE,EAC3D,UAAU,GAAG,IAAI,eAAe,EAAE,EAClC,0BAA0B,GAAG,IAAI,sCAAsC,EAAE,EACzE,uBAAuB,GAAG,IAAI,mCAAmC,EAAE,GACpE,GAAG,UAAU,CAAC;QAEf,2EAA2E;QAC3E,oDAAoD;QACpD,MAAM,kBAAkB,GACtB,UAAU,CAAC,kBAAkB;YAC7B,IAAI,wBAAwB,CAAC,EAA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|
import type { SimCreatePolicyCommand, SimCreatePolicyCommandOutput } from "./command/policy/create-policy/create-policy.command.js";
|
|
3
4
|
import type { SimIamManagedPolicy } from "./policy/sim-iam-policy.js";
|
|
4
5
|
import type { SimGetPolicyCommand, SimGetPolicyCommandOutput } from "./command/policy/get-policy/get-policy.command.js";
|
|
5
6
|
import type { SimListPoliciesCommand, SimListPoliciesCommandOutput } from "./command/policy/list-policies/list-policies.command.js";
|
|
6
|
-
import { type BackgroundScheduler } from "../../util/background/background.js";
|
|
7
7
|
import type { SimCreateRoleCommand, SimCreateRoleCommandOutput } from "./command/role/create-role/create-role.command.js";
|
|
8
8
|
import type { SimGetRoleCommand, SimGetRoleCommandOutput } from "./command/role/get-role/get-role.command.js";
|
|
9
9
|
import type { SimIamRole, SimIamRoleName } from "./role/sim-iam-role.js";
|
|
@@ -12,24 +12,19 @@ import type { SimIamAuthorizationInput } from "./authorize/context/sim-iam-auth-
|
|
|
12
12
|
import type { SimIamPolicyDecision } from "./authorize/sim-iam-decision.js";
|
|
13
13
|
import type { SimPutRolePolicyCommand, SimPutRolePolicyCommandOutput } from "./command/policy/put-role-policy/put-role-policy.command.js";
|
|
14
14
|
import type { SimAttachRolePolicyCommand, SimAttachRolePolicyCommandOutput } from "./command/role/attach-role-policy/attach-role-policy.command.js";
|
|
15
|
-
import { SimIamCredentialRegistry } from "./credential/sim-iam-credential-registry.js";
|
|
16
|
-
import { type SimIamSessionCredentialGenerator } from "./credential/session/sim-iam-session-cred-gen.js";
|
|
17
|
-
import { SimIamSessionManager } from "./credential/session/sim-iam-session-manager.js";
|
|
18
|
-
import { type SimIamUserCredentialGenerator } from "./credential/user/sim-iam-user-credential-generator.js";
|
|
19
15
|
import type { SimCreateUserCommand, SimCreateUserCommandOutput } from "./command/user/create-user/create-user.command.js";
|
|
20
16
|
import type { SimCreateAccessKeyCommand, SimCreateAccessKeyCommandOutput } from "./command/user/create-access-key/create-access-key.command.js";
|
|
21
17
|
import type { SimIamRequestOptions } from "./command/sim-iam-request-options.js";
|
|
22
18
|
import type { SimPutUserPolicyCommand, SimPutUserPolicyCommandOutput } from "./command/policy/put-user-policy/put-user-policy.command.js";
|
|
23
19
|
import type { SimCfnServiceResourceFactory } from "../cloudformation/resource/factory/sim-cfn-resource-factory.type.js";
|
|
24
20
|
import type { SimIamInterServiceAuthZ } from "./authorize/sim-iam-inter-service-auth-z.js";
|
|
21
|
+
import type { SimIamAccountIdentityPolicies } from "./authorize/identity/sim-iam-account-identity-policies.js";
|
|
22
|
+
import type { SimIamAuthZPolicySource } from "./authorize/context/sim-iam-auth-z-context.js";
|
|
23
|
+
import type { SimAwsPrincipal } from "../aws/caller/sim-aws-caller.js";
|
|
25
24
|
import type { SimSdkCommandRouter } from "../../sdk/index.js";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
readonly credentialRegistry?: SimIamCredentialRegistry;
|
|
30
|
-
readonly sessionCredentialGenerator?: SimIamSessionCredentialGenerator;
|
|
31
|
-
readonly userCredentialGenerator?: SimIamUserCredentialGenerator;
|
|
32
|
-
}
|
|
25
|
+
import type { SimIamCredentialRegistry } from "./credential/sim-iam-credential-registry.js";
|
|
26
|
+
import type { SimIamSessionManager } from "./credential/session/sim-iam-session-manager.js";
|
|
27
|
+
import { type SimIamProperties } from "./sim-iam-account-parts.js";
|
|
33
28
|
/**
|
|
34
29
|
* Simulated IAM service facade. Handles SDK commands. Emulates AWS behaviour
|
|
35
30
|
* and state.
|
|
@@ -38,20 +33,23 @@ interface SimIamProperties {
|
|
|
38
33
|
* scope for consistency with the other service factories, but memoises one
|
|
39
34
|
* service facade per Account.
|
|
40
35
|
*/
|
|
41
|
-
export declare class SimIam implements SimIamInterServiceAuthZ {
|
|
36
|
+
export declare class SimIam implements SimIamInterServiceAuthZ, SimIamAccountIdentityPolicies {
|
|
37
|
+
/**
|
|
38
|
+
* The simulated AWS Account this IAM belongs to.
|
|
39
|
+
*
|
|
40
|
+
* A standalone SimIam generates one, so this is how a test naming its own
|
|
41
|
+
* principals finds out which Account they should belong to.
|
|
42
|
+
*/
|
|
43
|
+
readonly accountId: SimAwsAccountId;
|
|
42
44
|
/**
|
|
43
45
|
* Manage temporary sessions belonging to this simulated IAM Account.
|
|
44
46
|
*/
|
|
45
47
|
readonly sessionManager: SimIamSessionManager;
|
|
46
48
|
readonly credentials: SimIamCredentialRegistry;
|
|
47
|
-
readonly policies: Map
|
|
49
|
+
readonly policies: Map<SimArn, SimIamManagedPolicy>;
|
|
48
50
|
readonly roles: Map<SimIamRoleName, SimIamRole>;
|
|
49
|
-
private readonly users;
|
|
50
|
-
private readonly background;
|
|
51
51
|
private readonly cfnFactory;
|
|
52
|
-
private readonly
|
|
53
|
-
private readonly userCommands;
|
|
54
|
-
private readonly policyCommands;
|
|
52
|
+
private readonly commands;
|
|
55
53
|
private readonly accountAuthZ;
|
|
56
54
|
private readonly sdkRouter;
|
|
57
55
|
constructor(properties?: SimIamProperties);
|
|
@@ -60,6 +58,16 @@ export declare class SimIam implements SimIamInterServiceAuthZ {
|
|
|
60
58
|
* request caller. An omitted caller defaults to the Account root principal.
|
|
61
59
|
*/
|
|
62
60
|
authorize(input: SimIamAuthorizationInput): SimIamPolicyDecision;
|
|
61
|
+
/**
|
|
62
|
+
* Identity-based policies this Account applies to one of its own principals.
|
|
63
|
+
*
|
|
64
|
+
* This is how another Account's IAM asks this Account what it grants a
|
|
65
|
+
* principal of its own, which is the caller's side of a cross-Account
|
|
66
|
+
* request. Real AWS requires that side to allow the action as well as the
|
|
67
|
+
* resource's own resource-based policy.
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
identityPolicySourcesFor(principal: SimAwsPrincipal): readonly SimIamAuthZPolicySource[];
|
|
63
71
|
/**
|
|
64
72
|
* Handle a Create Policy Command from the SDK.
|
|
65
73
|
*/
|
|
@@ -113,5 +121,4 @@ export declare class SimIam implements SimIamInterServiceAuthZ {
|
|
|
113
121
|
*/
|
|
114
122
|
sdkCommandRouter(): SimSdkCommandRouter;
|
|
115
123
|
}
|
|
116
|
-
export {};
|
|
117
124
|
//# sourceMappingURL=sim-iam.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sim-iam.d.ts","sourceRoot":"","sources":["../../../src/service/iam/sim-iam.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sim-iam.d.ts","sourceRoot":"","sources":["../../../src/service/iam/sim-iam.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,yDAAyD,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,mDAAmD,CAAC;AAC3D,OAAO,KAAK,EACV,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,yDAAyD,CAAC;AACjE,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC3B,MAAM,mDAAmD,CAAC;AAC3D,OAAO,KAAK,EACV,iBAAiB,EACjB,uBAAuB,EACxB,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EACV,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,iDAAiD,CAAC;AACzD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AACtG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EACV,uBAAuB,EACvB,6BAA6B,EAC9B,MAAM,6DAA6D,CAAC;AACrE,OAAO,KAAK,EACV,0BAA0B,EAC1B,gCAAgC,EACjC,MAAM,iEAAiE,CAAC;A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C1B,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CAElC;IAED;;OAEG;IACG,SAAS,CACb,OAAO,EAAE,mBAAmB,EAC5B,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,yBAAyB,CAAC,CAEpC;IAED;;OAEG;IACG,UAAU,CACd,OAAO,EAAE,oBAAoB,EAC7B,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,0BAA0B,CAAC,CAErC;IAED;;OAEG;IACG,eAAe,CACnB,OAAO,EAAE,yBAAyB,EAClC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,+BAA+B,CAAC,CAE1C;IAED;;OAEG;IACH,kBAAkB,IAAI,4BAA4B,CAEjD;IAED;;OAEG;IACH,gBAAgB,IAAI,mBAAmB,CAEtC;CACF"}
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import { simAwsAccountRegionScopeFactory } from "../aws/sim-aws-account-region-scope.factory.js";
|
|
2
|
-
import { BackgroundTasks, } from "../../util/background/background.js";
|
|
3
|
-
import { SimIamRoleCommandHandlers } from "./command/role/sim-iam-role-command-handlers.js";
|
|
4
|
-
import { SimIamCredentialRegistry } from "./credential/sim-iam-credential-registry.js";
|
|
5
|
-
import { SimIamRandomSessionCredentialGenerator, } from "./credential/session/sim-iam-session-cred-gen.js";
|
|
6
|
-
import { SimIamSessionManager } from "./credential/session/sim-iam-session-manager.js";
|
|
7
|
-
import { SimIamRandomUserCredentialGenerator, } from "./credential/user/sim-iam-user-credential-generator.js";
|
|
8
|
-
import { SimIamUserCommandHandlers } from "./command/user/sim-iam-user-command-handlers.js";
|
|
9
|
-
import { SimIamPolicyCommandHandlers } from "./command/policy/sim-iam-policy-command-handlers.js";
|
|
10
|
-
import { SimIamActionAuthorizer } from "./authorize/sim-iam-action-authorizer.js";
|
|
11
|
-
import { SimIamAccountAuthZ } from "./authorize/sim-iam-account-auth-z.js";
|
|
12
1
|
import { SimIamCloudFormationResourceFactory } from "./cfn/sim-cfn-iam-resource-factory.js";
|
|
13
2
|
import { SimIamSdkCommandRouter } from "./sdk/sim-iam-sdk-command-router.js";
|
|
3
|
+
import { SimIamAccountParts, } from "./sim-iam-account-parts.js";
|
|
14
4
|
/**
|
|
15
5
|
* Simulated IAM service facade. Handles SDK commands. Emulates AWS behaviour
|
|
16
6
|
* and state.
|
|
@@ -20,65 +10,34 @@ import { SimIamSdkCommandRouter } from "./sdk/sim-iam-sdk-command-router.js";
|
|
|
20
10
|
* service facade per Account.
|
|
21
11
|
*/
|
|
22
12
|
export class SimIam {
|
|
13
|
+
/**
|
|
14
|
+
* The simulated AWS Account this IAM belongs to.
|
|
15
|
+
*
|
|
16
|
+
* A standalone SimIam generates one, so this is how a test naming its own
|
|
17
|
+
* principals finds out which Account they should belong to.
|
|
18
|
+
*/
|
|
19
|
+
accountId;
|
|
23
20
|
/**
|
|
24
21
|
* Manage temporary sessions belonging to this simulated IAM Account.
|
|
25
22
|
*/
|
|
26
23
|
sessionManager;
|
|
27
24
|
credentials;
|
|
28
|
-
policies
|
|
29
|
-
roles
|
|
30
|
-
users = new Map();
|
|
31
|
-
background;
|
|
25
|
+
policies;
|
|
26
|
+
roles;
|
|
32
27
|
cfnFactory;
|
|
33
|
-
|
|
34
|
-
userCommands;
|
|
35
|
-
policyCommands;
|
|
28
|
+
commands;
|
|
36
29
|
accountAuthZ;
|
|
37
30
|
sdkRouter = new SimIamSdkCommandRouter(this);
|
|
38
31
|
constructor(properties = {}) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
accountId: accountRegionScope.accountId,
|
|
48
|
-
roles: this.roles,
|
|
49
|
-
credentialRegistry,
|
|
50
|
-
credentialGenerator: sessionCredentialGenerator,
|
|
51
|
-
});
|
|
32
|
+
const parts = new SimIamAccountParts(properties);
|
|
33
|
+
this.accountId = parts.accountId;
|
|
34
|
+
this.policies = parts.policies;
|
|
35
|
+
this.roles = parts.roles;
|
|
36
|
+
this.credentials = parts.credentials;
|
|
37
|
+
this.sessionManager = parts.sessionManager;
|
|
38
|
+
this.accountAuthZ = parts.accountAuthZ;
|
|
39
|
+
this.commands = parts.commandHandlers(this);
|
|
52
40
|
this.cfnFactory = new SimIamCloudFormationResourceFactory(this);
|
|
53
|
-
this.accountAuthZ = new SimIamAccountAuthZ({
|
|
54
|
-
accountId: accountRegionScope.accountId,
|
|
55
|
-
policies: this.policies,
|
|
56
|
-
roles: this.roles,
|
|
57
|
-
users: this.users,
|
|
58
|
-
credentialIdentityResolver: credentialRegistry,
|
|
59
|
-
});
|
|
60
|
-
const authorizer = new SimIamActionAuthorizer({ iam: this });
|
|
61
|
-
this.roleCommands = new SimIamRoleCommandHandlers({
|
|
62
|
-
accountId: accountRegionScope.accountId,
|
|
63
|
-
roles: this.roles,
|
|
64
|
-
background: this.background,
|
|
65
|
-
authorizer,
|
|
66
|
-
});
|
|
67
|
-
this.userCommands = new SimIamUserCommandHandlers({
|
|
68
|
-
accountId: accountRegionScope.accountId,
|
|
69
|
-
users: this.users,
|
|
70
|
-
credentialRegistry,
|
|
71
|
-
credentialGenerator: userCredentialGenerator,
|
|
72
|
-
background: this.background,
|
|
73
|
-
authorizer,
|
|
74
|
-
});
|
|
75
|
-
this.policyCommands = new SimIamPolicyCommandHandlers({
|
|
76
|
-
accountId: accountRegionScope.accountId,
|
|
77
|
-
policies: this.policies,
|
|
78
|
-
users: this.users,
|
|
79
|
-
background: this.background,
|
|
80
|
-
authorizer,
|
|
81
|
-
});
|
|
82
41
|
}
|
|
83
42
|
/**
|
|
84
43
|
* Evaluate an IAM authorization attempt against policies relevant to the
|
|
@@ -87,71 +46,83 @@ export class SimIam {
|
|
|
87
46
|
authorize(input) {
|
|
88
47
|
return this.accountAuthZ.authorize(input);
|
|
89
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Identity-based policies this Account applies to one of its own principals.
|
|
51
|
+
*
|
|
52
|
+
* This is how another Account's IAM asks this Account what it grants a
|
|
53
|
+
* principal of its own, which is the caller's side of a cross-Account
|
|
54
|
+
* request. Real AWS requires that side to allow the action as well as the
|
|
55
|
+
* resource's own resource-based policy.
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
identityPolicySourcesFor(principal) {
|
|
59
|
+
return this.accountAuthZ.identityPolicySourcesFor(principal);
|
|
60
|
+
}
|
|
90
61
|
/**
|
|
91
62
|
* Handle a Create Policy Command from the SDK.
|
|
92
63
|
*/
|
|
93
64
|
async createPolicy(command, options) {
|
|
94
|
-
return await this.
|
|
65
|
+
return await this.commands.policies.createPolicy(command, options);
|
|
95
66
|
}
|
|
96
67
|
/**
|
|
97
68
|
* Handle a Get Policy Command from the SDK.
|
|
98
69
|
*/
|
|
99
70
|
async getPolicy(command, options) {
|
|
100
|
-
return await this.
|
|
71
|
+
return await this.commands.policies.getPolicy(command, options);
|
|
101
72
|
}
|
|
102
73
|
/**
|
|
103
74
|
* Handle a List Policies Command from the SDK.
|
|
104
75
|
*/
|
|
105
76
|
async listPolicies(command, options) {
|
|
106
|
-
return await this.
|
|
77
|
+
return await this.commands.policies.listPolicies(command, options);
|
|
107
78
|
}
|
|
108
79
|
/**
|
|
109
80
|
* Handle a Put Role Policy Command from the SDK.
|
|
110
81
|
*/
|
|
111
82
|
async putRolePolicy(command, options) {
|
|
112
|
-
return await this.
|
|
83
|
+
return await this.commands.roles.putRolePolicy(command, options);
|
|
113
84
|
}
|
|
114
85
|
/**
|
|
115
86
|
* Handle an IAM PutUserPolicy command.
|
|
116
87
|
*/
|
|
117
88
|
async putUserPolicy(command, options) {
|
|
118
|
-
return await this.
|
|
89
|
+
return await this.commands.policies.putUserPolicy(command, options);
|
|
119
90
|
}
|
|
120
91
|
/**
|
|
121
92
|
* Handle a Create Role Command from the SDK.
|
|
122
93
|
*/
|
|
123
94
|
async createRole(command, options) {
|
|
124
|
-
return await this.
|
|
95
|
+
return await this.commands.roles.createRole(command, options);
|
|
125
96
|
}
|
|
126
97
|
/**
|
|
127
98
|
* Handle an Attach Role Policy Command from the SDK.
|
|
128
99
|
*/
|
|
129
100
|
async attachRolePolicy(command, options) {
|
|
130
|
-
return await this.
|
|
101
|
+
return await this.commands.roles.attachRolePolicy(command, options);
|
|
131
102
|
}
|
|
132
103
|
/**
|
|
133
104
|
* Handle a Get Role Command from the SDK.
|
|
134
105
|
*/
|
|
135
106
|
async getRole(command, options) {
|
|
136
|
-
return await this.
|
|
107
|
+
return await this.commands.roles.getRole(command, options);
|
|
137
108
|
}
|
|
138
109
|
/**
|
|
139
110
|
* Handle a List Roles Command from the SDK.
|
|
140
111
|
*/
|
|
141
112
|
async listRoles(command, options) {
|
|
142
|
-
return await this.
|
|
113
|
+
return await this.commands.roles.listRoles(command, options);
|
|
143
114
|
}
|
|
144
115
|
/**
|
|
145
116
|
* Handle an IAM CreateUser command.
|
|
146
117
|
*/
|
|
147
118
|
async createUser(command, options) {
|
|
148
|
-
return await this.
|
|
119
|
+
return await this.commands.users.createUser(command, options);
|
|
149
120
|
}
|
|
150
121
|
/**
|
|
151
122
|
* Handle an IAM CreateAccessKey command.
|
|
152
123
|
*/
|
|
153
124
|
async createAccessKey(command, options) {
|
|
154
|
-
return await this.
|
|
125
|
+
return await this.commands.users.createAccessKey(command, options);
|
|
155
126
|
}
|
|
156
127
|
/**
|
|
157
128
|
* Get this service's CloudFormation Resource factory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sim-iam.js","sourceRoot":"","sources":["../../../src/service/iam/sim-iam.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sim-iam.js","sourceRoot":"","sources":["../../../src/service/iam/sim-iam.ts"],"names":[],"mappings":"AAmDA,OAAO,EAAE,mCAAmC,EAAE,MAAM,uCAAuC,CAAC;AAM5F,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAM7E,O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