aws-simple-sso
Simple AWS SSO Sign-in
Install
npm install aws-simple-sso
Usage
import { authenticate } from 'aws-simple-sso'
const main = async () => {
const credentials = await authenticate('Prod', 'sre_dev', 'Admin')
console.log(credentials)
}
main()
API
authenticate(matchOrg, matchAcc, matchRole)
Quick method of fully authenticating against AWS SSO.
Parameters provide partial matches for Organization, Account, and Role.
matchOrg | Type: string | Partial Match for Organization Name |
matchAcc | Type: string | Partial Match for Account Name |
matchRole | Type: string | Partial Match for Role Name |
Returns:
{
accessKeyId: string,
secretAccessKey: string,
sessionToken: string,
expiration: Date
}
getOrgUrl(matchOrg)
Get an Organization StartURL for AWS SSO login
-
If none are known, the user will be prompted to add a new Organization URL and name
-
If the Organization name cannot be found via the matchOrg
parameter, the user will be prompted to select from a list of known Organizations
matchOrg | Type: string | Partial Match for Organization Name |
Returns:
Type: SSOOrgUrl
{
orgName: string,
orgUrl: string
}
getToken(orgUrl)
Get an AWS SSO OIDC token
orgUrl | Type: SSOOrgUrl | AWS Organization URL |
Returns:
Type: SSOToken
{
accessToken: string (optional)
tokenType: string (optional)
expiresIn: number (optional)
expireTime: Date (optional)
refreshToken: string (optional)
idToken: string (optional)
}
getAccount(token, matchAcc)
Get an AWS Account via the SSO service
- If the Account name cannot be found via the
matchAcc
parameter, the user will be prompted to select from a list of known Accounts
token | Type: SSOToken | AWS SSO Token |
matchAcc | Type: string | Partial Match for Account Name |
Returns:
Type: SSOAccount
{
accountId: string,
accountName: string
}
getRole(token, accountId, matchRole)
Get an AWS Role via the SSO service
- If the Role name cannot be found via the
matchRole
parameter, the user will be prompted to select from a list of known Roles
token | Type: SSOToken | AWS SSO Token |
accountId | Type: string | AWS Account ID |
matchRole | Type: string | Partial Match for Role Name |
Returns:
Type: SSORole
{
accountId: string
roleName: string,
}
getRoleCredentials(token, ssoRole)
Get AWS Role Credentials via the SSO service
token | Type: SSOToken | AWS SSO Token |
ssoRole | Type: SSORole | AWS SSO Role |
Returns:
{
accessKeyId: string,
secretAccessKey: string,
sessionToken: string,
expiration: Date
}
License
MIT ©