forked from SoftwareDefinedBuildings/XBOS
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request SoftwareDefinedBuildings#25 from rajasriramoju/24-…
…merge-login 24 merge login
- Loading branch information
Showing
20 changed files
with
990 additions
and
504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.env | ||
*.json | ||
*.egg-info | ||
config.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
okta-flask-example | ||
================== | ||
|
||
A simple Flask app with user registration and login. | ||
|
||
|
||
Meta | ||
---- | ||
|
||
- Author: Randall Degges | ||
- Email: [email protected] | ||
- Site: https://www.rdegges.com | ||
|
||
|
||
Purpose | ||
------- | ||
|
||
This example app showcases how you can easily add user login, registration, etc. | ||
into a Flask web app using OpenID Connect and `Okta | ||
<https://developer.okta.com>`_. | ||
|
||
I wrote this to showcase how to get stuff working in a simple way. | ||
|
||
.. note:: | ||
|
||
I wrote a blog post showcasing how this example app was built. You can view it | ||
here: https://developer.okta.com/blog/2018/07/12/flask-tutorial-simple-user-registration-and-login | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
To install the sample app you need to have Python 2.7 or 3.4+ installed. You can | ||
then install the project dependencies by running: | ||
|
||
.. code-block:: console | ||
$ pip install -e . | ||
This will install all the project dependencies. | ||
|
||
|
||
Running the App | ||
--------------- | ||
|
||
This app requires Okta to run. Okta is a free-to-use API service that stores | ||
user accounts and makes authentication and authorization simpler. Go create a | ||
free Okta developer account before continuing: https://developer.okta.com/signup | ||
|
||
Next, you need to create a ``client_secrets.json`` file. This holds the OpenID | ||
Connect information necessary for the app to function. Create a file named | ||
``client_secrets.json`` in the root of your project folder and add the following | ||
contents. | ||
|
||
.. code-block:: json | ||
{ | ||
"web": { | ||
"client_id": "{{ OKTA_CLIENT_ID }}", | ||
"client_secret": "{{ OKTA_CLIENT_SECRET }}", | ||
"auth_uri": "{{ OKTA_ORG_URL }}/oauth2/default/v1/authorize", | ||
"token_uri": "{{ OKTA_ORG_URL }}/oauth2/default/v1/token", | ||
"issuer": "{{ OKTA_ORG_URL }}/oauth2/default", | ||
"userinfo_uri": "{{ OKTA_ORG_URL }}/oauth2/default/userinfo", | ||
"redirect_uris": [ | ||
"http://localhost:5000", | ||
"http://localhost:5000/oidc/callback" | ||
] | ||
} | ||
} | ||
.. note:: | ||
|
||
Be sure to replace the Okta variables above appropriately. | ||
|
||
Next, define some necessary environment variables. | ||
|
||
.. code-block:: console | ||
export SECRET_KEY={{ RANDOM_STRING_HERE }} | ||
export OKTA_ORG_URL={{ OKTA_ORG_URL }} | ||
export OKTA_AUTH_TOKEN={{ OKTA_AUTH_TOKEN }} | ||
Set the ``SECRET_KEY`` variable to a long, random string. This will be used to | ||
secure your sessions (cookies). Then set the other two Okta variables | ||
appropriately. | ||
|
||
Next, run the web server. | ||
|
||
.. code-block:: console | ||
flask run | ||
Finally, go visit http://localhost:5000 and explore the site! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" | ||
Packaging information and tools. | ||
""" | ||
|
||
|
||
from os.path import abspath, dirname, join, normpath | ||
|
||
from setuptools import find_packages, setup | ||
|
||
|
||
setup( | ||
# Basic package information: | ||
name="okta-flask-example", | ||
version="1.0.0", | ||
packages=find_packages(), | ||
# Packaging options: | ||
zip_safe=False, | ||
include_package_data=True, | ||
# Package dependencies: | ||
install_requires=["Flask>=1.0.0", "flask-oidc>=1.4.0", "okta==0.0.4"], | ||
# Metadata for PyPI: | ||
author="Randall Degges", | ||
author_email="[email protected]", | ||
license="UNLICENSE", | ||
url="https://github.com/rdegges/okta-flask-example", | ||
keywords="python security authentication user login registration flask web okta openid connect", | ||
description="A simple Flask app with user registration and login.", | ||
long_description=open( | ||
normpath(join(dirname(abspath(__file__)), "README.rst")) | ||
).read(), | ||
classifiers=[ | ||
"Development Status :: 5 - Production/Stable", | ||
"Environment :: Console", | ||
"Intended Audience :: Developers", | ||
"License :: Public Domain", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 2", | ||
"Programming Language :: Python :: 2.7", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.4", | ||
"Programming Language :: Python :: 3.5", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
"Topic :: Internet", | ||
], | ||
) |
Oops, something went wrong.