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

Output valid xml #12

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
31 changes: 31 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -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/*
20 changes: 13 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions docs/source/README
Original file line number Diff line number Diff line change
@@ -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.
Then include `modules.rst' in your `index.rst' file.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
sys.path.insert(0, os.path.abspath('../..'))

# Import project metadata
from oktaauth import metadata
from oktaauthpy3 import metadata

# -- General configuration ----------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion oktaauth/__init__.py → oktaauthpy3/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Authenticates from the CLI"""

from oktaauth import metadata
from oktaauthpy3 import metadata


__version__ = metadata.version
Expand Down
6 changes: 3 additions & 3 deletions oktaauth/main.py → oktaauthpy3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions oktaauth/metadata.py → oktaauthpy3/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ['[email protected]']
maintainers = ['Mansab Uppal']
maintainers_string = ', '.join(maintainers)
emails = ['[email protected]']
license = 'Apache 2.0'
copyright = '2015 Thoughtworks Inc'
url = 'https://www.thoughtworks.com/'
12 changes: 7 additions & 5 deletions oktaauth/models.py → oktaauthpy3/models.py
Original file line number Diff line number Diff line change
@@ -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):

Expand All @@ -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):
Expand Down Expand Up @@ -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 = ''
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))


Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
]
}
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down