Skip to main content

# mentaws (moMENTary AWS tokens)

Stay Fresh!

[![Coverage Status](https://coveralls.io/repos/github/keithrozario/mentaws/badge.svg?branch=release)](https://coveralls.io/github/keithrozario/mentaws?branch=release) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/keithrozario/mentaws.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/keithrozario/mentaws/context:python)

[![Python 3.6](https://img.shields.io/badge/python-3.6-blue.svg)](https://www.python.org/downloads/release/python-360/)
[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)
[![Python 3.8](https://img.shields.io/badge/python-3.8-blue.svg)](https://www.python.org/downloads/release/python-380/)

## Introduction

mentaws (rhymes with jaws, and sounds like the candy) replaces your aws credentials file with fresh temporary tokens, while keeping your long lived AWS secret keys encrypted.

This way, the plaintext credentials file has only temporary tokens. Leaving sensitive long lived keys encrypted in your keychain.

## Usage

### Setup

$ mentaws setup
The following 4 were added to mentaws:

👷🏿 Profile
1.default
2.mentaws1
3.mentaws2
4.mentaws3

### Refresh

$ mentaws refresh
Generating temporary tokens...

👷🏿 Profile 🌎 Region: ⏰ Tokens expire at
default ap-southeast-1 Tue 19:27 tz:+08
mentaws1 ap-southeast-1 Tue 19:27 tz:+08
mentaws2 ap-southeast-1 Tue 19:27 tz:+08
mentaws3 ap-southeast-1 Tue 19:27 tz:+08

You're ready to go 🚀🚀

### Remove a profile

$ mentaws remove default
Are you sure you want to delete default? (y/n): y
Profile default was deleted

### Status

$ mentaws status
👷🏿 Profile 🔑 Key: ⏰ Tokens expire at
default ASIA42EXAMPLE1234567 Mon 14:28 tz:+08
mentaws1 ASIA42EXAMPLE1234567 Mon 14:28 tz:+08
mentaws2 ASIA42EXAMPLE1234567 Mon 16:28 tz:+08
mentaws3 ASIA42EXAMPLE1234567 Tue 20:28 tz:+08
metawsFail ERROR ***FAILED***
testassumptionprofile - No Token Expiry

## Installation

The simplest way to install mentaws is to use `pipx`

$ pipx install mentaws

of `pip`

$ pip install mentaws

## Adding profiles

For now, the easiest way to add a profile is to use the generic aws-cli commands:

$ aws configure --profile produser
AWS Access Key ID [None]: AKIAI44QH8DHBEXAMPLE
AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
Default region name [None]: us-east-1
Default output format [None]: text

On the next `refresh`, mentaws will load these new profiles into its database.

*Note: This method works even if you modified the credentials file manually.*

## Implementation details

The AWS credentials are stored in a sqlite3 database in the same directory as your AWS directory.

When you first setup mentaws, an encryption key is randomly generated and stored in your macOS keychain. This key is then used to encrypt the `aws_secret_access_key`. All other fields,including the `aws_access_key_id` are stored in plaintext -- the encrypted key together with other metadata is stored in a SQLITE database in your default aws directory.

For the encryption we use the [pyca/cryptography](https://cryptography.io/en/latest/fernet.html#implementation) package, which implements the following:

* AES in CBC mode with a 128-bit key for encryption; using PKCS7 padding.
* HMAC using SHA256 for authentication.
* Initialization vectors are generated using os.urandom().

We store the randomly generated key in your macOS keychain using keyring, this has one limitation, namely:

* Any Python script or application can access secrets created by keyring from that same Python executable without the operating system prompting the user for a password. **To cause any specific secret to prompt for a password every time it is accessed, locate the credential using the Keychain Access application, and in the Access Control settings, remove Python from the list of allowed applications.**

Although, on my machine with macOS Catalina installed, I do get prompted once for every sensitive mentaws operation.

## Warning

This project is still in beta, and work with all AWS features, use at your own risk.

## Limitation

Because of the way tokens work, any operation on iam, e.g. iam:GetRole, will fail with mentaws because we do not use MFA for the authorization.

Metadata

Release files for mentaws 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mentaws 0.6.1
File Size Uploaded Provenance Actions
mentaws-0.6.1.tar.gz 11.5 kB Without provenance Details for mentaws-0.6.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mentaws 0.6.1
File Interpreter ABI Platform Actions
mentaws-0.6.1-py3-none-any.whl Python 3 none any Details for mentaws-0.6.1-py3-none-any.whl

Total release size: 22.5 kB

Release files / mentaws-0.6.1.tar.gz

Download URL mentaws-0.6.1.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
01aaa932bbce4783c451b168013f9388b41c0e244996788060cc27da34b6a010
BLAKE2b-256 checksum
How to use checksums
e94cd5fd87c075bda27f8fc67294167f2caef322760414ba6eb3432470f781d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.3 Darwin/19.5.0

Release files / mentaws-0.6.1-py3-none-any.whl

Download URL mentaws-0.6.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14cc8ebf36aed91b16e871c2d99fde0a055ed2e3fec8d9fe28f3dac50422fb8e
BLAKE2b-256 checksum
How to use checksums
12aeaa585819788a55299a56f0c71bb6a1065cdb167539f428ced372c461b075
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.3 Darwin/19.5.0

Security for mentaws 0.6.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page