mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(sts): read the session tags a request, an assertion and a token pass (#9289)
A session's tags are principal tags of its requests, "when you request a session, you can specify principal tags as the session tags. The tags apply to requests that you make using the session's credentials", and this package read none of them. AssumeRole and GetFederationToken counted the Tags member toward the token size and then dropped it, and the two operations that take session tags inside a SAML assertion or a web identity token, where the model declares no Tags member at all, had nowhere to take them from, so aws:PrincipalTag held only what was stored on the user or the role. A session records the tags it was minted with now, from wherever its own operation takes them: the Tags member on AssumeRole and GetFederationToken, the assertion's https://aws.amazon.com/SAML/Attributes/PrincipalTag:<key> attributes on AssumeRoleWithSAML, and the token's https://aws.amazon.com/tags claims on AssumeRoleWithWebIdentity, in both formats AWS reads those in, the nested object under principal_tags and the flattened claims prefixed https://aws.amazon.com/tags/principal_tags/. GetSessionToken and AssumeRoot declare no way to pass one and record none. What a request publishes is the identity's tags with the session's own over them: the role's tags for a role session, and for a federated user the tags of the user whose key minted it, where it carried none at all, "the session principal tags include the user tags and the passed session tags". A session tag "overrides the role" tag of the same key, matched without case as IAM matches a tag key on a user or a role, "not case sensitive, but case is preserved", so the session's own spelling is the one published. One value per tag: "you must pass a single value for each session tag" and STS "does not support multi-valued session tags". The published nested example writes each value as an array holding one string and the flattened format as a plain claim, so both are read, while a tag carrying more than one value is left unread rather than cut down to its first. A role's trust policy has to permit the tagging as well as the assume: "trust policies for all roles connected to the identity provider passing tags must have the sts:TagSession permission. For roles without this permission in the trust policy, the AssumeRole operation fails." All three assume operations read their own trust policy for that action when the request, the assertion or the token carries a tag, with the same principals and conditions as the assume, and answer AccessDenied naming it. Without that reading a caller the policy lets assume a role could choose the principal tags downstream permissions are conditioned on, which is the whole point of the permission. The caller's own half was already here, the generated tagging table requiring sts:TagSession of a request that carries Tags, so a tagged AssumeRole is held to both policies and a tagged GetFederationToken to the caller's alone, having no trust policy to read. A tag that is not one key with one value is refused rather than read as the first value or dropped: an attribute with several AttributeValue elements or none, an attribute whose name ends at the colon, and a token claim that is neither a string nor a one-element array. Nothing published says what AWS answers a malformed session tag, so those sentences are this package's own, and a tag a policy would have been evaluated with cannot go missing quietly. An assertion's value is stored as it was signed, spaces included, where trimming it would hand a policy a value the provider never asserted. Two tags of one request whose keys differ only in case are one tag, the later winning, as a tag key on an identity is: kept as two they would reach a policy as one key with the other's value dropped, and a Deny on that value would stop matching. Session tags are state the token carries, "session policies and session tags add to the session token size", so they count against the limit and into what the session reports. The two operations that take them from a message measure that once the assertion or the token has been verified, which is the first point the tags exist, rather than before the operation runs where the declared members are read. Two published pieces are left, named on the page rather than guessed at here. The transitive tag keys beside the tags are not read, so no tag passes into a chained session, which is AWS's own default and leaves only the opt-in missing; a key stored unread would have said otherwise. And the plaintext limits a session tag is held to are read where the model declares the members that carry them, which leaves the number and the length of a tag inside an assertion or a token unchecked, nothing published saying what AWS answers there; what does hold them is the token size. Covered end to end under enforcement by a session tag that decides a call and overrides the role's tag of that key, by one that brings a Deny on, by a caller whose trust policy permits the assume but not the tagging, and by a federated session whose tag is the whole of what decides it; over the API by a signed assertion whose attributes reach the session, by a spaced value kept as signed, by an attribute carrying no single value and one naming no key, and by a tag set too large for the token it would be carried in; at the service level by the merge, the case-insensitive replacement within a request and across the identity's tags, and the federated user's two halves; on the handler by the Tags member reaching the session it mints, by the token's tags counting toward what the session reports, and by the long-term session recording nothing; and on the token verifier by both claim formats, a multi-valued tag, a tag with no key and a token that passes none.
This commit is contained in:
1 parent
8a0903f42b
commit
d2a3e2624e
16 files changed
+1048
-114
No files matched your search
@@ -190,6 +190,95 @@ class WebIdentityTokenVerifierTest {
|
||||
assertTrue(thrown.getMessage().contains("not yet valid"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The session tags a token passes in the nested format, "a structure within the
|
||||
* https://aws.amazon.com/tags namespace", where the tags sit "under the principal_tags key".
|
||||
* The published example writes each value as an array holding one string while the prose calls
|
||||
* each tag "a single string value", so both forms are read. The transitive keys beside them are
|
||||
* not read.
|
||||
*/
|
||||
@Test
|
||||
void readsTheSessionTagsOfTheNestedClaimFormat() throws Exception {
|
||||
KeyPair keyPair = newKeyPair();
|
||||
String token = signRs256(keyPair.getPrivate(), claims(
|
||||
"\"https://aws.amazon.com/tags\":{"
|
||||
+ "\"principal_tags\":{\"Project\":[\"Automation\"],\"CostCenter\":\"987654\"},"
|
||||
+ "\"transitive_tag_keys\":[\"Project\"]}"));
|
||||
|
||||
WebIdentityToken verified = verifier.verify(token, (RSAPublicKey) keyPair.getPublic(), ISSUER,
|
||||
EksOidcService.STS_AUDIENCE);
|
||||
|
||||
assertEquals(Map.of("Project", "Automation", "CostCenter", "987654"), verified.principalTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* A tag carrying anything but one string is a multi-valued session tag, which "AWS STS does not
|
||||
* support", and the token is refused rather than verified with that tag quietly dropped: a tag
|
||||
* a policy would have been evaluated with cannot go missing. A tag claim naming no key at all
|
||||
* is refused the same way.
|
||||
*/
|
||||
@Test
|
||||
void refusesATokenWhoseSessionTagCarriesNoSingleValue() throws Exception {
|
||||
KeyPair keyPair = newKeyPair();
|
||||
String multiValued = signRs256(keyPair.getPrivate(), claims(
|
||||
"\"https://aws.amazon.com/tags\":{\"principal_tags\":{\"Teams\":[\"one\",\"two\"]}}"));
|
||||
|
||||
WebIdentityTokenVerifier.InvalidTokenException thrown = assertThrows(
|
||||
WebIdentityTokenVerifier.InvalidTokenException.class,
|
||||
() -> verifier.verify(multiValued, (RSAPublicKey) keyPair.getPublic(), ISSUER,
|
||||
EksOidcService.STS_AUDIENCE));
|
||||
assertTrue(thrown.getMessage().contains("Teams does not carry a single value"),
|
||||
thrown.getMessage());
|
||||
|
||||
String keyless = signRs256(keyPair.getPrivate(),
|
||||
claims("\"https://aws.amazon.com/tags/principal_tags/\":\"Automation\""));
|
||||
|
||||
assertTrue(assertThrows(WebIdentityTokenVerifier.InvalidTokenException.class,
|
||||
() -> verifier.verify(keyless, (RSAPublicKey) keyPair.getPublic(), ISSUER,
|
||||
EksOidcService.STS_AUDIENCE))
|
||||
.getMessage().contains("session tag with no key"));
|
||||
}
|
||||
|
||||
/**
|
||||
* And in the flattened format, "compatible with identity providers that don't support nested
|
||||
* objects in JWT claims", where each tag is "a separate claim with the prefix
|
||||
* https://aws.amazon.com/tags/principal_tags/" and the transitive keys are one claim of their
|
||||
* own, which is not a tag.
|
||||
*/
|
||||
@Test
|
||||
void readsTheSessionTagsOfTheFlattenedClaimFormat() throws Exception {
|
||||
KeyPair keyPair = newKeyPair();
|
||||
String token = signRs256(keyPair.getPrivate(), claims(
|
||||
"\"https://aws.amazon.com/tags/principal_tags/Project\":\"Automation\","
|
||||
+ "\"https://aws.amazon.com/tags/principal_tags/Department\":\"Engineering\","
|
||||
+ "\"https://aws.amazon.com/tags/transitive_tag_keys\":[\"Project\"]"));
|
||||
|
||||
WebIdentityToken verified = verifier.verify(token, (RSAPublicKey) keyPair.getPublic(), ISSUER,
|
||||
EksOidcService.STS_AUDIENCE);
|
||||
|
||||
assertEquals(Map.of("Project", "Automation", "Department", "Engineering"),
|
||||
verified.principalTags());
|
||||
}
|
||||
|
||||
/** A token passing no tags carries none, which is every token this emulator mints itself. */
|
||||
@Test
|
||||
void aTokenWithoutTagClaimsCarriesNoSessionTags() throws Exception {
|
||||
String token = mint("my-namespace", "my-service-account", null, null);
|
||||
|
||||
WebIdentityToken verified = verifier.verify(token, publicKey(), ISSUER,
|
||||
EksOidcService.STS_AUDIENCE);
|
||||
|
||||
assertTrue(verified.principalTags().isEmpty());
|
||||
}
|
||||
|
||||
/** A valid claim set carrying {@code extra} beside the three claims every token needs. */
|
||||
private static String claims(String extra) {
|
||||
long now = System.currentTimeMillis() / 1000;
|
||||
return "{\"iss\":\"" + ISSUER + "\",\"aud\":[\"" + EksOidcService.STS_AUDIENCE + "\"],"
|
||||
+ "\"sub\":\"system:serviceaccount:my-namespace:my-service-account\","
|
||||
+ "\"exp\":" + (now + 3600) + "," + extra + "}";
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsKeyFromAnotherCluster() {
|
||||
String otherIssuer = "https://oidc.eks.us-east-1.amazonaws.com/id/OTHERCLUSTER0000000000000000";
|
||||
|
||||
+154
-14
@@ -58,7 +58,9 @@ import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
@@ -541,6 +543,104 @@ class AssumeRoleWithSamlValidationIntegrationTest {
|
||||
.body(result + "PackedPolicySize", equalTo("25"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The session tags the assertion passes are the session's principal tags: "to pass SAML
|
||||
* attributes as session tags, include the Attribute element with the Name attribute set to
|
||||
* https://aws.amazon.com/SAML/Attributes/PrincipalTag:{TagKey}", which is the only way this
|
||||
* operation takes them, its request declaring no Tags member at all.
|
||||
*/
|
||||
@Test
|
||||
void theAssertionsSessionTagsBecomeTheSessionsPrincipalTags() {
|
||||
String role = createRoleAllowingTags();
|
||||
Map<String, List<String>> tags = Map.of("Project", List.of("Automation"),
|
||||
"CostCenter", List.of("12345"));
|
||||
|
||||
String accessKeyId = assumeRequest(role, assertionCarryingTags(role, tags), PROVIDER)
|
||||
.when().post("/").then().statusCode(200)
|
||||
.extract().path("AssumeRoleWithSAMLResponse.AssumeRoleWithSAMLResult.Credentials.AccessKeyId");
|
||||
|
||||
assertEquals(Map.of("Project", "Automation", "CostCenter", "12345"),
|
||||
iamService.resolveCallerArns(accessKeyId).orElseThrow().principalTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* The value is the one the assertion signed, spaces and all: a tag value may carry them, and
|
||||
* trimming it would hand a policy a value the provider never asserted.
|
||||
*/
|
||||
@Test
|
||||
void aSpacedTagValueIsStoredAsTheAssertionSignedIt() {
|
||||
String role = createRoleAllowingTags();
|
||||
|
||||
String accessKeyId = assumeRequest(role, assertionCarryingTags(role, tag("Team", " admin ")), PROVIDER)
|
||||
.when().post("/").then().statusCode(200)
|
||||
.extract().path("AssumeRoleWithSAMLResponse.AssumeRoleWithSAMLResult.Credentials.AccessKeyId");
|
||||
|
||||
assertEquals(Map.of("Team", " admin "),
|
||||
iamService.resolveCallerArns(accessKeyId).orElseThrow().principalTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* A tag attribute carrying several values is a multi-valued session tag, which AWS STS does not
|
||||
* support, and one carrying none names a tag with no value: both are refused rather than read
|
||||
* as the first value or dropped, so a tag a policy would be evaluated with cannot go missing.
|
||||
*/
|
||||
@Test
|
||||
void aTagAttributeWithoutExactlyOneValueIsRefused() {
|
||||
String role = createRoleAllowingTags();
|
||||
|
||||
assume(role, assertionCarryingTags(role, Map.of("Teams", List.of("one", "two"))), PROVIDER)
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("InvalidIdentityToken"))
|
||||
.body("ErrorResponse.Error.Message",
|
||||
equalTo(SAMLAssertionVerifier.singleValueRequired("Teams")));
|
||||
assume(role, assertionCarryingTags(role, Map.of("Teams", List.of())), PROVIDER)
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Message",
|
||||
equalTo(SAMLAssertionVerifier.singleValueRequired("Teams")));
|
||||
}
|
||||
|
||||
/** And an attribute whose name ends at the colon names no tag key at all. */
|
||||
@Test
|
||||
void aTagAttributeNamingNoKeyIsRefused() {
|
||||
String role = createRoleAllowingTags();
|
||||
|
||||
assume(role, assertionCarryingTags(role, tag("", "Automation")), PROVIDER)
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("InvalidIdentityToken"))
|
||||
.body("ErrorResponse.Error.Message", equalTo(SAMLAssertionVerifier.TAG_KEY_MISSING));
|
||||
}
|
||||
|
||||
/**
|
||||
* The assertion's tags are state the session token carries, so they count against the one
|
||||
* limit it is held to and a set that will not fit is refused before anything is minted. The
|
||||
* request declares no Tags member, so this is measured once the assertion has been verified.
|
||||
*/
|
||||
@Test
|
||||
void anAssertionCarryingTooManyTagsIsRefused() {
|
||||
String role = createRoleAllowingTags();
|
||||
Map<String, List<String>> tags = new LinkedHashMap<>();
|
||||
for (int i = 1; i <= 20; i++) {
|
||||
tags.put("key-" + i, List.of("v".repeat(250)));
|
||||
}
|
||||
|
||||
assume(role, assertionCarryingTags(role, tags), PROVIDER)
|
||||
.statusCode(400)
|
||||
.body("ErrorResponse.Error.Code", equalTo("PackedPolicyTooLarge"));
|
||||
}
|
||||
|
||||
/** A set that does fit is reported as what it cost, the tags counted with the token. */
|
||||
@Test
|
||||
void theAssertionsTagsCountTowardWhatTheSessionReports() {
|
||||
String role = createRoleAllowingTags();
|
||||
String value = "v".repeat(250);
|
||||
|
||||
String result = "AssumeRoleWithSAMLResponse.AssumeRoleWithSAMLResult.";
|
||||
assumeRequest(role, assertionCarryingTags(role, tag("Project", value)), PROVIDER)
|
||||
.when().post("/").then().statusCode(200)
|
||||
.body(result + "SessionTokenSize",
|
||||
equalTo(Integer.toString(200 + "Project".length() + value.length())));
|
||||
}
|
||||
|
||||
private static void assertSignatureInvalid(Function<XMLSignatureFactory, List<Transform>> transforms) {
|
||||
String role = createRole(true);
|
||||
assume(role, assertion(role, PROVIDER, Instant.now().plusSeconds(300), AUDIENCE, ISSUER, true, false, transforms),
|
||||
@@ -577,22 +677,31 @@ class AssumeRoleWithSamlValidationIntegrationTest {
|
||||
}
|
||||
|
||||
private static String createRole(boolean allow) {
|
||||
String role = "saml-role-" + UUID.randomUUID().toString().replace("-", "").substring(0, 12);
|
||||
String trust = allow
|
||||
? "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Federated\":\"" + PROVIDER + "\"},\"Action\":\"sts:AssumeRoleWithSAML\"}]}"
|
||||
: "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Deny\",\"Principal\":{\"Federated\":\"" + PROVIDER + "\"},\"Action\":\"sts:AssumeRoleWithSAML\"}]}";
|
||||
given().contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateRole").formParam("RoleName", role)
|
||||
.formParam("AssumeRolePolicyDocument", trust)
|
||||
.header("Authorization", auth("iam")).when().post("/").then().statusCode(200);
|
||||
ensureProviderRegistered();
|
||||
return "arn:aws:iam::" + ACCOUNT + ":role/" + role;
|
||||
return createRole("saml-role-", "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\""
|
||||
+ (allow ? "Allow" : "Deny") + "\",\"Principal\":{\"Federated\":\"" + PROVIDER
|
||||
+ "\"},\"Action\":\"sts:AssumeRoleWithSAML\"}]}");
|
||||
}
|
||||
|
||||
/**
|
||||
* A role whose trust policy permits tagging the session as well as assuming it, which a tagged
|
||||
* assertion needs: "trust policies for all roles connected to the identity provider passing
|
||||
* tags must have the sts:TagSession permission."
|
||||
*/
|
||||
private static String createRoleAllowingTags() {
|
||||
return createRole("saml-tagged-", "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\","
|
||||
+ "\"Principal\":{\"Federated\":\"" + PROVIDER + "\"},"
|
||||
+ "\"Action\":[\"sts:AssumeRoleWithSAML\",\"sts:TagSession\"]}]}");
|
||||
}
|
||||
|
||||
private static String createRoleWithCondition(String condition) {
|
||||
String role = "saml-session-" + UUID.randomUUID().toString().replace("-", "").substring(0, 12);
|
||||
String trust = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"Federated\":\""
|
||||
+ PROVIDER + "\"},\"Action\":\"sts:AssumeRoleWithSAML\",\"Condition\":" + condition + "}]}";
|
||||
return createRole("saml-session-", "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\","
|
||||
+ "\"Principal\":{\"Federated\":\"" + PROVIDER + "\"},"
|
||||
+ "\"Action\":\"sts:AssumeRoleWithSAML\",\"Condition\":" + condition + "}]}");
|
||||
}
|
||||
|
||||
/** A role of this class's own, named for what its trust policy says, with the provider registered. */
|
||||
private static String createRole(String namePrefix, String trust) {
|
||||
String role = namePrefix + UUID.randomUUID().toString().replace("-", "").substring(0, 12);
|
||||
given().contentType("application/x-www-form-urlencoded")
|
||||
.formParam("Action", "CreateRole").formParam("RoleName", role)
|
||||
.formParam("AssumeRolePolicyDocument", trust)
|
||||
@@ -648,13 +757,44 @@ class AssumeRoleWithSamlValidationIntegrationTest {
|
||||
factory -> List.of(enveloped(factory)), roleSessionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* A valid signed assertion for {@code role} passing {@code tags} as its session tags, each key
|
||||
* written as its own attribute and each value in its own AttributeValue element, so a case can
|
||||
* pass a tag with no value or with several.
|
||||
*/
|
||||
private static String assertionCarryingTags(String role, Map<String, List<String>> tags) {
|
||||
return assertion(role, PROVIDER, Instant.now().plusSeconds(300), AUDIENCE, ISSUER, true, false,
|
||||
factory -> List.of(enveloped(factory)), null, tags);
|
||||
}
|
||||
|
||||
/** One session tag, the shape every case that passes a well-formed one uses. */
|
||||
private static Map<String, List<String>> tag(String key, String value) {
|
||||
return Map.of(key, List.of(value));
|
||||
}
|
||||
|
||||
private static String assertion(String role, String provider, Instant expiry, String audience,
|
||||
String issuer, boolean sign, boolean unrelatedConfirmation,
|
||||
Function<XMLSignatureFactory, List<Transform>> transforms,
|
||||
String roleSessionName) {
|
||||
return assertion(role, provider, expiry, audience, issuer, sign, unrelatedConfirmation, transforms,
|
||||
roleSessionName, Map.of());
|
||||
}
|
||||
|
||||
private static String assertion(String role, String provider, Instant expiry, String audience,
|
||||
String issuer, boolean sign, boolean unrelatedConfirmation,
|
||||
Function<XMLSignatureFactory, List<Transform>> transforms,
|
||||
String roleSessionName, Map<String, List<String>> principalTags) {
|
||||
String sessionNameAttribute = roleSessionName == null ? ""
|
||||
: "<saml:Attribute Name=\"https://aws.amazon.com/SAML/Attributes/RoleSessionName\"><saml:AttributeValue>"
|
||||
+ roleSessionName + "</saml:AttributeValue></saml:Attribute>";
|
||||
StringBuilder tagAttributes = new StringBuilder();
|
||||
principalTags.forEach((key, values) -> {
|
||||
tagAttributes.append("<saml:Attribute Name=\"https://aws.amazon.com/SAML/Attributes/PrincipalTag:")
|
||||
.append(key).append("\">");
|
||||
values.forEach(value -> tagAttributes.append("<saml:AttributeValue>").append(value)
|
||||
.append("</saml:AttributeValue>"));
|
||||
tagAttributes.append("</saml:Attribute>");
|
||||
});
|
||||
String id = "_" + UUID.randomUUID();
|
||||
String extraConfirmation = unrelatedConfirmation
|
||||
? "<saml:SubjectConfirmation Method=\"urn:oasis:names:tc:SAML:2.0:cm:sender-vouches\"><saml:SubjectConfirmationData Recipient=\"https://unrelated.example.test\" NotOnOrAfter=\"" + Instant.now().minusSeconds(1) + "\"/></saml:SubjectConfirmation>"
|
||||
@@ -664,7 +804,7 @@ class AssumeRoleWithSamlValidationIntegrationTest {
|
||||
+ extraConfirmation + "<saml:SubjectConfirmation Method=\"urn:oasis:names:tc:SAML:2.0:cm:bearer\"><saml:SubjectConfirmationData Recipient=\"https://signin.aws.amazon.com/saml\" NotOnOrAfter=\"" + expiry + "\"/></saml:SubjectConfirmation></saml:Subject>"
|
||||
+ "<saml:Conditions NotBefore=\"" + Instant.now().minusSeconds(30) + "\" NotOnOrAfter=\"" + expiry + "\"><saml:AudienceRestriction><saml:Audience>" + audience + "</saml:Audience></saml:AudienceRestriction></saml:Conditions>"
|
||||
+ "<saml:AttributeStatement><saml:Attribute Name=\"https://aws.amazon.com/SAML/Attributes/Role\"><saml:AttributeValue>" + role + "," + provider + "</saml:AttributeValue></saml:Attribute>" + sessionNameAttribute
|
||||
+ "</saml:AttributeStatement></saml:Assertion>";
|
||||
+ tagAttributes + "</saml:AttributeStatement></saml:Assertion>";
|
||||
try {
|
||||
Document document = XmlParser.parseDocument(xml);
|
||||
if (!sign) {
|
||||
|
||||
@@ -555,7 +555,7 @@ class IamServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void userSessionTokensCarryUserTagsButFederatedAndRootSessionsDoNot() {
|
||||
void userAndFederatedSessionsCarryTheUsersTagsButRootSessionsDoNot() {
|
||||
IamUser user = iamService.createUser("tagged", "/");
|
||||
user.setTags(Map.of("Team", "platform"));
|
||||
String key = iamService.createAccessKey("tagged").getAccessKeyId();
|
||||
@@ -567,13 +567,97 @@ class IamServiceTest {
|
||||
iamService.registerIssuedSession("ASIAROOT", "secret", "token", null, expiration,
|
||||
null, "000000000000", "test");
|
||||
Map<String, List<String>> context = new LinkedHashMap<>();
|
||||
iamService.resolveCallerArns("ASIAUSER").orElseThrow().putPrincipalKeys(context);
|
||||
assertEquals(List.of("platform"), context.get("aws:PrincipalTag/Team"));
|
||||
for (String session : List.of("ASIAFEDERATED", "ASIAROOT")) {
|
||||
// The federated user's own half of what the guide gives it: "the session principal tags
|
||||
// include the user tags and the passed session tags".
|
||||
for (String session : List.of("ASIAUSER", "ASIAFEDERATED")) {
|
||||
context.clear();
|
||||
iamService.resolveCallerArns(session).orElseThrow().putPrincipalKeys(context);
|
||||
assertFalse(context.containsKey("aws:PrincipalTag/Team"));
|
||||
assertEquals(List.of("platform"), context.get("aws:PrincipalTag/Team"));
|
||||
}
|
||||
context.clear();
|
||||
iamService.resolveCallerArns("ASIAROOT").orElseThrow().putPrincipalKeys(context);
|
||||
assertFalse(context.containsKey("aws:PrincipalTag/Team"));
|
||||
}
|
||||
|
||||
/**
|
||||
* A session's own tags are principal tags of its requests, over the tags of the identity it
|
||||
* acts as: "when you request a session, you can specify principal tags as the session tags.
|
||||
* The tags apply to requests that you make using the session's credentials."
|
||||
*/
|
||||
@Test
|
||||
void sessionTagsArePublishedOverTheTagsOfTheIdentityTheSessionActsAs() {
|
||||
IamRole role = iamService.createRole("Tagged", "/", EMPTY_POLICY_DOCUMENT, null, 3600, null);
|
||||
role.setTags(Map.of("Team", "role-team", "Owner", "platform"));
|
||||
iamService.registerSession("ASIASESSIONTAGS", "secret", "token", role.getArn(),
|
||||
Instant.now().plusSeconds(3600), null, "000000000000", "tagged", "AROATAGGED:tagged");
|
||||
iamService.recordSessionTags("ASIASESSIONTAGS", Map.of("Team", "session-team", "Project", "atlas"));
|
||||
|
||||
Map<String, List<String>> context = new LinkedHashMap<>();
|
||||
iamService.resolveCallerArns("ASIASESSIONTAGS").orElseThrow().putPrincipalKeys(context);
|
||||
|
||||
assertEquals(List.of("session-team"), context.get("aws:PrincipalTag/Team"));
|
||||
assertEquals(List.of("atlas"), context.get("aws:PrincipalTag/Project"));
|
||||
assertEquals(List.of("platform"), context.get("aws:PrincipalTag/Owner"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The key a session tag replaces is matched without case, as IAM matches a tag key on a user or
|
||||
* a role: a new session tag overrides an existing one "regardless of character case", and the
|
||||
* spelling published is the session's own.
|
||||
*/
|
||||
@Test
|
||||
void aSessionTagReplacesTheIdentityTagOfThatKeyWhateverItsCase() {
|
||||
IamRole role = iamService.createRole("CaseTagged", "/", EMPTY_POLICY_DOCUMENT, null, 3600, null);
|
||||
role.setTags(Map.of("department", "finance"));
|
||||
iamService.registerSession("ASIACASETAGS", "secret", "token", role.getArn(),
|
||||
Instant.now().plusSeconds(3600), null, "000000000000", "cased", "AROACASED:cased");
|
||||
iamService.recordSessionTags("ASIACASETAGS", Map.of("Department", "engineering"));
|
||||
|
||||
Map<String, List<String>> context = new LinkedHashMap<>();
|
||||
iamService.resolveCallerArns("ASIACASETAGS").orElseThrow().putPrincipalKeys(context);
|
||||
|
||||
assertEquals(List.of("engineering"), context.get("aws:PrincipalTag/Department"));
|
||||
assertFalse(context.containsKey("aws:PrincipalTag/department"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Two session tags whose keys differ only in case are one tag, the later winning, as a tag key
|
||||
* on an identity is: "you cannot have separate Department and department tag keys". Kept as two
|
||||
* they would reach a policy as one key with the other's value dropped.
|
||||
*/
|
||||
@Test
|
||||
void sessionTagsThatDifferOnlyInCaseAreOneTag() {
|
||||
IamRole role = iamService.createRole("OneTag", "/", EMPTY_POLICY_DOCUMENT, null, 3600, null);
|
||||
iamService.registerSession("ASIAONETAG", "secret", "token", role.getArn(),
|
||||
Instant.now().plusSeconds(3600), null, "000000000000", "one", "AROAONE:one");
|
||||
Map<String, String> sent = new LinkedHashMap<>();
|
||||
sent.put("Team", "first");
|
||||
sent.put("team", "second");
|
||||
iamService.recordSessionTags("ASIAONETAG", sent);
|
||||
|
||||
Map<String, List<String>> context = new LinkedHashMap<>();
|
||||
iamService.resolveCallerArns("ASIAONETAG").orElseThrow().putPrincipalKeys(context);
|
||||
|
||||
assertEquals(List.of("second"), context.get("aws:PrincipalTag/team"));
|
||||
assertFalse(context.containsKey("aws:PrincipalTag/Team"));
|
||||
}
|
||||
|
||||
/** A federated user's session tags join the tags of the user whose key minted the session. */
|
||||
@Test
|
||||
void federatedSessionTagsJoinTheIssuingUsersTags() {
|
||||
IamUser user = iamService.createUser("federated-tagged", "/");
|
||||
user.setTags(Map.of("Team", "platform"));
|
||||
String key = iamService.createAccessKey("federated-tagged").getAccessKeyId();
|
||||
iamService.registerIssuedSession("ASIAFEDTAGS", "secret", "token",
|
||||
"arn:aws:sts::000000000000:federated-user/federated-tagged",
|
||||
Instant.now().plusSeconds(3600), null, "000000000000", key);
|
||||
iamService.recordSessionTags("ASIAFEDTAGS", Map.of("Project", "atlas"));
|
||||
|
||||
Map<String, List<String>> context = new LinkedHashMap<>();
|
||||
iamService.resolveCallerArns("ASIAFEDTAGS").orElseThrow().putPrincipalKeys(context);
|
||||
|
||||
assertEquals(List.of("platform"), context.get("aws:PrincipalTag/Team"));
|
||||
assertEquals(List.of("atlas"), context.get("aws:PrincipalTag/Project"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+166
-2
@@ -27,12 +27,26 @@ import java.util.UUID;
|
||||
import static io.floci.aws.testing.EnforcementFixtures.auth;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(IamEnforcementProfile.class)
|
||||
class PrincipalTagEnforcementIntegrationTest {
|
||||
private static final String ACCOUNT = "111111111111";
|
||||
private static final String OTHER_ACCOUNT = "222222222222";
|
||||
/**
|
||||
* What a caller needs of its own policy to pass session tags, beside the operation itself:
|
||||
* the generated tagging table has {@code sts:AssumeRole} and {@code sts:GetFederationToken}
|
||||
* requiring {@code sts:TagSession} of a request that carries {@code Tags}, which the
|
||||
* enforcement filter reads before the operation runs. The role's trust policy is a separate
|
||||
* permission, and the cases below tell the two refusals apart by their sentences.
|
||||
*/
|
||||
private static final String ALLOW_TAGGING = """
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"sts:TagSession","Resource":"*"}]}""";
|
||||
private static final String ALLOW_FEDERATION = """
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow",
|
||||
"Action":["sts:GetFederationToken","sts:TagSession"],"Resource":"*"}]}""";
|
||||
|
||||
private static final String ALLOW_ASSUME = """
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"sts:AssumeRole","Resource":"*"}]}""";
|
||||
private static final String TAG_POLICY = """
|
||||
@@ -135,6 +149,125 @@ class PrincipalTagEnforcementIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A session's own tags are principal tags of its requests, over the tags of the role it
|
||||
* assumed: "when you request a session, you can specify principal tags as the session tags.
|
||||
* The tags apply to requests that you make using the session's credentials", and a session tag
|
||||
* overrides the role's tag of the same key. The role here carries the wrong team, so only the
|
||||
* session that passes the right one is allowed, and a session tag of its own can bring the Deny
|
||||
* on as well.
|
||||
*/
|
||||
@Test
|
||||
void sessionTagsDecideTheCallAndOverrideTheRolesOwnTags() {
|
||||
String name = "principal-session-" + suffix();
|
||||
String source = "principal-passer-" + suffix();
|
||||
UserCredentials keys = user(ACCOUNT, source, ALLOW_ASSUME);
|
||||
policy(source, "tagging", ALLOW_TAGGING);
|
||||
try (IamClient admin = admin(ACCOUNT);
|
||||
StsClient sts = AwsTestClients.create(StsClient.builder(), keys.accessKeyId(), keys.secretAccessKey(),
|
||||
Region.US_EAST_1)) {
|
||||
String target = role(admin, ACCOUNT, name, trustAllowingTags(), TAG_POLICY);
|
||||
admin.tagRole(r -> r.roleName(name).tags(tag("Team", "other")));
|
||||
|
||||
Credentials passed = sts.assumeRole(r -> r.roleArn(target).roleSessionName("passed")
|
||||
.tags(sessionTag("Team", "platform"))).credentials();
|
||||
try (IamClient caller = sessionClient(passed)) {
|
||||
caller.listUsers();
|
||||
}
|
||||
|
||||
Credentials none = sts.assumeRole(r -> r.roleArn(target).roleSessionName("none")).credentials();
|
||||
try (IamClient caller = sessionClient(none)) {
|
||||
denied(caller::listUsers);
|
||||
}
|
||||
|
||||
Credentials blocked = sts.assumeRole(r -> r.roleArn(target).roleSessionName("blocked")
|
||||
.tags(sessionTag("Team", "platform"), sessionTag("Blocked", "yes"))).credentials();
|
||||
try (IamClient caller = sessionClient(blocked)) {
|
||||
denied(caller::listUsers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A caller the trust policy lets assume the role but not tag the session cannot choose its own
|
||||
* principal tags: "for roles without this permission in the trust policy, the AssumeRole
|
||||
* operation fails". The same role is assumable without tags, so what is refused is the tagging.
|
||||
*/
|
||||
@Test
|
||||
void aTaggedAssumeNeedsTheTrustPolicysPermissionToTag() {
|
||||
String name = "principal-untagged-" + suffix();
|
||||
String source = "principal-untrusted-" + suffix();
|
||||
UserCredentials keys = user(ACCOUNT, source, ALLOW_ASSUME);
|
||||
policy(source, "tagging", ALLOW_TAGGING);
|
||||
try (IamClient admin = admin(ACCOUNT);
|
||||
StsClient sts = AwsTestClients.create(StsClient.builder(), keys.accessKeyId(), keys.secretAccessKey(),
|
||||
Region.US_EAST_1)) {
|
||||
String target = role(admin, ACCOUNT, name, trust(null), TAG_POLICY);
|
||||
|
||||
AwsServiceException refused = assertThrows(AwsServiceException.class,
|
||||
() -> sts.assumeRole(r -> r.roleArn(target).roleSessionName("tagged")
|
||||
.tags(sessionTag("Team", "platform"))));
|
||||
assertEquals(403, refused.statusCode());
|
||||
// The role's own refusal, which names the resource it was read for, rather than the
|
||||
// caller's policy being short of the action: that grant is in place here.
|
||||
assertTrue(refused.awsErrorDetails().errorMessage()
|
||||
.endsWith("is not authorized to perform: sts:TagSession on resource: " + target),
|
||||
refused.awsErrorDetails().errorMessage());
|
||||
sts.assumeRole(r -> r.roleArn(target).roleSessionName("untagged"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A federated user's session tags are principal tags of its requests, beside the tags of the
|
||||
* user whose key minted it: "when you use the temporary credentials returned by the
|
||||
* GetFederationToken operation, the session principal tags include the user tags and the passed
|
||||
* session tags". The user is untagged here, so the session tag is the whole of what decides the
|
||||
* call.
|
||||
*
|
||||
* <p>The probe is an object read rather than an IAM call, which such a session never reaches,
|
||||
* and it carries the session policy AWS requires of it: without one "the temporary security
|
||||
* credentials will not grant any permissions", so the policy is what the tag is read in.
|
||||
*/
|
||||
@Test
|
||||
void federatedSessionTagsJoinTheIssuingUsersTags() {
|
||||
String bucket = "principal-federated-" + suffix();
|
||||
String name = "principal-fed-user-" + suffix();
|
||||
String read = """
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:GetObject",
|
||||
"Resource":"arn:aws:s3:::%s/*"}]}""".formatted(bucket);
|
||||
String readWhenTagged = """
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:GetObject",
|
||||
"Resource":"arn:aws:s3:::%s/*",
|
||||
"Condition":{"StringEquals":{"aws:PrincipalTag/Team":"platform"}}}]}""".formatted(bucket);
|
||||
UserCredentials keys = user(ACCOUNT, name, read);
|
||||
policy(name, "federation", ALLOW_FEDERATION);
|
||||
try (S3Client owner = AwsTestClients.create(S3Client.builder().forcePathStyle(true), ACCOUNT, Region.US_EAST_1);
|
||||
StsClient sts = AwsTestClients.create(StsClient.builder(), keys.accessKeyId(), keys.secretAccessKey(),
|
||||
Region.US_EAST_1)) {
|
||||
owner.createBucket(r -> r.bucket(bucket));
|
||||
cleanup.register(() -> {
|
||||
try (S3Client client = AwsTestClients.create(S3Client.builder().forcePathStyle(true),
|
||||
ACCOUNT, Region.US_EAST_1)) {
|
||||
client.deleteObject(r -> r.bucket(bucket).key("key"));
|
||||
client.deleteBucket(r -> r.bucket(bucket));
|
||||
}
|
||||
});
|
||||
owner.putObject(r -> r.bucket(bucket).key("key"), RequestBody.fromString("content"));
|
||||
|
||||
Credentials tagged = sts.getFederationToken(r -> r.name("fed-" + suffix()).policy(readWhenTagged)
|
||||
.tags(sessionTag("Team", "platform"))).credentials();
|
||||
try (S3Client reader = federatedClient(tagged)) {
|
||||
assertEquals("content", reader.getObjectAsBytes(r -> r.bucket(bucket).key("key")).asUtf8String());
|
||||
}
|
||||
|
||||
Credentials untagged = sts.getFederationToken(r -> r.name("fed-" + suffix())
|
||||
.policy(readWhenTagged)).credentials();
|
||||
try (S3Client reader = federatedClient(untagged)) {
|
||||
denied(() -> reader.getObjectAsBytes(r -> r.bucket(bucket).key("key")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void sameNamedUsersInDifferentAccountsKeepTheirOwnTags() {
|
||||
String name = "principal-account-" + suffix();
|
||||
@@ -185,6 +318,11 @@ class PrincipalTagEnforcementIntegrationTest {
|
||||
return keys;
|
||||
}
|
||||
|
||||
/** A second inline policy on a user of this account, for a case that needs two grants. */
|
||||
private void policy(String userName, String policyName, String document) {
|
||||
EnforcementFixtures.putUserPolicy(baseUri.getPort(), auth(ACCOUNT, "iam"), userName, policyName, document);
|
||||
}
|
||||
|
||||
private String role(IamClient admin, String account, String name, String trust, String policy) {
|
||||
String arn = admin.createRole(r -> r.roleName(name).path("/teams/platform/")
|
||||
.assumeRolePolicyDocument(trust)).role().arn();
|
||||
@@ -194,10 +332,23 @@ class PrincipalTagEnforcementIntegrationTest {
|
||||
}
|
||||
|
||||
private static String trust(String team) {
|
||||
return trust(team, "\"sts:AssumeRole\"");
|
||||
}
|
||||
|
||||
/**
|
||||
* A trust policy that permits tagging the session as well as assuming the role, which a
|
||||
* request passing session tags needs: "trust policies for all roles connected to the identity
|
||||
* provider passing tags must have the sts:TagSession permission."
|
||||
*/
|
||||
private static String trustAllowingTags() {
|
||||
return trust(null, "[\"sts:AssumeRole\",\"sts:TagSession\"]");
|
||||
}
|
||||
|
||||
private static String trust(String team, String action) {
|
||||
String condition = team == null ? "" : ",\"Condition\":{\"StringEquals\":{\"aws:PrincipalTag/Team\":\"" + team + "\"}}";
|
||||
return """
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"sts:AssumeRole",
|
||||
"Principal":{"AWS":"arn:aws:iam::%s:root"}%s}]}""".formatted(ACCOUNT, condition);
|
||||
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":%s,
|
||||
"Principal":{"AWS":"arn:aws:iam::%s:root"}%s}]}""".formatted(action, ACCOUNT, condition);
|
||||
}
|
||||
|
||||
private static IamClient admin(String account) {
|
||||
@@ -215,6 +366,11 @@ class PrincipalTagEnforcementIntegrationTest {
|
||||
.tokenCode(device.codeNow())).credentials();
|
||||
}
|
||||
|
||||
private S3Client federatedClient(Credentials session) {
|
||||
return AwsTestClients.create(S3Client.builder().forcePathStyle(true), sessionCredentials(session),
|
||||
Region.US_EAST_1, baseUri);
|
||||
}
|
||||
|
||||
private IamClient sessionClient(Credentials session) {
|
||||
return AwsTestClients.create(IamClient.builder(), sessionCredentials(session), Region.US_EAST_1, baseUri);
|
||||
}
|
||||
@@ -233,6 +389,14 @@ class PrincipalTagEnforcementIntegrationTest {
|
||||
return Tag.builder().key(key).value(value).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* A session tag for a request that mints a session. Both services model a {@code Tag} of their
|
||||
* own, and IAM's is the one this class names most, so STS's is qualified here, once.
|
||||
*/
|
||||
private static software.amazon.awssdk.services.sts.model.Tag sessionTag(String key, String value) {
|
||||
return software.amazon.awssdk.services.sts.model.Tag.builder().key(key).value(value).build();
|
||||
}
|
||||
|
||||
private static String suffix() {
|
||||
return UUID.randomUUID().toString().substring(0, 8);
|
||||
}
|
||||
|
||||
@@ -449,6 +449,41 @@ class StsQueryHandlerTest {
|
||||
assertFalse(StsRequestShapes.hasMember("AssumeRoot", "Tags"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The tags the request's own {@code Tags} member carries are recorded on the session the
|
||||
* operation mints, which is what its requests then publish as {@code aws:PrincipalTag}. An
|
||||
* operation that declares no such member records nothing: the long-term session mints from the
|
||||
* caller's own credentials and takes no tags at all.
|
||||
*/
|
||||
@Test
|
||||
void theTagsAnOperationDeclaresAreRecordedOnTheSessionItMints() {
|
||||
IamRole role = new IamRole();
|
||||
role.setRoleName("TestRole");
|
||||
role.setArn("arn:aws:iam::000000000000:role/TestRole");
|
||||
IamService assumed = mock(IamService.class);
|
||||
when(assumed.findRole(anyString(), anyString())).thenReturn(Optional.of(role));
|
||||
MultivaluedMap<String, String> params = sessionRequest("AssumeRole");
|
||||
params.putSingle("Tags.member.1.Key", "Project");
|
||||
params.putSingle("Tags.member.1.Value", "atlas");
|
||||
|
||||
Response response = newHandler(assumed, new RegionResolver(REGION, "000000000000"))
|
||||
.handle("AssumeRole", params);
|
||||
|
||||
assertEquals(200, response.getStatus(), (String) response.getEntity());
|
||||
verify(assumed).recordSessionTags(anyString(), eq(Map.of("Project", "atlas")));
|
||||
|
||||
IamService longTerm = mock(IamService.class);
|
||||
MultivaluedMap<String, String> untagged = sessionRequest("GetSessionToken");
|
||||
untagged.putSingle("Tags.member.1.Key", "Project");
|
||||
untagged.putSingle("Tags.member.1.Value", "atlas");
|
||||
|
||||
Response longTermResponse = newHandler(longTerm, new RegionResolver(REGION, "000000000000"))
|
||||
.handle("GetSessionToken", untagged);
|
||||
|
||||
assertEquals(200, longTermResponse.getStatus(), (String) longTermResponse.getEntity());
|
||||
verify(longTerm, never()).recordSessionTags(anyString(), anyMap());
|
||||
}
|
||||
|
||||
/** The least a request needs to reach issuance on an operation that models a token size. */
|
||||
private static MultivaluedMap<String, String> sessionRequest(String action) {
|
||||
Map<String, String> members = switch (action) {
|
||||
@@ -1011,7 +1046,8 @@ class StsQueryHandlerTest {
|
||||
* A role and its account's OIDC provider are IAM resources of one partition, so a trust policy
|
||||
* naming the provider ARN CreateOpenIDConnectProvider returned keeps matching and the session
|
||||
* lands in the stored role's partition, whatever region AssumeRoleWithWebIdentity is signed for
|
||||
* and whichever partition its RoleArn names.
|
||||
* and whichever partition its RoleArn names. The session tags the token passed are recorded on
|
||||
* it as well, this operation taking them from the token rather than from a request member.
|
||||
*/
|
||||
@Test
|
||||
void webIdentityMatchesTheProviderAndMintsTheSessionInTheRolesPartition() throws Exception {
|
||||
@@ -1034,11 +1070,14 @@ class StsQueryHandlerTest {
|
||||
when(verifier.peekIssuer("jwt0")).thenReturn(Optional.of(issuer));
|
||||
when(verifier.verify(eq("jwt0"), any(), eq(issuer), anyString()))
|
||||
.thenReturn(new WebIdentityToken(issuer, "system:serviceaccount:default:app",
|
||||
List.of("sts.amazonaws.com")));
|
||||
List.of("sts.amazonaws.com"), Map.of("Project", "atlas")));
|
||||
OidcIssuerKeyLookup keys = mock(OidcIssuerKeyLookup.class);
|
||||
when(keys.findVerificationKey(issuer)).thenReturn(Optional.of(mock(RSAPublicKey.class)));
|
||||
WebIdentityTrustPolicyEvaluator trust = mock(WebIdentityTrustPolicyEvaluator.class);
|
||||
when(trust.allows(eq("{}"), eq(providerArn), eq("oidc.example.com/id/ABC"), anyMap(), eq("app"))).thenReturn(true);
|
||||
// The token passes a session tag, which the trust policy has to permit as well.
|
||||
when(trust.allowsTagging(eq("{}"), eq(providerArn), eq("oidc.example.com/id/ABC"), anyMap(), eq("app")))
|
||||
.thenReturn(true);
|
||||
|
||||
StsQueryHandler handler = new StsQueryHandler(iamService, mock(AccountResolver.class),
|
||||
new RegionResolver(REGION, "000000000000"), config, mock(AssumeRolePolicyEvaluator.class),
|
||||
@@ -1056,6 +1095,10 @@ class StsQueryHandlerTest {
|
||||
verify(trust).allows(eq("{}"), eq(providerArn), eq("oidc.example.com/id/ABC"), anyMap(), eq("app"));
|
||||
assertEquals("arn:aws-cn:sts::000000000000:assumed-role/web-role/app",
|
||||
extract(ARN, (String) response.getEntity()));
|
||||
verify(iamService).recordSessionTags(anyString(), eq(Map.of("Project", "atlas")));
|
||||
// The token's tags are state its session carries, so they count with the token itself.
|
||||
assertEquals(Integer.toString(200 + "Project".length() + "atlas".length()),
|
||||
extract(SESSION_TOKEN_SIZE, (String) response.getEntity()));
|
||||
}
|
||||
|
||||
/** A session keeps its role's partition even when AssumeRole is signed for another one. */
|
||||
|
||||
Reference in new issue
Block a user