mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-11 20:29:01 +00:00
Address greptile comments
This commit is contained in:
@@ -31,7 +31,8 @@ import { compileUsernameTemplate } from "./templateUtils";
|
||||
|
||||
// AWS STS duration constants (in seconds)
|
||||
const AWS_STS_MIN_DURATION = 900;
|
||||
const AWS_STS_MAX_DURATION_SESSION_TOKEN = 43200;
|
||||
const AWS_STS_MAX_DURATION_SESSION_TOKEN = 43200; // 12 hours for GetSessionToken
|
||||
const AWS_STS_MAX_DURATION_ASSUME_ROLE = 3600; // 1 hour for AssumeRole when using temp credentials
|
||||
|
||||
const generateUsername = (usernameTemplate?: string | null, identity?: { name: string }) => {
|
||||
const randomUsername = alphaNumericNanoId(32);
|
||||
@@ -200,14 +201,6 @@ export const AwsIamProvider = (): TDynamicProviderFns => {
|
||||
if (providerInputs.method === AwsIamAuthType.AssumeRole) {
|
||||
sensitiveTokens.push(providerInputs.roleArn);
|
||||
}
|
||||
if (providerInputs.credentialType === AwsIamCredentialType.TemporaryCredentials) {
|
||||
if (providerInputs.method === AwsIamAuthType.AccessKey) {
|
||||
sensitiveTokens.push(providerInputs.accessKey, providerInputs.secretAccessKey);
|
||||
}
|
||||
if (providerInputs.method === AwsIamAuthType.AssumeRole) {
|
||||
sensitiveTokens.push(providerInputs.roleArn);
|
||||
}
|
||||
}
|
||||
const sanitizedErrorMessage = sanitizeString({
|
||||
unsanitizedString: (err as Error)?.message,
|
||||
tokens: sensitiveTokens
|
||||
@@ -243,9 +236,11 @@ export const AwsIamProvider = (): TDynamicProviderFns => {
|
||||
throw new BadRequestError({ message: "Expiration time must be in the future" });
|
||||
}
|
||||
|
||||
let durationSeconds = Math.min(requestedDuration, AWS_STS_MAX_DURATION_SESSION_TOKEN);
|
||||
let durationSeconds: number;
|
||||
|
||||
if (providerInputs.method === AwsIamAuthType.AssumeRole) {
|
||||
// AssumeRole has a lower maximum duration when using temporary credentials
|
||||
durationSeconds = Math.min(requestedDuration, AWS_STS_MAX_DURATION_ASSUME_ROLE);
|
||||
const appCfg = getConfig();
|
||||
stsClient = new STSClient({
|
||||
region: providerInputs.region,
|
||||
@@ -260,8 +255,6 @@ export const AwsIamProvider = (): TDynamicProviderFns => {
|
||||
: undefined
|
||||
});
|
||||
|
||||
durationSeconds = Math.min(durationSeconds, AWS_STS_MAX_DURATION_SESSION_TOKEN);
|
||||
|
||||
const assumeRoleRes = await stsClient.send(
|
||||
new AssumeRoleCommand({
|
||||
RoleArn: providerInputs.roleArn,
|
||||
@@ -290,6 +283,8 @@ export const AwsIamProvider = (): TDynamicProviderFns => {
|
||||
};
|
||||
}
|
||||
if (providerInputs.method === AwsIamAuthType.AccessKey) {
|
||||
// GetSessionToken supports longer durations
|
||||
durationSeconds = Math.min(requestedDuration, AWS_STS_MAX_DURATION_SESSION_TOKEN);
|
||||
stsClient = new STSClient({
|
||||
region: providerInputs.region,
|
||||
useFipsEndpoint: crypto.isFipsModeEnabled(),
|
||||
@@ -325,6 +320,8 @@ export const AwsIamProvider = (): TDynamicProviderFns => {
|
||||
};
|
||||
}
|
||||
if (providerInputs.method === AwsIamAuthType.IRSA) {
|
||||
// GetSessionToken supports longer durations
|
||||
durationSeconds = Math.min(requestedDuration, AWS_STS_MAX_DURATION_SESSION_TOKEN);
|
||||
stsClient = new STSClient({
|
||||
region: providerInputs.region,
|
||||
useFipsEndpoint: crypto.isFipsModeEnabled(),
|
||||
|
||||
Reference in New Issue
Block a user