in tampermonkey.js [60:95]
function getCredentials() {
const encodedSAML = $('input[name="SAMLResponse"]').val();
const role = $('input[name="roleIndex"]:checked').val();
if(!role) return; // Nothing was selected
// Parse SAML token into an XML DOM we can use
const rawSAML = atob(encodedSAML);
const parsedSAML = $.parseXML(rawSAML);
const $saml = $(parsedSAML);
const idp = getIDPForRole($saml, role);
const duration = getSessionDurationForRole($saml, role);
// Request temporary access keys from AWS STS
return STS.assumeRoleWithSAML({
PrincipalArn: idp,
RoleArn: role,
SAMLAssertion: encodedSAML, /* SAML Token Base64 encoded */
DurationSeconds: duration
}).promise()
.then((data)=> {
const accountId = role.substr(13, 12);
const roleName = role.substr(role.lastIndexOf('/')+1);
// Render popup with the new credentials
displayCredentials(accountId, roleName,
data.Credentials.AccessKeyId,
data.Credentials.SecretAccessKey,
data.Credentials.SessionToken,
data.Credentials.Expiration);
})
.catch((err) => {
const message = err.message ? err.message : JSON.stringify(err, null, 2);
alert(message);
});
}