diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..4e1ef42 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,31 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/README.rst b/README.rst index 27bc700..7a02d3d 100644 --- a/README.rst +++ b/README.rst @@ -1,19 +1,21 @@ ========================= - oktaauth + oktaauthpy3 ========================= -The oktaauth module and command line interface allows users to +This is a fork of oktaauth with Python3 support + +The oktaauthpy3 module and command line interface allows users to authenticate with Okta and obtain a SAML assertion either from the command line or programmatically from another script. Usage ===== -The oktaauth CLI requires a few arguments to operate. +The oktaauthpy3 CLI requires a few arguments to operate. # obtain a SAML response from Okta - $ oktaauth --username joebloggs --server + $ oktaauthpy3 --username joebloggs --server acemeinc.okta.com --apptype amazon_aws --appid exk5c0llc The *apptype* and *appid* are provided by okta and would be seen in the @@ -27,11 +29,15 @@ submit a pull request to this ``README``. Thanks ====== +Peter Gillard-Moss who is the original Author or oktaauth +https://pypi.org/project/oktaauth/ + Thanks to Okta for help. I borrowed a lot of code from https://github.com/okta/okta-openvpn to handle the Okta API authentication flow. -Authors -======= -* Peter Gillard-Moss +Author +=========== + +* Mansab Uppal diff --git a/docs/source/README b/docs/source/README index 10dcb2d..2f11dea 100644 --- a/docs/source/README +++ b/docs/source/README @@ -1,5 +1,5 @@ -Run `sphinx-apidoc -o . ../../oktaauth' in this directory. +Run `sphinx-apidoc -o . ../../oktaauthpy3' in this directory. -This will generate `modules.rst' and `oktaauth.rst'. +This will generate `modules.rst' and `oktaauthpy3.rst'. -Then include `modules.rst' in your `index.rst' file. \ No newline at end of file +Then include `modules.rst' in your `index.rst' file. diff --git a/docs/source/conf.py b/docs/source/conf.py index a561a1b..d3391fe 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -22,7 +22,7 @@ sys.path.insert(0, os.path.abspath('../..')) # Import project metadata -from oktaauth import metadata +from oktaauthpy3 import metadata # -- General configuration ---------------------------------------------------- diff --git a/oktaauth/__init__.py b/oktaauthpy3/__init__.py similarity index 85% rename from oktaauth/__init__.py rename to oktaauthpy3/__init__.py index d356ee2..a8b61c6 100644 --- a/oktaauth/__init__.py +++ b/oktaauthpy3/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Authenticates from the CLI""" -from oktaauth import metadata +from oktaauthpy3 import metadata __version__ = metadata.version diff --git a/oktaauth/main.py b/oktaauthpy3/main.py similarity index 96% rename from oktaauth/main.py rename to oktaauthpy3/main.py index 1a719ed..2392f79 100755 --- a/oktaauth/main.py +++ b/oktaauthpy3/main.py @@ -9,10 +9,10 @@ import getpass import logging -from oktaauth import models -from oktaauth import metadata +from oktaauthpy3 import models +from oktaauthpy3 import metadata -log = logging.getLogger('oktaauth') +log = logging.getLogger('oktaauthpy3') def configurelogging(): log.setLevel(logging.DEBUG) diff --git a/oktaauth/metadata.py b/oktaauthpy3/metadata.py similarity index 66% rename from oktaauth/metadata.py rename to oktaauthpy3/metadata.py index 0a82dbc..f793727 100644 --- a/oktaauth/metadata.py +++ b/oktaauthpy3/metadata.py @@ -5,14 +5,16 @@ """ # The package name, which is also the "UNIX name" for the project. -package = 'oktaauth' -project = "Okta CLI authentication" +package = 'oktaauthpy3' +project = "Okta CLI authentication with Python3 support" project_no_spaces = project.replace(' ', '') -version = '0.2' +version = '0.7' description = 'Authenticates from the CLI' authors = ['Peter Gillard-Moss'] authors_string = ', '.join(authors) -emails = ['pgillard@thoughtworks.com'] +maintainers = ['Mansab Uppal'] +maintainers_string = ', '.join(maintainers) +emails = ['muppal@thoughtworks.com'] license = 'Apache 2.0' copyright = '2015 Thoughtworks Inc' url = 'https://www.thoughtworks.com/' diff --git a/oktaauth/models.py b/oktaauthpy3/models.py similarity index 94% rename from oktaauth/models.py rename to oktaauthpy3/models.py index 3153ff2..f87df43 100644 --- a/oktaauth/models.py +++ b/oktaauthpy3/models.py @@ -1,9 +1,10 @@ import requests import base64 -import urlparse +from urllib.parse import urlparse +from urllib.parse import urlunparse import logging from bs4 import BeautifulSoup -log = logging.getLogger('oktaauth') +log = logging.getLogger('oktaauthpy3') class OktaAPIAuth(object): @@ -15,7 +16,7 @@ def __init__(self, okta_server, username, password, passcode): self.passcode = passcode url_new = ('https', okta_server, '', '', '','') - self.okta_url = urlparse.urlunparse(url_new) + self.okta_url = urlunparse(url_new) return def okta_req(self, path, data): @@ -109,7 +110,7 @@ def saml(self, sessionToken): if resp.status_code != 200: raise Exception('Received error code from server: %s' % resp.status_code) - return resp.text.decode('utf8') + return resp.text def assertion(self, saml): assertion = '' @@ -118,7 +119,8 @@ def assertion(self, saml): if inputtag.get('name') == 'SAMLResponse': assertion = inputtag.get('value') - return base64.b64decode(assertion) + decodedAssertion = base64.b64decode(assertion) + return str(decodedAssertion, "utf-8") def auth(self): token = super(OktaSamlAuth, self).auth() diff --git a/pavement.py b/pavement.py index 7830305..c7135d4 100644 --- a/pavement.py +++ b/pavement.py @@ -129,7 +129,7 @@ def run(args): # executable. So we just pass the package name in as the executable name, # since it's close enough. This should never be seen by an end user # installing through Setuptools anyway. - from oktaauth.main import main + from oktaauthpy3.main import main raise SystemExit(main([CODE_DIRECTORY] + args)) diff --git a/setup.py b/setup.py index ab373af..12674af 100644 --- a/setup.py +++ b/setup.py @@ -35,16 +35,16 @@ def check_output(cmd_args, *args, **kwargs): sys.path.insert(0, os.path.abspath('.')) ## Constants -CODE_DIRECTORY = 'oktaauth' +CODE_DIRECTORY = 'oktaauthpy3' DOCS_DIRECTORY = 'docs' TESTS_DIRECTORY = 'tests' PYTEST_FLAGS = ['--doctest-modules'] # Import metadata. Normally this would just be: # -# from oktaauth import metadata +# from oktaauthpy3 import metadata # -# However, when we do this, we also import `oktaauth/__init__.py'. If this +# However, when we do this, we also import `oktaauthpy3/__init__.py'. If this # imports names from some other modules and these modules have third-party # dependencies that need installing (which happens after this file is run), the # script will crash. What we do instead is to load the metadata module by path @@ -268,7 +268,7 @@ def run_tests(self): zip_safe=False, # don't use eggs entry_points={ 'console_scripts': [ - 'oktaauth = oktaauth.main:entry_point' + 'oktaauthpy3 = oktaauthpy3.main:entry_point' ] } ) diff --git a/tests/test_main.py b/tests/test_main.py index d334440..fa20ff1 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -8,8 +8,8 @@ import pytest parametrize = pytest.mark.parametrize -from oktaauth import metadata -from oktaauth.main import main +from oktaauthpy3 import metadata +from oktaauthpy3.main import main class TestMain(object):