OKTA AWS credential helper.
You you only need the following steps to setup your aws credentials file derived from Okta automatically. Procedures are
okta-aws-cred-helper init
okta-aws-cred-helper refresh
# then you are ready to go.
AWS_PROFILE=okta-role aws s3 ls
# If you need to know what profiles are available to you, you need to check your aws credentials file, i.e. ~/.aws/credentials
# when your DevSecOps made change on permissions, you need to refresh your local aws credentials file to pick up the change.
okta-aws-cred-helper refresh
pip install okta-aws-credential-helper
Preparation:
- You need to know Okta AWS application sso URL. It should be like https://domain.okta.com/app/amazon_aws/`app-id`/sso/saml.
- You already have your email/password/google 2Fa set up.
- During the process, we will reset the Okta Google 2FA code. You will need a QR code scanner application (besides Google 2FA app) so it can read the TOTP code. An useful application can be: https://play.google.com/store/apps/details?id=com.tohsoft.qrcode.pro
Login to your Okta Account and reset your 2FA code. When you are resetting, while the QR code still displays, use the QR code scanner to decode the QR code, which will be like
otpauth://totp/xxx.okta.com:<your-email>?secret=<totp-code>&issuer=xxx.okta.com
Mark the totp code down and you will use it later.
Execute
okta-aws-cred-helper init
Follow the questions and input your answers. You will be asked for sso_url, okta username(email), okta password, totp code (you previously marked down). Note whatever you have input will be echo back to the screen. Please keep alert from peeping.
NOTE your okta credentials settings are stored in file ~/.aws/okta-aws/settings.json
. Keep it secret. You can also edit this file directly later instead of running okta-aws-cred-helper init
command.
Once initialized, the file should be like
{
"sso_url": "https://domain.okta.com/app/amazon_aws/aaaaabbbbbcccccDDDDD/sso/saml",
"region": "ap-southeast-2",
"user_name": "[email protected]",
"password": "<password>",
"google_2fa_totp": "<totp code>"
}
Execute
okta-aws-cred-helper refresh
This command will modify your ~/.aws/credentials
for the new credentials derived from okta. The credentials from Okta will be defined as profiles with name starting with okta-
.
Note existing credentials in ~/.aws/credentials
with profile name not starting with okta-
will be intact.
After executing this command, simply check the content of ~/.aws/credentials
to get familiar with what roles OKTA has allowed you to assume to. You can also configure other personal profiles to source from these okta-
profiles.
This process uses directory ~/.aws/okta-aws
as temporary credential caches.
This tool automatically refreshes the credentials behind the scene for you.
While refreshing credentials, you may feel your aws tools (boto scripts or awscli) freeze for several seconds. This usually happens at the edge of every 30 seconds. When this tool sense it is close to the end of each 30 seconds, it will wait until this 30 second window pass, to avoid the google 2FA authentication failure caused by network delay or time in-synchronization.
The following items are in the view:
- Use more secure store.
- Test on windows
- Test on linux(ubuntu)
- add a easy role assumption support
- Allow signing Login URLs (working with awslogin)
- Package properly and add testing
Contribution welcome..