Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!parameters.triggerFunction) {
answers.triggerFunction = 'NONE';
}
continueWithTriggerOperationQuestion = false;
break;
}
default:
console.log(`${triggerOperationAnswer.triggerOperation} not supported`);
}
}
}
const storageRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(storageRequirements, context, 'storage', answers.resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
// if requirements are unsatisfied, trigger auth
if (foundUnmetRequirements) {
try {
await externalAuthEnable(context, category, answers.resourceName, storageRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
Object.assign(defaultValues, answers);
const resource = defaultValues.resourceName;
async function enableGuestAuth(context, resourceName, allowUnauthenticatedIdentities) {
const { checkRequirements, externalAuthEnable } = require('amplify-category-auth');
// enable allowUnauthenticatedIdentities
const identifyRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(identifyRequirements, context, 'predictions', resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
// if requirements are unsatisfied, trigger auth
if (foundUnmetRequirements) {
try {
await externalAuthEnable(context, 'predictions', resourceName, identifyRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
}
async function enableGuestAuth(context, resourceName, allowUnauthenticatedIdentities) {
const { checkRequirements, externalAuthEnable } = require('amplify-category-auth');
// enable allowUnauthenticatedIdentities
const identifyRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(identifyRequirements, context, 'predictions', resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
// if requirements are unsatisfied, trigger auth
if (foundUnmetRequirements) {
try {
await externalAuthEnable(context, 'predictions', resourceName, identifyRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
}
try {
await externalAuthEnable(context, 'api', answers.resourceName, apiRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
}
if (answer.privacy === 'protected') {
privacy.auth = await askReadWrite('Authenticated', context, authPrivacy);
privacy.unauth = await askReadWrite('Guest', context, unauthPrivacy);
allowUnauthenticatedIdentities = true;
const apiRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(apiRequirements, context, 'api', answers.resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
// if requirements are unsatisfied, trigger auth
if (foundUnmetRequirements) {
try {
await externalAuthEnable(context, 'api', answers.resourceName, apiRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
}
}
async function enableGuestAuth(context, resourceName, allowUnauthenticatedIdentities) {
const { checkRequirements, externalAuthEnable } = require('amplify-category-auth');
// enable allowUnauthenticatedIdentities
const identifyRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(identifyRequirements, context, 'predictions', resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
// if requirements are unsatisfied, trigger auth
if (foundUnmetRequirements) {
try {
await externalAuthEnable(context, 'predictions', resourceName, identifyRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
}
const s3Resource = {
resourceName: answers.resourceName,
};
const storageRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
answers.adminTriggerFunction = await addTrigger(context, s3Resource, options, predictionsResourceName);
answers.triggerFunction = 'NONE';
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(storageRequirements, context, storageCategory, answers.resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
// if requirements are unsatisfied, trigger auth
if (foundUnmetRequirements) {
try {
await externalAuthEnable(context, storageCategory, answers.resourceName, storageRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
Object.assign(defaultValues, answers);
const resource = defaultValues.resourceName;
const resourceDirPath = path.join(projectBackendDirPath, storageCategory, resource);
delete defaultValues.resourceName;
delete defaultValues.storageAccess;
fs.ensureDirSync(resourceDirPath);
const parametersFilePath = path.join(resourceDirPath, parametersFileName);
const jsonString = JSON.stringify(defaultValues, null, 4);
fs.writeFileSync(parametersFilePath, jsonString, 'utf8');
async function enableGuestAuth(context, resourceName, allowUnauthenticatedIdentities) {
const { checkRequirements, externalAuthEnable } = require('amplify-category-auth');
// enable allowUnauthenticatedIdentities
const identifyRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(identifyRequirements, context, 'predictions', resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
// if requirements are unsatisfied, trigger auth
if (foundUnmetRequirements) {
try {
await externalAuthEnable(context, 'predictions', resourceName, identifyRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
}
if (answer.privacy === 'protected') {
privacy.auth = await askReadWrite('Authenticated', context, authPrivacy);
privacy.unauth = await askReadWrite('Guest', context, unauthPrivacy);
allowUnauthenticatedIdentities = true;
const apiRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(apiRequirements, context, 'api', answers.resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
// if requirements are unsatisfied, trigger auth
if (foundUnmetRequirements) {
try {
await externalAuthEnable(context, 'api', answers.resourceName, apiRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
}
}
if (permissionSelected === 'Both' || permissionSelected === 'Individual Groups') {
// Enable Auth if not enabled
const apiRequirements = { authSelections: 'identityPoolAndUserPool' };
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(apiRequirements, context, 'api', answers.resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
async function enableGuestAuth(context, resourceName, allowUnauthenticatedIdentities) {
const { checkRequirements, externalAuthEnable } = require('amplify-category-auth');
// enable allowUnauthenticatedIdentities
const identifyRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(identifyRequirements, context, 'predictions', resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
// if requirements are unsatisfied, trigger auth
if (foundUnmetRequirements) {
try {
await externalAuthEnable(context, 'predictions', resourceName, identifyRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
}
async function enableGuestAuth(context, resourceName, allowUnauthenticatedIdentities) {
const { checkRequirements, externalAuthEnable } = require('amplify-category-auth');
// enable allowUnauthenticatedIdentities
const identifyRequirements = { authSelections: 'identityPoolAndUserPool', allowUnauthenticatedIdentities };
// getting requirement satisfaction map
const satisfiedRequirements = await checkRequirements(identifyRequirements, context, 'predictions', resourceName);
// checking to see if any requirements are unsatisfied
const foundUnmetRequirements = Object.values(satisfiedRequirements).includes(false);
// if requirements are unsatisfied, trigger auth
if (foundUnmetRequirements) {
try {
await externalAuthEnable(context, 'predictions', resourceName, identifyRequirements);
} catch (e) {
context.print.error(e);
throw e;
}
}
}