Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function updateProjectManifest(applicationId) {
console.log('Updating manifest with application ID');
try {
// Update manifest with application guid and unique manifest id
const manifestContent = await fs.readFileSync(defaults.manifestPath, 'utf8');
const re = new RegExp('{application GUID here}', 'g');
const updatedManifestContent = manifestContent.replace(re, applicationId);
await fs.writeFileSync(defaults.manifestPath, updatedManifestContent);
await manifest.modifyManifestFile(defaults.manifestPath, 'random');
} catch (err) {
throw new Error(`Unable to update ${defaults.manifestPath}. \n${err}`);
}
}
async function configureSSOApplication() {
// Check to see if Azure CLI is installed. If it isn't installed then install it
const cliInstalled = await azureCliInstalled();
if(!cliInstalled) {
console.log("Azure CLI is not installed. Installing now before proceeding");
await installAzureCli();
console.log('Please close your command shell, reopen and run configure-sso again. This is neccessary to register the path to the Azure CLI');
return;
}
const userJson = await logIntoAzure();
if (userJson) {
console.log('Login was successful!');
const manifestInfo = await manifest.readManifestFile(defaults.manifestPath);
const applicationJson = await createNewApplication(manifestInfo.displayName);
ssoAppData.writeApplicationData(applicationJson.appId);
const secretJson = await setApplicationSecret(applicationJson);
ssoAppData.addSecretToCredentialStore(manifestInfo.displayName, secretJson.secretText);
updateProjectManifest(applicationJson.appId);
await logoutAzure();
console.log("Outputting Azure application info:\n");
console.log(applicationJson);
}
else {
throw new Error(`Login to Azure did not succeed.`);
}
}