Skip to content

Commit ed397a1

Browse files
committed
working on next post
1 parent 94e11fa commit ed397a1

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Posts and associated code:
77

88
|Post|Code Directory|
99
|---|---|
10+
|[How to Add User Authentication to Flask Apps with Okta](https://www.fullstackpython.com/blog/add-user-authentication-flask-apps-okta.html)|[flask-auth-okta](./flask-auth-okta)|
1011
|[Running Bottle Apps in Docker Containers on macOS](https://www.fullstackpython.com/blog/first-steps-bottle-web-apps-docker-containers.html)|[docker-bottle-mac](./docker-bottle-mac)|
1112
|[How to Add Maps to Django Web App Projects with Mapbox](https://www.fullstackpython.com/blog/maps-django-web-applications-projects-mapbox.html)|[maps-django-mapbox](./maps-django-mapbox)|
1213
|[Full Stack Python at PyCon US 2018](https://www.fullstackpython.com/blog/full-stack-python-pycon-us-2018.html)|No code in post.|

flask-auth-okta/app.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from os import environ
2+
from flask import Flask, Response
3+
4+
5+
app = Flask(__name__)
6+
app.config["DEBUG"] = True
7+
# secret credentials for Okta connection
8+
app.config["OIDC_CLIENT_SECRETS"] = "client_secrets.json"
9+
app.config["OIDC_COOKIE_SECURE"] = False
10+
app.config["OIDC_CALLBACK_ROUTE"] = "/oidc/callback"
11+
app.config["OIDC_SCOPES"] = ["openid", "email", "profile"]
12+
app.config["SECRET_KEY"] = environ.get("SECRET_KEY")
13+
app.config["OIDC_ID_TOKEN_COOKIE_NAME"] = "oidc_token"
14+
# instantiate Open ID client to handle user session
15+
oidc = OpenIDConnect(app)
16+
# Okta client will determine if a user has an appropriate account
17+
okta_client = UsersClient(environ.get("OKTA_ORG_URL"),
18+
environ.get("OKTA_AUTH_TOKEN"))
19+
20+
21+
@app.route("/lair")
22+
def lair():
23+
return Response("Thundercats (supposed to be hidden) lair.")
24+
25+
26+
@app.route("/")
27+
def landing_page():
28+
return Response("Thundercats, Thundercats, hoooooooooooo!")
29+

0 commit comments

Comments
 (0)