Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
qref(`$${variableToCheck}.put("${ownerAttribute}", $identityValue)`),
set(ref(variableToSet), raw('true'))
])
)
)
} else {
// If the owner field is a list and the user does not
// provide a list of values for the owner, set the list with
// the owner as the sole member.
ownershipAuthorizationExpressions.push(
// If the owner is not provided set it automatically.
// If the user explicitly provides null this will be false and we leave it null.
iff(
and([
raw(`$util.isNull($${allowedOwnersVariable})`),
parens(raw(`! $${variableToCheck}.containsKey("${ownerAttribute}")`)),
]),
compoundExpression([
qref(`$${variableToCheck}.put("${ownerAttribute}", ["$identityValue"])`),
set(ref(variableToSet), raw('true'))
])
)
)
}
ruleNumber++
}
return compoundExpression([
set(ref(variableToSet), raw(`false`)),
...ownershipAuthorizationExpressions,
]);
}
public appendItemIfLocallyAuthorized(): Expression {
return iff(
parens(
or([
equals(ref(ResourceConstants.SNIPPETS.IsLocalDynamicGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsLocalOwnerAuthorizedVariable), raw('true'))
])
), qref('$items.add($item)')
)
}
public throwIfNotStaticGroupAuthorizedOrAuthConditionIsEmpty(): Expression {
const ifUnauthThrow = iff(
not(parens(
or([
equals(ref(ResourceConstants.SNIPPETS.IsStaticGroupAuthorizedVariable), raw('true')),
parens(raw('$authCondition && $authCondition.expression != ""'))
])
)), raw('$util.unauthorized()')
)
return block('Throw if unauthorized', [
ifUnauthThrow,
])
}
public throwIfSubscriptionUnauthorized(): Expression {
const ifUnauthThrow = iff(
not(
parens(
or([
equals(ref(ResourceConstants.SNIPPETS.IsStaticGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsOwnerAuthorizedVariable), raw('true')),
])
)
),
raw('$util.unauthorized()')
);
return block('Throw if unauthorized', [ifUnauthThrow]);
}
public throwIfUnauthorized(): Expression {
const ifUnauthThrow = iff(
not(parens(
or([
equals(ref(ResourceConstants.SNIPPETS.IsStaticGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsDynamicGroupAuthorizedVariable), raw('true')),
equals(ref(ResourceConstants.SNIPPETS.IsOwnerAuthorizedVariable), raw('true'))
])
)), raw('$util.unauthorized()')
)
return block('Throw if unauthorized', [
ifUnauthThrow,
])
}
public throwIfNotStaticGroupAuthorizedOrAuthConditionIsEmpty(): Expression {
const ifUnauthThrow = iff(
not(parens(
or([
equals(ref(ResourceConstants.SNIPPETS.IsStaticGroupAuthorizedVariable), raw('true')),
parens(raw('$authCondition && $authCondition.expression != ""'))
])
)), raw('$util.unauthorized()')
)
return block('Throw if unauthorized', [
ifUnauthThrow,
])
}