@jrposada/pm-creds
v2.2.3
Published
Middle-ware between Postman and credentials providers.
Downloads
16
Readme
PM Creds
Getting started
Install
npm i @jrposada/pm-creds -g
Create config files and self-signed certificates
pm-creds init
Start server
pm-creds
You may also use run command as a daemon
pm-creds --daemon
To stop daemon process
pm-creds stop
Install Self Signed Certificate
Windows
- Open Manage user certificates. Press Windows logo key and search Manage user certificates
- Select Trusted Root Certification Authorities from the list.
- Go to Action -> All Tasks -> Import...
- Select
~/.pm-creds/ca.crt
- Accept install prompts.
- Verify installation by checking pm-creds-ca certificate is under Trusted Root Certification Authorities > Certificates
Configure Postman
Add the next pre-script
to postman. It will request the target AWS profile define through aws_profile
and inject the tokens it into the request. For AWS you also need to select "AWS Signature" as auth method:
let profile = pm.collectionVariables.get("aws_profile");
if (!profile) {
profile = pm.environment.get("aws_profile")
}
if (!profile) {
throw new Error("'aws_profile' variable not set")
}
pm.sendRequest({
url: `https://localhost:9999/aws/${profile}`,
method: "GET",
}, function (_, response) {
if (response.status == "OK") {
const body = response.json()
pm.variables.set("aws_access_key_id", body.aws_access_key_id)
pm.variables.set("aws_secret_access_key", body.aws_secret_access_key)
if (body.aws_session_token) {
pm.variables.set("aws_session_token", body.aws_session_token)
}
console.log(`using aws credentials from '${profile}'`)
return
} else {
throw new Error(response.text() || JSON.stringify(err) || "unknown error fetching aws credentials")
}
}
)