Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Authentication locks tools without stdin - windows credentials support hack #51

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions aws_okta_processor/core/okta.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import abc
import base64
import os
import sys
import time
import json
import requests
import dateutil
import getpass
import subprocess
import aws_okta_processor.core.prompt as prompt

from datetime import datetime
Expand Down Expand Up @@ -78,21 +79,28 @@ def __init__(
self.user_name = input()

if not self.okta_session_id:
if not self.user_name:
print_tty(string="UserName: ", newline=False)
self.user_name = input()

if not user_pass:
user_pass = getpass.getpass()

if not self.organization:
print_tty(string="Organization: ", newline=False)
self.organization = input()
# if not self.user_name:
# print_tty(string="UserName: ", newline=False)
# self.user_name = input()

getCredentialCommand = f"(Get-Credential -Message 'aws-okta-processor is requesting credentials for {self.organization}' -UserName {self.user_name}).GetNetworkCredential() | ConvertTo-Json"
encodedCommand = base64.b64encode(getCredentialCommand.encode("utf-16")[2:]).decode("utf-8")
powershellCommand = f"powershell.exe -NoProfile -NonInteractive -OutputFormat Text -EncodedCommand {encodedCommand}"
output = subprocess.check_output(powershellCommand)
wincreds = json.loads(output)

# if not user_pass:
# user_pass = getpass.getpass()

# if not self.organization:
# print_tty(string="Organization: ", newline=False)
# self.organization = input()

self.okta_single_use_token = self.get_okta_single_use_token(
user_name=self.user_name,
user_pass=user_pass
user_name=wincreds['UserName'],
user_pass=wincreds['Password']
)
wincreds = None

self.get_okta_session_id()

Expand Down