Skip to main content

Okta login made easy from the command line without API token

Project description

Okta Login Wrapper

Provide an easy way for your scripts to access ressources behind an Okta SSO solution, without the need for an API token.

Prerequisite

  • Python 3
  • Python modules
    • Requests
    • lxml
  • An Okta account

Installing

Simply make sure you have the required python modules installed.

pip install -r requirements.txt

Once done, place OktaLoginWrapper.py in the same folder as your own script.

Getting Started

~WARNING~ Currently the script only works if you have "push" enabled as MFA.

The main goal of this script is to help you login to an application using SSO with Okta, without requiring any API token.

As part of another scripts, it allows you to have an okta_session object from where you can connect to all application assigned to you in Okta.

from oktaloginwrapper import OktaLoginWrapper as OLW


#  Create a session with your okta instance name as well as your credentials.
#  If the credentials are correct, you'll be asked for MFA. (Currently only work with push notification)

my_session = OLW.OktaSession(okta_instance) #Where okta_instance is https://<okta_instance>.okta.com
my_session.okta_auth(okta_username, okta_password)

Then, depending on the type of script you are writing, here's what you can do.

As a non-interactive script:

#  Use connect_to() with the 'Embed Link' of an app in Okta as parameter. 
#  You can find that url in Okta admin portal on the general tab of an app.
#  Or by using the provided method app_list()

my_app = my_session.connect_to(app_url)

As an interactive script:

#  You can prompt the user to type the name of an app he wants to log into.
#  A list is returned with with corresponding apps and the user has to select which one to login to.
#  If connection is successful, it returns a requests.models.response of the homepage of the app.
#  From there, you can navigate the app using your object my_session.

my_app = my_session.connect_from_appslist()

Close the session once you're done.

my_session.okta_session.close()

It can also be executed but this is mainly a proof of concept as it just print the raw content. I will probably remove that part at some point in the future.

Built With

  • Requests - Python HTTP Requests for Humans
  • lxml - The lxml XML toolkit for Python

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oktaloginwrapper-0.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

oktaloginwrapper-0.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file oktaloginwrapper-0.1.tar.gz.

File metadata

File hashes

Hashes for oktaloginwrapper-0.1.tar.gz
Algorithm Hash digest
SHA256 1ce0a53ec3157f486a47e241e274ff97b49116c71fa3e02f5606bdc560bd467c
MD5 3494166219a2d22dce76746599eb83bc
BLAKE2b-256 b75c6ac2956fe3e3d8581d2edf54aa268e1615ab784df34122375be12ce95c4f

See more details on using hashes here.

File details

Details for the file oktaloginwrapper-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for oktaloginwrapper-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eeda08e051a408522925e3f5b1da8bfd9dfe33bfdd9afe51cadbfba63e6894a0
MD5 e3043f53e41c166c760610dcb25df9b5
BLAKE2b-256 c47429686af889dbb436222edf4c3a93a49ede90368bfb1312ffe6069a8ff23f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page