mirror of
https://github.com/yeslayla/cognito-oauthtools.git
synced 2025-01-14 04:53:24 +01:00
Push additional files
Update Workflow Update Workflow Update Workflow Update Workflow Update Workflow
This commit is contained in:
parent
8f2ba12f80
commit
130ae3f76e
15
.bumpversion.cfg
Normal file
15
.bumpversion.cfg
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
[bumpversion]
|
||||||
|
current_version = 0.0.0
|
||||||
|
commit = False
|
||||||
|
tag = True
|
||||||
|
tag_name = {new_version}
|
||||||
|
|
||||||
|
[bumpversion:file:cognito_oauthtools/__init__.py]
|
||||||
|
search = version = "0.0.0"
|
||||||
|
replace = version = "{new_version}"
|
||||||
|
|
||||||
|
[semver]
|
||||||
|
main_branches = master
|
||||||
|
major_branches =
|
||||||
|
minor_branches = feature
|
||||||
|
patch_branches = hotfix, bugfix
|
34
.github/workflows/build.yml
vendored
Normal file
34
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
name: Build & Publish
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- created
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Set up Python 3.7
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: 3.7
|
||||||
|
- name: Update Version
|
||||||
|
run: |
|
||||||
|
pip install bumpversion
|
||||||
|
export regex="([0-9]+.[0-9]+.[0-9]+)"
|
||||||
|
echo ${{ github.ref }} > tag.txt
|
||||||
|
VERSION=`grep -Po "${regex}" tag.txt`
|
||||||
|
bumpversion minor --no-tag --new-version ${VERSION}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
- name: build
|
||||||
|
run: |
|
||||||
|
python setup.py sdist bdist_wheel
|
||||||
|
- name: PyPi Publish
|
||||||
|
uses: pypa/gh-action-pypi-publish@v1.0.0a0
|
||||||
|
with:
|
||||||
|
user: josephbmanley
|
||||||
|
password: ${{ secrets.PYPI_PASSWORD }}
|
40
.github/workflows/version.yml
vendored
Normal file
40
.github/workflows/version.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
name: Version & Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
CheckVersion:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: rightbrainnetworks/auto-semver
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
- name: Run auto-semver
|
||||||
|
id: semver
|
||||||
|
run: |
|
||||||
|
export regex='^\\s*current_version\\s*=\\s*\\K[^\\s]+'
|
||||||
|
export RETURN_STATUS=`semver -n`
|
||||||
|
echo "Semver Return Status: ${RETURN_STATUS}"
|
||||||
|
|
||||||
|
export SEMVER_NEW_VERSION=`grep -Po '${regex}' .bumpversion.cfg`
|
||||||
|
export VERSION=`semver_get_version -d`
|
||||||
|
|
||||||
|
echo ::set-output name=RETURN_STATUS::$RETURN_STATUS
|
||||||
|
echo ::set-output name=SEMVER_NEW_VERSION::$SEMVER_NEW_VERSION
|
||||||
|
echo ::set-output name=VERSION::$VERSION
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
if: steps['semver']['outputs']['RETURN_STATUS'] == '0'
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.semver.outputs.SEMVER_NEW_VERSION }}
|
||||||
|
release_name: ${{ steps.semver.outputs.SEMVER_NEW_VERSION }}
|
||||||
|
body: Release Version ${{ steps.semver.outputs.SEMVER_NEW_VERSION }}
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
44
cognito_oauthtools/__init__.py
Normal file
44
cognito_oauthtools/__init__.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import requests
|
||||||
|
|
||||||
|
version = "0.0.0"
|
||||||
|
|
||||||
|
class Client:
|
||||||
|
def __init__(self, endpoint, client_id, client_secret, host_domain, logout_path="/", redirect_path="/oauth"):
|
||||||
|
self.endpoint = endpoint
|
||||||
|
self.client_id = client_id
|
||||||
|
self.client_secret = client_secret
|
||||||
|
self.host = host_domain
|
||||||
|
self.logout_path = logout_path
|
||||||
|
self.redirect_path = redirect_path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def loginUrl(self):
|
||||||
|
return 'https://' + self.endpoint + '/login?client_id=' + self.client_id + "&redirect_uri=https://" + self.host + self.redirect_path + "&response_type=code"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def registerUrl(self):
|
||||||
|
return 'https://' + self.endpoint + '/signup?client_id=' + self.client_id + "&redirect_uri=https://" + self.host + self.redirect_path + "&response_type=code"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def logoutUrl(self):
|
||||||
|
return 'https://' + self.endpoint + '/logout?client_id=' + self.client_id + "&logout_uri=https://" + self.host + self.logout_path
|
||||||
|
|
||||||
|
def get_token(self, code):
|
||||||
|
r = requests.post('https://' + self.endpoint + '/oauth2/token', auth=(self.client_id, self.client_secret),
|
||||||
|
data = {'code':code, 'grant_type':'authorization_code', 'redirect_uri': "https://" + self.host + self.redirect_path })
|
||||||
|
return r.json()['access_token']
|
||||||
|
|
||||||
|
class User:
|
||||||
|
def __init__(self, client, token = None):
|
||||||
|
self.data = {}
|
||||||
|
self.token = token
|
||||||
|
self.client = client
|
||||||
|
self.reload()
|
||||||
|
|
||||||
|
def is_logged_in(self):
|
||||||
|
self.reload()
|
||||||
|
return 'username' in self.data
|
||||||
|
|
||||||
|
def reload(self):
|
||||||
|
if self.token:
|
||||||
|
self.data = requests.post('https://' + self.client.endpoint + '/oauth2/userInfo', headers={'Authorization' :"Bearer " + self.token}).json()
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
wheel
|
||||||
|
requests
|
62
setup.py
Normal file
62
setup.py
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
import re
|
||||||
|
from os import path
|
||||||
|
|
||||||
|
from setuptools import setup
|
||||||
|
from codecs import open
|
||||||
|
|
||||||
|
here = path.abspath(path.dirname(__file__))
|
||||||
|
|
||||||
|
# Get the long description from the README file
|
||||||
|
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
|
||||||
|
long_description = f.read()
|
||||||
|
|
||||||
|
def read(*parts):
|
||||||
|
return open(path.join(here, *parts), 'r').read()
|
||||||
|
|
||||||
|
def find_version(*file_paths):
|
||||||
|
version_file = read(*file_paths)
|
||||||
|
version_match = re.search(r"^version = ['\"]([^'\"]*)['\"]",
|
||||||
|
version_file, re.M)
|
||||||
|
if version_match:
|
||||||
|
return version_match.group(1)
|
||||||
|
raise RuntimeError("Unable to find version string.")
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='cognito-oauthtools',
|
||||||
|
version=find_version('cognito_oauthtools','__init__.py'),
|
||||||
|
description='Simple AWS Cognito client to simplify implementation',
|
||||||
|
long_description=long_description,
|
||||||
|
long_description_content_type="text/markdown",
|
||||||
|
|
||||||
|
# The project's main homepage.
|
||||||
|
url='https://github.com/josephbmanley/cognito-oauthtools',
|
||||||
|
|
||||||
|
# Author details
|
||||||
|
author='Joseph Manley',
|
||||||
|
author_email='j@cloudsumu.com',
|
||||||
|
|
||||||
|
# Choose your license
|
||||||
|
license='GPL3.0',
|
||||||
|
|
||||||
|
# See https://pypi.org/classifiers/
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 5 - Production/Stable',
|
||||||
|
'Intended Audience :: Developers',
|
||||||
|
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
|
||||||
|
'Programming Language :: Python :: 2',
|
||||||
|
'Programming Language :: Python :: 2.7',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
'Programming Language :: Python :: 3.3',
|
||||||
|
'Programming Language :: Python :: 3.4',
|
||||||
|
'Programming Language :: Python :: 3.5',
|
||||||
|
'Programming Language :: Python :: 3.6',
|
||||||
|
'Programming Language :: Python :: 3.7',
|
||||||
|
'Programming Language :: Python :: 3.8'
|
||||||
|
],
|
||||||
|
keywords='AWS,Cognito,OAuth',
|
||||||
|
packages=["cognito_oauthtools"],
|
||||||
|
install_requires=['requests'],
|
||||||
|
package_data={},
|
||||||
|
entry_points={}
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user