mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(sts): require long-term callers for federation tokens (#5586)
* fix(sts): require long-term callers for federation tokens * fix(sts): preserve temporary federation caller refusals * fix(sts): refuse temporary federation callers before dispatch
This commit is contained in:
1 parent
5e48cbb80b
commit
c907eec9d2
10 files changed
+292
-49
No files matched your search
@@ -63,6 +63,9 @@ import java.util.regex.Pattern;
|
||||
* key itself is still checked.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Authenticated temporary callers of {@code sts:GetFederationToken} are refused here with
|
||||
* the same operation-specific error as the handler, before policy evaluation.
|
||||
*
|
||||
* <p>Evaluates the caller's identity policies, optional session policy, and optional
|
||||
* permissions boundary, as well as applicable resource policies via {@link ResourcePolicyProvider}.
|
||||
*
|
||||
@@ -365,6 +368,11 @@ public class IamEnforcementFilter implements ContainerRequestFilter {
|
||||
return; // AWS returns caller identity even when an identity policy explicitly denies it
|
||||
}
|
||||
|
||||
if ("sts:GetFederationToken".equals(action) && IamService.isTemporaryAccessKey(akid)) {
|
||||
ctx.abortWith(queryXmlAccessDenied(IamService.FEDERATION_TOKEN_SESSION_MESSAGE));
|
||||
return;
|
||||
}
|
||||
|
||||
// Service control policies from the caller's organization, when the Organizations
|
||||
// service is present and SCP enforcement is enabled. Resolved lazily via Instance
|
||||
// to avoid a hard IAM → Organizations dependency.
|
||||
|
||||
@@ -101,6 +101,9 @@ import java.util.stream.Stream;
|
||||
@ApplicationScoped
|
||||
public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
|
||||
public static final String FEDERATION_TOKEN_SESSION_MESSAGE =
|
||||
"Cannot call GetFederationToken with session credentials";
|
||||
|
||||
private static final int ROLE_INLINE_POLICY_SIZE_LIMIT = 10_240;
|
||||
private static final Logger LOG = Logger.getLogger(IamService.class);
|
||||
private static final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
@@ -537,6 +537,10 @@ public class StsQueryHandler {
|
||||
}
|
||||
|
||||
private Response handleGetFederationToken(MultivaluedMap<String, String> params) {
|
||||
if (IamService.isTemporaryAccessKey(callerAccessKeyId())) {
|
||||
return AwsQueryResponse.error("AccessDenied", IamService.FEDERATION_TOKEN_SESSION_MESSAGE,
|
||||
AwsNamespaces.STS, 403);
|
||||
}
|
||||
Response validation = validateRequired(params, "Name");
|
||||
if (validation != null) {
|
||||
return validation;
|
||||
|
||||
Reference in new issue
Block a user