Skip to content

Commit 8da8d39

Browse files
committed
Merge branch 'bugfix/ARSN-387-ssl-check-fix' into tmp/octopus/w/7.70/bugfix/ARSN-387-ssl-check-fix
2 parents 69dbbb1 + 0466eb4 commit 8da8d39

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

lib/policyEvaluator/utils/conditions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function findConditionKey(
6161
case 'aws:referer': return headers.referer;
6262
// aws:SecureTransport – Used to check whether the request was sent
6363
// using SSL (see Boolean Condition Operators).
64-
case 'aws:SecureTransport': return requestContext.getSslEnabled() ? 'true' : 'false';
64+
case 'aws:SecureTransport': return headers?.['x-forwarded-proto'] === 'https' ? 'true' : 'false';
6565
// aws:SourceArn – Used check the source of the request,
6666
// using the ARN of the source. N/A here.
6767
case 'aws:SourceArn': return undefined;

lib/policyEvaluator/utils/variables.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function findVariable(variable: string, requestContext: RequestContext): string
3838
// aws:SecureTransport is boolean value that represents whether the
3939
// request was sent using SSL
4040
map.set('aws:SecureTransport',
41-
requestContext.getSslEnabled() ? 'true' : 'false');
41+
headers?.['x-forwarded-proto'] === 'https' ? 'true' : 'false');
4242
// aws:SourceIp is requester's IP address, for use with IP address
4343
// conditions
4444
map.set('aws:SourceIp', requestContext.getRequesterIp());

tests/unit/policyEvaluator.spec.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,9 @@ describe('policyEvaluator', () => {
906906
() => {
907907
policy.Statement.Condition = { Bool:
908908
{ 'aws:SecureTransport': 'true' } };
909-
const rcModifiers = { _sslEnabled: false };
909+
const rcModifiers = { _headers: {
910+
'x-forwarded-proto': 'http',
911+
} };
910912
check(requestContext, rcModifiers, policy, 'Neutral');
911913
});
912914

@@ -915,7 +917,9 @@ describe('policyEvaluator', () => {
915917
() => {
916918
policy.Statement.Condition = { Bool:
917919
{ 'aws:SecureTransport': 'true' } };
918-
const rcModifiers = { _sslEnabled: true };
920+
const rcModifiers = { _headers: {
921+
'x-forwarded-proto': 'https',
922+
} };
919923
check(requestContext, rcModifiers, policy, 'Allow');
920924
});
921925

0 commit comments

Comments
 (0)