saml2aws Temporary AWS credentials from Identity Provider utilizing browser based MFA in Python

Viewed 15

Background:

In my quest for automation inside of a restrictive environment, I have hit a roadblock that I am not sure how to get around.

My organization uses saml2aws to generate temporary credentials from our identity provider. The saml2aws setup uses "Browser" as the Provider option and points to our credentialing site where we enter username/password and then a one-time code from email.

From there, the temporary credentials are stored, and I can then interact with CLI.

My desire though is to work within these constraints to create an entirely automated process. Which I am guessing is likely going to be very "hacky" and not a best practice.

saml2aws uses Playwright Go to open Browser based IdP's.

Python is my language of choice.

The Question(s):

I want to attempt using saml2aws in python by utilizing "subprocess", but:

  1. Is there an existing python package that can do the same thing as saml2aws instead?
  2. Can Python interact with the Playwright Go browser window that saml2aws opens?

Current code:

from subprocess import run, PIPE
from shlex import split

#must run "saml2aws configure" from cmd prior to running "saml2aws login" from subprocess
#provider must be set to "Browser"

completed_process = run(split('saml2aws login --skip-prompt'), stdout=PIPE, stderr=PIPE)
completed_process.stdout

The Problem:

The playwright browser window opens, but I can't take control of it to pass login/mfa token.

Is it possible to programmatically interact with a playwright browser from python if it is opened from a command line process?

0 Answers
Related