mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(iam): look the user up before the service name on a credential request (#8314)
CreateServiceSpecificCredential resolved the service name first, so a request that named a user who does not exist and a service that is not supported was answered for the service. AWS answers for the user: a recording validated against a real account asks for a credential as a user that was never created, once with CodeCommit and once with a service name nothing supports, and both come back NoSuchEntity with "The user with name <name> cannot be found." The user is confirmed before the service name is read now, under the lock it was already taken under. ListServiceSpecificCredentials had the same shape, with its ServiceName filter resolved ahead of the user it lists for, and reads the two the same way round. Under AllUsers there is no user to look up, so an unsupported filter still answers for itself. What the bounds of CredentialAgeDays say is settled ahead of both by the constraints every request is held to, so only the question that needs the service is left behind it: whether this service takes the member at all. The in-operation bounds stay where they are as the backstop they became.
This commit is contained in:
1 parent
a138f88094
commit
aa2adac677
3 files changed
+79
-17
No files matched your search
@@ -325,6 +325,49 @@ class ServiceSpecificCredentialIntegrationTest {
|
||||
.when().post("/").then().statusCode(400).body(containsString("ValidationError"));
|
||||
}
|
||||
|
||||
/**
|
||||
* A request wrong in both halves is answered for the user. Recordings validated against AWS
|
||||
* answer a user that does not exist with the user whether the service beside it is supported
|
||||
* or not, so the user is looked up before the service name is read.
|
||||
*/
|
||||
@Test
|
||||
void aRequestNamingNeitherAUserNorASupportedServiceAnswersForTheUser() {
|
||||
String missing = "ssc-absent-" + suffix();
|
||||
|
||||
for (String service : List.of(CODECOMMIT, "nonexistentservice.amazonaws.com",
|
||||
"lambda.amazonaws.com", "o3on3n3onosneo", "")) {
|
||||
iam("CreateServiceSpecificCredential")
|
||||
.formParam("UserName", missing)
|
||||
.formParam("ServiceName", service)
|
||||
.when().post("/").then().statusCode(404)
|
||||
.body(containsString("NoSuchEntity"))
|
||||
.body(containsString("The user with name " + missing + " cannot be found."))
|
||||
.body(not(containsString("No such service")));
|
||||
}
|
||||
}
|
||||
|
||||
/** The list reads the two the same way round, and AllUsers leaves the filter alone to be wrong. */
|
||||
@Test
|
||||
void theListAnswersForTheUserBeforeTheServiceFilter() {
|
||||
String missing = "ssc-absent-list-" + suffix();
|
||||
|
||||
iam("ListServiceSpecificCredentials")
|
||||
.formParam("UserName", missing)
|
||||
.formParam("ServiceName", "nonexistentservice.amazonaws.com")
|
||||
.when().post("/").then().statusCode(404)
|
||||
.body(containsString("NoSuchEntity"))
|
||||
.body(containsString("The user with name " + missing + " cannot be found."))
|
||||
.body(not(containsString("No such service")));
|
||||
|
||||
iam("ListServiceSpecificCredentials")
|
||||
.formParam("AllUsers", "true")
|
||||
.formParam("ServiceName", "nonexistentservice.amazonaws.com")
|
||||
.when().post("/").then().statusCode(404)
|
||||
.body(containsString("NoSuchEntity"))
|
||||
.body(containsString("No such service nonexistentservice.amazonaws.com "
|
||||
+ "is supported for Service Specific Credentials"));
|
||||
}
|
||||
|
||||
/** The list takes the same filter, so it rejects the same way. */
|
||||
@Test
|
||||
void theListRefusesAnUnsupportedServiceFilter() {
|
||||
|
||||
Reference in new issue
Block a user