@kensio/yulin 1.20.15 → 1.20.16
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 +13 -0
- package/dist/sdk/module/sim-sdk-module-client-interceptor.d.ts +5 -0
- package/dist/sdk/module/sim-sdk-module-client-interceptor.js +14 -0
- package/dist/sdk/module/sim-sdk-static-client-factory.d.ts +26 -0
- package/dist/sdk/module/sim-sdk-static-client-factory.js +59 -0
- package/dist/sdk/send-patch.d.ts +8 -0
- package/dist/sdk/send-patch.js +11 -0
- package/dist/service/aws/caller/sim-aws-caller-resolver.d.ts +28 -6
- package/dist/service/aws/caller/sim-aws-caller-resolver.js +18 -11
- package/dist/service/aws/caller/sim-aws-caller.d.ts +9 -0
- package/dist/service/aws/caller/sim-aws-resolved-caller.d.ts +19 -0
- package/dist/service/aws/caller/sim-aws-resolved-caller.js +26 -0
- package/dist/service/aws/factory/sim-aws-account-region-service-builder.d.ts +6 -0
- package/dist/service/aws/factory/sim-aws-account-region-service-builder.js +3 -0
- package/dist/service/aws/factory/sim-aws-account-service-cache.d.ts +6 -0
- package/dist/service/aws/factory/sim-aws-account-service-cache.js +5 -0
- package/dist/service/aws/factory/sim-aws-service-factory.d.ts +5 -0
- package/dist/service/aws/factory/sim-aws-service-factory.js +6 -0
- package/dist/service/aws/sim-aws-properties.d.ts +15 -0
- package/dist/service/aws/sim-aws.js +2 -1
- package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.d.ts +30 -7
- package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.js +20 -11
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts +2 -1
- package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js +5 -1
- package/dist/service/iam/authorize/match/sim-iam-policy-principal-matcher.d.ts +10 -0
- package/dist/service/iam/authorize/match/sim-iam-policy-principal-matcher.js +15 -3
- package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts +11 -4
- package/dist/service/iam/authorize/sim-iam-account-auth-z.js +5 -3
- package/dist/service/iam/authorize/sim-iam-authorizer.d.ts +2 -1
- package/dist/service/iam/authorize/sim-iam-authorizer.js +1 -0
- package/dist/service/iam/role/sim-iam-role-with-policy.factory.d.ts +9 -0
- package/dist/service/iam/role/sim-iam-role-with-policy.factory.js +4 -2
- package/dist/service/iam/sim-iam-account-parts.d.ts +8 -0
- package/dist/service/iam/sim-iam-account-parts.js +1 -0
- package/dist/service/sts/auth-z/assume-role-auth-z-coordinator.d.ts +9 -2
- package/dist/service/sts/auth-z/assume-role-auth-z-coordinator.js +2 -2
- package/dist/service/sts/auth-z/assume-role-source-account-auth-z.d.ts +10 -4
- package/dist/service/sts/auth-z/assume-role-source-account-auth-z.js +8 -7
- package/dist/service/sts/auth-z/assume-role-target-auth-z.d.ts +2 -2
- package/dist/service/sts/auth-z/assume-role-trust-policy-authorizer.d.ts +6 -2
- package/dist/service/sts/auth-z/assume-role-trust-policy-authorizer.js +14 -11
- package/dist/service/sts/command/assume-role/assume-role.handler.d.ts +5 -1
- package/dist/service/sts/command/assume-role/assume-role.handler.js +5 -2
- package/dist/service/sts/command/get-caller-identity/get-caller-identity.handler.d.ts +5 -1
- package/dist/service/sts/command/get-caller-identity/get-caller-identity.handler.js +4 -1
- package/dist/service/sts/service-role/sim-service-role.js +5 -1
- package/dist/service/sts/sim-sts.d.ts +9 -1
- package/dist/service/sts/sim-sts.js +4 -0
- package/docs/README.md +54 -0
- package/docs/ai-skill/README.md +69 -0
- package/docs/cli/README.md +284 -0
- package/docs/factories/README.md +140 -0
- package/docs/lint/README.md +176 -0
- package/docs/non-aws-dependencies/README.md +261 -0
- package/docs/sdk/README.md +272 -0
- package/docs/serve/README.md +1126 -0
- package/docs/services/acm/README.md +823 -0
- package/docs/services/apigateway/README.md +1919 -0
- package/docs/services/apigatewayv2/README.md +2678 -0
- package/docs/services/athena/README.md +1044 -0
- package/docs/services/bedrock/README.md +350 -0
- package/docs/services/cloudformation/README.md +3440 -0
- package/docs/services/cloudfront/README.md +2874 -0
- package/docs/services/cloudwatch/README.md +420 -0
- package/docs/services/cognito/README.md +4923 -0
- package/docs/services/dynamodb/README.md +3784 -0
- package/docs/services/ecr/README.md +302 -0
- package/docs/services/ecs/README.md +2010 -0
- package/docs/services/elbv2/README.md +1897 -0
- package/docs/services/eventbridge/README.md +1110 -0
- package/docs/services/firehose/README.md +805 -0
- package/docs/services/glue/README.md +501 -0
- package/docs/services/iam/README.md +1283 -0
- package/docs/services/kinesis/README.md +454 -0
- package/docs/services/kms/README.md +659 -0
- package/docs/services/lambda/README.md +3645 -0
- package/docs/services/logs/README.md +868 -0
- package/docs/services/organizations/README.md +574 -0
- package/docs/services/personalize/README.md +835 -0
- package/docs/services/rekognition/README.md +1070 -0
- package/docs/services/route53/README.md +1783 -0
- package/docs/services/s3/README.md +3024 -0
- package/docs/services/scheduler/README.md +806 -0
- package/docs/services/secretsmanager/README.md +667 -0
- package/docs/services/ses/README.md +1011 -0
- package/docs/services/sns/README.md +1904 -0
- package/docs/services/sqs/README.md +1185 -0
- package/docs/services/ssm/README.md +1072 -0
- package/docs/services/stepfunctions/README.md +1332 -0
- package/docs/services/sts/README.md +245 -0
- package/docs/services/wafv2/README.md +1378 -0
- package/docs/terraform/README.md +248 -0
- package/docs/time/README.md +284 -0
- package/llms.txt +59 -0
- package/package.json +7 -4
|
@@ -2,34 +2,43 @@ import { SimAwsCallerResolver, } from "../../../aws/caller/sim-aws-caller-resolv
|
|
|
2
2
|
/**
|
|
3
3
|
* Resolves the caller and any policy sources implied by that caller.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* A request that omits a caller is decided as the simulation's default caller,
|
|
6
|
+
* and as the Account root where the simulation named none. An explicit
|
|
7
|
+
* anonymous caller falls back to neither.
|
|
8
8
|
*/
|
|
9
9
|
export class SimIamAuthZCallerContextBuilder {
|
|
10
10
|
callerResolver;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
accountRootPrincipal;
|
|
12
|
+
accountRootArn;
|
|
13
|
+
constructor(properties) {
|
|
14
|
+
const root = properties.accountRootPrincipal;
|
|
15
|
+
this.accountRootPrincipal = root;
|
|
16
|
+
this.accountRootArn = root.kind === "arn" ? root.arn : undefined;
|
|
17
|
+
this.callerResolver = new SimAwsCallerResolver({
|
|
18
|
+
credentialIdentityResolver: properties.credentialIdentityResolver,
|
|
19
|
+
defaultCaller: properties.defaultCaller,
|
|
20
|
+
});
|
|
15
21
|
}
|
|
16
22
|
/**
|
|
17
23
|
* Resolve request caller data and add the simulated root policy when
|
|
18
24
|
* applicable.
|
|
19
25
|
*/
|
|
20
26
|
build(caller) {
|
|
21
|
-
const resolvedCaller = this.callerResolver.resolve(caller, this.
|
|
27
|
+
const resolvedCaller = this.callerResolver.resolve(caller, this.accountRootPrincipal);
|
|
22
28
|
return {
|
|
23
29
|
caller: resolvedCaller,
|
|
24
30
|
rootPolicySources: this.rootPolicySources(resolvedCaller),
|
|
25
31
|
};
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
|
-
* Give the
|
|
34
|
+
* Give the Account's root principal unrestricted identity access.
|
|
35
|
+
*
|
|
36
|
+
* The comparison names the root principal explicitly, so a simulation with a
|
|
37
|
+
* default caller keeps this access on the root where AWS has it.
|
|
29
38
|
*/
|
|
30
39
|
rootPolicySources(caller) {
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
if (this.accountRootArn === undefined ||
|
|
41
|
+
caller.arn !== this.accountRootArn) {
|
|
33
42
|
return [];
|
|
34
43
|
}
|
|
35
44
|
return [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SimArn } from "../../../aws/arn.js";
|
|
2
2
|
import type { AwsRegionName } from "../../../aws/sim-aws-region.js";
|
|
3
|
-
import type { SimAwsCaller, SimAwsPrincipal } from "../../../aws/caller/sim-aws-caller.js";
|
|
3
|
+
import type { SimAwsCaller, SimAwsDefaultCaller, SimAwsPrincipal } from "../../../aws/caller/sim-aws-caller.js";
|
|
4
4
|
import type { SimAwsAccountId } from "../../../aws/sim-aws-account.js";
|
|
5
5
|
import type { SimIamAccountResolver } from "../../registry/sim-iam-account-resolver.js";
|
|
6
6
|
import type { SimIamConditionValue, SimIamPolicy, SimIamPolicyDocument } from "../../policy/sim-iam-policy.js";
|
|
@@ -85,6 +85,7 @@ interface SimIamAuthZContextBuilderProperties {
|
|
|
85
85
|
readonly roles: ReadonlyMap<SimIamRoleName, SimIamRole>;
|
|
86
86
|
readonly users: ReadonlyMap<SimIamUsername, SimIamUser>;
|
|
87
87
|
readonly credentialIdentityResolver: SimAwsCredentialIdentityResolver;
|
|
88
|
+
readonly defaultCaller?: SimAwsDefaultCaller | undefined;
|
|
88
89
|
/**
|
|
89
90
|
* Resolves other Accounts' IAM in the same simulation, for the identity side
|
|
90
91
|
* of a cross-Account request.
|
|
@@ -43,7 +43,11 @@ export class SimIamAuthZContextBuilder {
|
|
|
43
43
|
derivedConditions = new SimIamDerivedConditions();
|
|
44
44
|
scpSourceBuilder;
|
|
45
45
|
constructor(properties) {
|
|
46
|
-
this.callerContextBuilder = new SimIamAuthZCallerContextBuilder(
|
|
46
|
+
this.callerContextBuilder = new SimIamAuthZCallerContextBuilder({
|
|
47
|
+
accountRootPrincipal: makeSimAwsAccountRootPrincipal(properties.accountId),
|
|
48
|
+
credentialIdentityResolver: properties.credentialIdentityResolver,
|
|
49
|
+
defaultCaller: properties.defaultCaller,
|
|
50
|
+
});
|
|
47
51
|
this.identityPolicyCoordinator = new SimIamAuthZIdentityPolicyCoordinator({
|
|
48
52
|
policies: properties.policies,
|
|
49
53
|
roles: properties.roles,
|
|
@@ -47,8 +47,18 @@ export declare class SimIamPolicyPrincipalMatcher {
|
|
|
47
47
|
* The wildcard matches both authenticated and anonymous requests. Other AWS
|
|
48
48
|
* forms require an ARN-based caller. Account delegation forms compare against
|
|
49
49
|
* the account ID derived by the caller resolver.
|
|
50
|
+
*
|
|
51
|
+
* A pattern is compared against two ARNs, because an assumed-role session
|
|
52
|
+
* has two. The session ARN is the caller, and the Role behind it is the
|
|
53
|
+
* identity whose policies apply. AWS matches a policy naming either one, and
|
|
54
|
+
* recommends naming the Role. The two ARNs are the same for every caller
|
|
55
|
+
* that is not a session, so one comparison happens in that case.
|
|
50
56
|
*/
|
|
51
57
|
private awsPatternMatches;
|
|
58
|
+
/**
|
|
59
|
+
* Whether a principal pattern names one of the caller's ARNs.
|
|
60
|
+
*/
|
|
61
|
+
private arnMatches;
|
|
52
62
|
/**
|
|
53
63
|
* Compare a service principal pattern with the resolved caller.
|
|
54
64
|
*
|
|
@@ -81,6 +81,12 @@ export class SimIamPolicyPrincipalMatcher {
|
|
|
81
81
|
* The wildcard matches both authenticated and anonymous requests. Other AWS
|
|
82
82
|
* forms require an ARN-based caller. Account delegation forms compare against
|
|
83
83
|
* the account ID derived by the caller resolver.
|
|
84
|
+
*
|
|
85
|
+
* A pattern is compared against two ARNs, because an assumed-role session
|
|
86
|
+
* has two. The session ARN is the caller, and the Role behind it is the
|
|
87
|
+
* identity whose policies apply. AWS matches a policy naming either one, and
|
|
88
|
+
* recommends naming the Role. The two ARNs are the same for every caller
|
|
89
|
+
* that is not a session, so one comparison happens in that case.
|
|
84
90
|
*/
|
|
85
91
|
awsPatternMatches(pattern) {
|
|
86
92
|
if (pattern === "*") {
|
|
@@ -94,9 +100,15 @@ export class SimIamPolicyPrincipalMatcher {
|
|
|
94
100
|
if (delegatedAccountId !== undefined) {
|
|
95
101
|
return SimIamPrincipalMatch.accountDelegation().when(caller.accountId === delegatedAccountId);
|
|
96
102
|
}
|
|
97
|
-
return SimIamPrincipalMatch.direct().when(
|
|
98
|
-
|
|
99
|
-
|
|
103
|
+
return SimIamPrincipalMatch.direct().when(this.arnMatches(pattern, caller.arn) ||
|
|
104
|
+
this.arnMatches(pattern, caller.identityPolicyArn));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether a principal pattern names one of the caller's ARNs.
|
|
108
|
+
*/
|
|
109
|
+
arnMatches(pattern, arn) {
|
|
110
|
+
return (arn !== undefined &&
|
|
111
|
+
simIamWildcardMatch(pattern, arn, { caseSensitive: true }));
|
|
100
112
|
}
|
|
101
113
|
/**
|
|
102
114
|
* Compare a service principal pattern with the resolved caller.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
|
|
2
2
|
import type { SimArn } from "../../aws/arn.js";
|
|
3
3
|
import type { SimAwsCredentialIdentityResolver } from "../../aws/caller/sim-aws-caller-resolver.js";
|
|
4
|
-
import type { SimAwsPrincipal } from "../../aws/caller/sim-aws-caller.js";
|
|
4
|
+
import type { SimAwsDefaultCaller, SimAwsPrincipal } from "../../aws/caller/sim-aws-caller.js";
|
|
5
5
|
import type { SimIamManagedPolicy } from "../policy/sim-iam-policy.js";
|
|
6
6
|
import type { SimIamRole, SimIamRoleName } from "../role/sim-iam-role.js";
|
|
7
7
|
import type { SimIamUser, SimIamUsername } from "../user/sim-iam-user.js";
|
|
@@ -17,6 +17,12 @@ interface SimIamAccountAuthZProperties {
|
|
|
17
17
|
readonly roles: Map<SimIamRoleName, SimIamRole>;
|
|
18
18
|
readonly users: Map<SimIamUsername, SimIamUser>;
|
|
19
19
|
readonly credentialIdentityResolver: SimAwsCredentialIdentityResolver;
|
|
20
|
+
/**
|
|
21
|
+
* The caller this simulation attributes a request naming none to.
|
|
22
|
+
*
|
|
23
|
+
* Left out, such a request is decided as this Account's root principal.
|
|
24
|
+
*/
|
|
25
|
+
readonly defaultCaller?: SimAwsDefaultCaller | undefined;
|
|
20
26
|
/**
|
|
21
27
|
* Resolves other Accounts' IAM in the same simulation.
|
|
22
28
|
*
|
|
@@ -37,9 +43,10 @@ interface SimIamAccountAuthZProperties {
|
|
|
37
43
|
* Evaluates IAM authorization attempts against one simulated Account's IAM
|
|
38
44
|
* state.
|
|
39
45
|
*
|
|
40
|
-
* If the caller is omitted, authorization defaults to the
|
|
41
|
-
* the
|
|
42
|
-
*
|
|
46
|
+
* If the caller is omitted, authorization defaults to the simulation's default
|
|
47
|
+
* caller, and to the root principal of the owning sim Account where the
|
|
48
|
+
* simulation has none. An explicit anonymous caller suppresses both and is
|
|
49
|
+
* evaluated without identity policies.
|
|
43
50
|
*/
|
|
44
51
|
export declare class SimIamAccountAuthZ implements SimIamAccountIdentityPolicies {
|
|
45
52
|
private readonly properties;
|
|
@@ -3,9 +3,10 @@ import { SimIamAuthorizer } from "./sim-iam-authorizer.js";
|
|
|
3
3
|
* Evaluates IAM authorization attempts against one simulated Account's IAM
|
|
4
4
|
* state.
|
|
5
5
|
*
|
|
6
|
-
* If the caller is omitted, authorization defaults to the
|
|
7
|
-
* the
|
|
8
|
-
*
|
|
6
|
+
* If the caller is omitted, authorization defaults to the simulation's default
|
|
7
|
+
* caller, and to the root principal of the owning sim Account where the
|
|
8
|
+
* simulation has none. An explicit anonymous caller suppresses both and is
|
|
9
|
+
* evaluated without identity policies.
|
|
9
10
|
*/
|
|
10
11
|
export class SimIamAccountAuthZ {
|
|
11
12
|
properties;
|
|
@@ -38,6 +39,7 @@ export class SimIamAccountAuthZ {
|
|
|
38
39
|
roles: this.properties.roles,
|
|
39
40
|
users: this.properties.users,
|
|
40
41
|
credentialIdentityResolver: this.properties.credentialIdentityResolver,
|
|
42
|
+
defaultCaller: this.properties.defaultCaller,
|
|
41
43
|
iamResolver: this.properties.iamResolver,
|
|
42
44
|
scpResolver: this.properties.scpResolver,
|
|
43
45
|
});
|
|
@@ -3,7 +3,7 @@ import type { SimIamPolicy } from "../policy/sim-iam-policy.js";
|
|
|
3
3
|
import type { SimIamRole, SimIamRoleName } from "../role/sim-iam-role.js";
|
|
4
4
|
import { type SimIamAuthorizationInput } from "./context/sim-iam-auth-z-context-builder.js";
|
|
5
5
|
import { SimIamPolicyDecision } from "./sim-iam-decision.js";
|
|
6
|
-
import type { SimAwsPrincipal } from "../../aws/caller/sim-aws-caller.js";
|
|
6
|
+
import type { SimAwsDefaultCaller, SimAwsPrincipal } from "../../aws/caller/sim-aws-caller.js";
|
|
7
7
|
import type { SimIamUser, SimIamUsername } from "../user/sim-iam-user.js";
|
|
8
8
|
import type { SimAwsCredentialIdentityResolver } from "../../aws/caller/sim-aws-caller-resolver.js";
|
|
9
9
|
import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
|
|
@@ -17,6 +17,7 @@ interface SimIamAuthorizerProperties {
|
|
|
17
17
|
readonly roles: ReadonlyMap<SimIamRoleName, SimIamRole>;
|
|
18
18
|
readonly users: ReadonlyMap<SimIamUsername, SimIamUser>;
|
|
19
19
|
readonly credentialIdentityResolver: SimAwsCredentialIdentityResolver;
|
|
20
|
+
readonly defaultCaller?: SimAwsDefaultCaller | undefined;
|
|
20
21
|
readonly iamResolver?: SimIamAccountResolver | undefined;
|
|
21
22
|
readonly scpResolver?: SimIamServiceControlPolicyResolver | undefined;
|
|
22
23
|
}
|
|
@@ -17,6 +17,7 @@ export class SimIamAuthorizer {
|
|
|
17
17
|
roles: properties.roles,
|
|
18
18
|
users: properties.users,
|
|
19
19
|
credentialIdentityResolver: properties.credentialIdentityResolver,
|
|
20
|
+
defaultCaller: properties.defaultCaller,
|
|
20
21
|
iamResolver: properties.iamResolver,
|
|
21
22
|
scpResolver: properties.scpResolver,
|
|
22
23
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AsyncMappedFactory } from "@kensio/part-factory";
|
|
2
2
|
import type { SimAws } from "../../aws/sim-aws.js";
|
|
3
|
+
import type { SimAwsCaller } from "../../aws/caller/sim-aws-caller.js";
|
|
3
4
|
import type { SimCreateRoleCommandOutput } from "../command/role/create-role/create-role.command.js";
|
|
4
5
|
/**
|
|
5
6
|
* What a test asks for when it wants a Role that may do something.
|
|
@@ -13,6 +14,14 @@ export interface SimIamRoleWithPolicyInput {
|
|
|
13
14
|
readonly policyName: string;
|
|
14
15
|
readonly actions: readonly string[];
|
|
15
16
|
readonly resource: string;
|
|
17
|
+
/**
|
|
18
|
+
* The principal creating the Role.
|
|
19
|
+
*
|
|
20
|
+
* A simulation given a default caller attributes these two commands to it,
|
|
21
|
+
* and a Role being created for that caller has no policies to allow them
|
|
22
|
+
* yet. Naming the Account root here is how such a test bootstraps.
|
|
23
|
+
*/
|
|
24
|
+
readonly caller?: SimAwsCaller | undefined;
|
|
16
25
|
}
|
|
17
26
|
/**
|
|
18
27
|
* The Role a CreateRole request answers with.
|
|
@@ -24,8 +24,10 @@ export const simIamRoleWithPolicyFactory = new AsyncMappedFactory(() => ({
|
|
|
24
24
|
policyName: "ApplicationPolicy",
|
|
25
25
|
actions: [],
|
|
26
26
|
resource: "*",
|
|
27
|
+
caller: undefined,
|
|
27
28
|
}), async (input, simAws) => {
|
|
28
29
|
const simIam = simAws.iam();
|
|
30
|
+
const options = input.caller === undefined ? undefined : { caller: input.caller };
|
|
29
31
|
const creation = await simIam.createRole({
|
|
30
32
|
input: {
|
|
31
33
|
RoleName: input.roleName,
|
|
@@ -38,7 +40,7 @@ export const simIamRoleWithPolicyFactory = new AsyncMappedFactory(() => ({
|
|
|
38
40
|
},
|
|
39
41
|
}),
|
|
40
42
|
},
|
|
41
|
-
});
|
|
43
|
+
}, options);
|
|
42
44
|
await simIam.putRolePolicy({
|
|
43
45
|
input: {
|
|
44
46
|
RoleName: input.roleName,
|
|
@@ -47,6 +49,6 @@ export const simIamRoleWithPolicyFactory = new AsyncMappedFactory(() => ({
|
|
|
47
49
|
Statement: { Action: input.actions, Resource: input.resource },
|
|
48
50
|
}),
|
|
49
51
|
},
|
|
50
|
-
});
|
|
52
|
+
}, options);
|
|
51
53
|
return creation.Role;
|
|
52
54
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type BackgroundScheduler } from "../../util/background/background.js";
|
|
2
2
|
import type { SimAwsAccountId } from "../aws/sim-aws-account.js";
|
|
3
3
|
import type { SimAwsAccountRegionScope } from "../aws/sim-aws-account-region-scope.js";
|
|
4
|
+
import type { SimAwsDefaultCaller } from "../aws/caller/sim-aws-caller.js";
|
|
4
5
|
import { SimIamAccountAuthZ } from "./authorize/sim-iam-account-auth-z.js";
|
|
5
6
|
import type { SimIamInterServiceAuthZ } from "./authorize/sim-iam-inter-service-auth-z.js";
|
|
6
7
|
import { SimIamCommandHandlers } from "./command/sim-iam-command-handlers.js";
|
|
@@ -19,6 +20,13 @@ export interface SimIamProperties {
|
|
|
19
20
|
readonly credentialRegistry?: SimIamCredentialRegistry;
|
|
20
21
|
readonly sessionCredentialGenerator?: SimIamSessionCredentialGenerator;
|
|
21
22
|
readonly userCredentialGenerator?: SimIamUserCredentialGenerator;
|
|
23
|
+
/**
|
|
24
|
+
* The caller this simulation attributes a request naming none to.
|
|
25
|
+
*
|
|
26
|
+
* A SimAws passes on what it was built with. Left out, such a request is
|
|
27
|
+
* decided as the Account root, which is what a standalone SimIam does.
|
|
28
|
+
*/
|
|
29
|
+
readonly defaultCaller?: SimAwsDefaultCaller | undefined;
|
|
22
30
|
/**
|
|
23
31
|
* Resolves the IAM of other Accounts in the same simulation.
|
|
24
32
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SimAwsResolvedCaller } from "../../aws/caller/sim-aws-caller-resolver.js";
|
|
2
2
|
import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
|
|
3
3
|
import type { AwsRegionName } from "../../aws/sim-aws-region.js";
|
|
4
4
|
import type { SimGetRoleCommandOutput } from "../../iam/command/role/get-role/get-role.command.js";
|
|
@@ -14,7 +14,14 @@ interface AssumeRoleAuthorizationCoordinatorProperties {
|
|
|
14
14
|
interface AssumeRoleAuthorizationInput {
|
|
15
15
|
readonly roleArn: string;
|
|
16
16
|
readonly roleArnParts: IamRoleArnParts;
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The caller as the request boundary resolved it.
|
|
19
|
+
*
|
|
20
|
+
* Both sides of an AssumeRole decision need the identity whose policies
|
|
21
|
+
* apply, which is the Role behind an assumed-role session. Passing the
|
|
22
|
+
* resolved caller whole is what carries it here.
|
|
23
|
+
*/
|
|
24
|
+
readonly caller: SimAwsResolvedCaller;
|
|
18
25
|
readonly conditionContext?: Readonly<Record<string, SimIamConditionValue>> | undefined;
|
|
19
26
|
}
|
|
20
27
|
type AssumeRoleAuthorizedRole = SimGetRoleCommandOutput["Role"];
|
|
@@ -38,8 +38,8 @@ export class AssumeRoleAuthorizationCoordinator {
|
|
|
38
38
|
});
|
|
39
39
|
this.sourcePrincipalAuthorizer.authorize({
|
|
40
40
|
roleArn: input.roleArn,
|
|
41
|
-
|
|
42
|
-
identityPolicyAllowRequired: !this.hasDirectSameAccountUserGrant(input.caller, input.roleArnParts.accountId, targetAuthorization.trust.isDirectPrincipalGrant),
|
|
41
|
+
caller: input.caller,
|
|
42
|
+
identityPolicyAllowRequired: !this.hasDirectSameAccountUserGrant(input.caller.principal, input.roleArnParts.accountId, targetAuthorization.trust.isDirectPrincipalGrant),
|
|
43
43
|
});
|
|
44
44
|
return targetAuthorization.role;
|
|
45
45
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SimIamAccountResolver } from "../../iam/registry/sim-iam-account-resolver.js";
|
|
2
2
|
import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
|
|
3
3
|
import type { AwsRegionName } from "../../aws/sim-aws-region.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { SimAwsResolvedCaller } from "../../aws/caller/sim-aws-caller-resolver.js";
|
|
5
5
|
interface AssumeRoleSourceAccountAuthorizerProperties {
|
|
6
6
|
readonly sourceAccountId: SimAwsAccountId;
|
|
7
7
|
readonly iamResolver: SimIamAccountResolver;
|
|
@@ -12,7 +12,13 @@ interface AssumeRoleSourceAccountAuthorizerProperties {
|
|
|
12
12
|
}
|
|
13
13
|
export interface AssumeRoleSourceAuthorizationInput {
|
|
14
14
|
readonly roleArn: string;
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The caller as the request boundary resolved it.
|
|
17
|
+
*
|
|
18
|
+
* The identity policies deciding this are the ones held by the Role behind
|
|
19
|
+
* an assumed-role session, so the resolved caller travels here whole.
|
|
20
|
+
*/
|
|
21
|
+
readonly caller?: SimAwsResolvedCaller | undefined;
|
|
16
22
|
/**
|
|
17
23
|
* Whether the caller must have an identity-policy Allow for sts:AssumeRole.
|
|
18
24
|
*
|
|
@@ -31,8 +37,8 @@ export interface AssumeRoleSourceAuthorizationInput {
|
|
|
31
37
|
* trust authorization is a separate responsibility and must be performed even
|
|
32
38
|
* when the source and target Account are the same.
|
|
33
39
|
*
|
|
34
|
-
* When no caller principal is supplied,
|
|
35
|
-
*
|
|
40
|
+
* When no caller principal is supplied, sim IAM applies its own default caller
|
|
41
|
+
* behaviour for the source Account.
|
|
36
42
|
*/
|
|
37
43
|
export declare class AssumeRoleSourcePrincipalAuthorizer {
|
|
38
44
|
private readonly sourceAccountId;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { simAwsCallerFor } from "../../aws/caller/sim-aws-resolved-caller.js";
|
|
2
2
|
import { SimIamAccessDenied } from "../../iam/error/sim-iam.error.js";
|
|
3
3
|
/**
|
|
4
4
|
* Authorizes the caller's request to assume a role against IAM in the source
|
|
@@ -10,8 +10,8 @@ import { SimIamAccessDenied } from "../../iam/error/sim-iam.error.js";
|
|
|
10
10
|
* trust authorization is a separate responsibility and must be performed even
|
|
11
11
|
* when the source and target Account are the same.
|
|
12
12
|
*
|
|
13
|
-
* When no caller principal is supplied,
|
|
14
|
-
*
|
|
13
|
+
* When no caller principal is supplied, sim IAM applies its own default caller
|
|
14
|
+
* behaviour for the source Account.
|
|
15
15
|
*/
|
|
16
16
|
export class AssumeRoleSourcePrincipalAuthorizer {
|
|
17
17
|
sourceAccountId;
|
|
@@ -30,18 +30,19 @@ export class AssumeRoleSourcePrincipalAuthorizer {
|
|
|
30
30
|
*/
|
|
31
31
|
authorize(input) {
|
|
32
32
|
const sourceIam = this.iamResolver.iamForAccount(this.sourceAccountId);
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
// A request with no caller of its own is left for sim IAM to attribute.
|
|
34
|
+
// The simulation's default caller reaches this decision the way it reaches
|
|
35
|
+
// every other one.
|
|
35
36
|
const decision = sourceIam.authorize({
|
|
36
37
|
action: "sts:AssumeRole",
|
|
37
38
|
resource: input.roleArn,
|
|
38
39
|
region: this.regionName,
|
|
39
|
-
caller:
|
|
40
|
+
caller: input.caller === undefined ? undefined : simAwsCallerFor(input.caller),
|
|
40
41
|
});
|
|
41
42
|
if (decision.isExplicitDeny ||
|
|
42
43
|
(decision.isImplicitDeny && Boolean(input.identityPolicyAllowRequired))) {
|
|
43
44
|
throw new SimIamAccessDenied({
|
|
44
|
-
principal:
|
|
45
|
+
principal: decision.caller.principal,
|
|
45
46
|
action: "sts:AssumeRole",
|
|
46
47
|
resource: input.roleArn,
|
|
47
48
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SimAwsResolvedCaller } from "../../aws/caller/sim-aws-caller-resolver.js";
|
|
2
2
|
import type { SimAwsAccountId } from "../../aws/sim-aws-account.js";
|
|
3
3
|
import type { AwsRegionName } from "../../aws/sim-aws-region.js";
|
|
4
4
|
import type { SimIamAccountResolver } from "../../iam/registry/sim-iam-account-resolver.js";
|
|
@@ -17,7 +17,7 @@ type AssumeRoleTargetRole = SimGetRoleCommandOutput["Role"];
|
|
|
17
17
|
interface AssumeRoleTargetAuthorizationInput {
|
|
18
18
|
readonly roleArn: string;
|
|
19
19
|
readonly target: IamRoleArnParts | SimAwsAccountId;
|
|
20
|
-
readonly caller:
|
|
20
|
+
readonly caller: SimAwsResolvedCaller;
|
|
21
21
|
readonly conditionContext?: Readonly<Record<string, SimIamConditionValue>> | undefined;
|
|
22
22
|
}
|
|
23
23
|
interface AssumeRoleTargetAuthorization {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SimAwsResolvedCaller } from "../../aws/caller/sim-aws-caller-resolver.js";
|
|
2
2
|
import type { AwsRegionName } from "../../aws/sim-aws-region.js";
|
|
3
3
|
import type { SimGetRoleCommandOutput } from "../../iam/command/role/get-role/get-role.command.js";
|
|
4
4
|
import type { SimIamConditionValue } from "../../iam/policy/sim-iam-policy.js";
|
|
@@ -14,7 +14,7 @@ interface AssumeRoleTrustPolicyAuthorizationInput {
|
|
|
14
14
|
* target Account's service control policies can be conditioned on.
|
|
15
15
|
*/
|
|
16
16
|
readonly region?: AwsRegionName | undefined;
|
|
17
|
-
readonly caller:
|
|
17
|
+
readonly caller: SimAwsResolvedCaller;
|
|
18
18
|
readonly conditionContext?: Readonly<Record<string, SimIamConditionValue>> | undefined;
|
|
19
19
|
}
|
|
20
20
|
export interface AssumeRoleTrustPolicyAuthorization {
|
|
@@ -46,5 +46,9 @@ export declare class AssumeRoleTrustPolicyAuthorizer {
|
|
|
46
46
|
* no trust-policy statement grants access, even if no explicit Deny matched.
|
|
47
47
|
*/
|
|
48
48
|
authorize(input: AssumeRoleTrustPolicyAuthorizationInput): AssumeRoleTrustPolicyAuthorization;
|
|
49
|
+
/**
|
|
50
|
+
* Refuse the request as the caller that made it.
|
|
51
|
+
*/
|
|
52
|
+
private refuse;
|
|
49
53
|
}
|
|
50
54
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsonParse } from "../../../util/type-guard/json.js";
|
|
2
|
+
import { simAwsCallerFor } from "../../aws/caller/sim-aws-resolved-caller.js";
|
|
2
3
|
import { SimIamAccessDenied } from "../../iam/error/sim-iam.error.js";
|
|
3
4
|
import { AssumeRoleTrustGrantClassifier } from "./assume-role-trust-grant-classifier.js";
|
|
4
5
|
/**
|
|
@@ -27,18 +28,14 @@ export class AssumeRoleTrustPolicyAuthorizer {
|
|
|
27
28
|
*/
|
|
28
29
|
authorize(input) {
|
|
29
30
|
if (input.role.AssumeRolePolicyDocument === undefined) {
|
|
30
|
-
|
|
31
|
-
principal: input.caller,
|
|
32
|
-
action: "sts:AssumeRole",
|
|
33
|
-
resource: input.roleArn,
|
|
34
|
-
});
|
|
31
|
+
this.refuse(input);
|
|
35
32
|
}
|
|
36
33
|
const trustPolicy = jsonParse(input.role.AssumeRolePolicyDocument);
|
|
37
34
|
const decision = input.targetIam.authorize({
|
|
38
35
|
action: "sts:AssumeRole",
|
|
39
36
|
resource: input.roleArn,
|
|
40
37
|
region: input.region,
|
|
41
|
-
caller: input.caller,
|
|
38
|
+
caller: simAwsCallerFor(input.caller),
|
|
42
39
|
conditionContext: input.conditionContext,
|
|
43
40
|
resourcePolicies: [
|
|
44
41
|
{
|
|
@@ -50,15 +47,21 @@ export class AssumeRoleTrustPolicyAuthorizer {
|
|
|
50
47
|
],
|
|
51
48
|
});
|
|
52
49
|
if (decision.isDenied || !decision.isAllowedByTrustPolicy) {
|
|
53
|
-
|
|
54
|
-
principal: input.caller,
|
|
55
|
-
action: "sts:AssumeRole",
|
|
56
|
-
resource: input.roleArn,
|
|
57
|
-
});
|
|
50
|
+
this.refuse(input);
|
|
58
51
|
}
|
|
59
52
|
return {
|
|
60
53
|
decision,
|
|
61
54
|
isDirectPrincipalGrant: this.trustGrantClassifier.hasDirectPrincipalGrant(decision.trustAllowStatements),
|
|
62
55
|
};
|
|
63
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Refuse the request as the caller that made it.
|
|
59
|
+
*/
|
|
60
|
+
refuse(input) {
|
|
61
|
+
throw new SimIamAccessDenied({
|
|
62
|
+
principal: input.caller.principal,
|
|
63
|
+
action: "sts:AssumeRole",
|
|
64
|
+
resource: input.roleArn,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
64
67
|
}
|
|
@@ -4,7 +4,7 @@ import type { SimAssumeRoleCommand, SimAssumeRoleCommandOutput } from "./assume-
|
|
|
4
4
|
import { type BackgroundScheduler } from "../../../../util/background/background.js";
|
|
5
5
|
import type { SimAwsAccountId } from "../../../aws/sim-aws-account.js";
|
|
6
6
|
import type { AwsRegionName } from "../../../aws/sim-aws-region.js";
|
|
7
|
-
import type { SimAwsCaller } from "../../../aws/caller/sim-aws-caller.js";
|
|
7
|
+
import type { SimAwsCaller, SimAwsDefaultCaller } from "../../../aws/caller/sim-aws-caller.js";
|
|
8
8
|
interface AssumeRoleCommandHandlerProperties {
|
|
9
9
|
readonly sourceAccountId: SimAwsAccountId;
|
|
10
10
|
/**
|
|
@@ -13,6 +13,10 @@ interface AssumeRoleCommandHandlerProperties {
|
|
|
13
13
|
readonly regionName: AwsRegionName;
|
|
14
14
|
readonly iamResolver: SimIamAccountResolver;
|
|
15
15
|
readonly background?: BackgroundScheduler;
|
|
16
|
+
/**
|
|
17
|
+
* The caller this simulation attributes a request naming none to.
|
|
18
|
+
*/
|
|
19
|
+
readonly defaultCaller?: SimAwsDefaultCaller | undefined;
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* STS AssumeRoleCommand handler.
|
|
@@ -16,7 +16,7 @@ import { AssumeRoleAuthorizationCoordinator } from "../../auth-z/assume-role-aut
|
|
|
16
16
|
*/
|
|
17
17
|
export class AssumeRoleCommandHandler {
|
|
18
18
|
background;
|
|
19
|
-
callerResolver
|
|
19
|
+
callerResolver;
|
|
20
20
|
requestParser = new SimStsAssumeRoleRequestParser();
|
|
21
21
|
authorizationCoordinator;
|
|
22
22
|
sessionCreator;
|
|
@@ -25,6 +25,9 @@ export class AssumeRoleCommandHandler {
|
|
|
25
25
|
const { sourceAccountId, regionName, iamResolver, background = new BackgroundTasks(), } = properties;
|
|
26
26
|
this.sourceAccountId = sourceAccountId;
|
|
27
27
|
this.background = background;
|
|
28
|
+
this.callerResolver = new SimAwsCallerResolver({
|
|
29
|
+
defaultCaller: properties.defaultCaller,
|
|
30
|
+
});
|
|
28
31
|
this.authorizationCoordinator = new AssumeRoleAuthorizationCoordinator({
|
|
29
32
|
sourceAccountId,
|
|
30
33
|
iamResolver,
|
|
@@ -56,7 +59,7 @@ export class AssumeRoleCommandHandler {
|
|
|
56
59
|
const role = await this.authorizationCoordinator.authorize({
|
|
57
60
|
roleArn: request.roleArn,
|
|
58
61
|
roleArnParts: request.roleArnParts,
|
|
59
|
-
caller
|
|
62
|
+
caller,
|
|
60
63
|
conditionContext: request.conditionContext,
|
|
61
64
|
});
|
|
62
65
|
return this.sessionCreator.create({
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { CommandHandler } from "../../../../command/command-handler.js";
|
|
2
|
-
import type { SimAwsCaller } from "../../../aws/caller/sim-aws-caller.js";
|
|
2
|
+
import type { SimAwsCaller, SimAwsDefaultCaller } from "../../../aws/caller/sim-aws-caller.js";
|
|
3
3
|
import type { SimAwsAccountId } from "../../../aws/sim-aws-account.js";
|
|
4
4
|
import type { SimIamAccountResolver } from "../../../iam/registry/sim-iam-account-resolver.js";
|
|
5
5
|
import type { SimGetCallerIdentityCommand, SimGetCallerIdentityCommandOutput } from "./get-caller-identity.command.js";
|
|
6
6
|
interface GetCallerIdentityCommandHandlerProperties {
|
|
7
7
|
readonly sourceAccountId: SimAwsAccountId;
|
|
8
8
|
readonly iamResolver: SimIamAccountResolver;
|
|
9
|
+
/**
|
|
10
|
+
* The caller this simulation attributes a request naming none to.
|
|
11
|
+
*/
|
|
12
|
+
readonly defaultCaller?: SimAwsDefaultCaller | undefined;
|
|
9
13
|
}
|
|
10
14
|
/**
|
|
11
15
|
* Simulated STS GetCallerIdentity handler.
|
|
@@ -13,12 +13,15 @@ import { simStsCallerUserId } from "./sim-sts-caller-user-id.js";
|
|
|
13
13
|
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/sts/command/GetCallerIdentityCommand/
|
|
14
14
|
*/
|
|
15
15
|
export class GetCallerIdentityCommandHandler {
|
|
16
|
-
callerResolver
|
|
16
|
+
callerResolver;
|
|
17
17
|
sourceAccountId;
|
|
18
18
|
iamResolver;
|
|
19
19
|
constructor(properties) {
|
|
20
20
|
this.sourceAccountId = properties.sourceAccountId;
|
|
21
21
|
this.iamResolver = properties.iamResolver;
|
|
22
|
+
this.callerResolver = new SimAwsCallerResolver({
|
|
23
|
+
defaultCaller: properties.defaultCaller,
|
|
24
|
+
});
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* Report the identity behind this request.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { simAwsResolvedCallerOf } from "../../aws/caller/sim-aws-resolved-caller.js";
|
|
1
2
|
import { SimIamAccessDenied } from "../../iam/error/sim-iam.error.js";
|
|
2
3
|
import { AssumeRoleTrustPolicyAuthorizer } from "../auth-z/assume-role-trust-policy-authorizer.js";
|
|
3
4
|
import { simServiceRoleConditionContext, } from "./sim-service-role-source.js";
|
|
@@ -25,7 +26,10 @@ export async function assumeSimServiceRole(assumption) {
|
|
|
25
26
|
role,
|
|
26
27
|
targetIam: iam,
|
|
27
28
|
region: scope.accountRegionScope.regionName,
|
|
28
|
-
caller: {
|
|
29
|
+
caller: simAwsResolvedCallerOf({
|
|
30
|
+
kind: "service",
|
|
31
|
+
service: servicePrincipal,
|
|
32
|
+
}),
|
|
29
33
|
conditionContext: simServiceRoleConditionContext(source),
|
|
30
34
|
});
|
|
31
35
|
}
|