Skip to content

Commit

Permalink
Merge pull request #1368 from cityofaustin/roll-back-cr3-changes
Browse files Browse the repository at this point in the history
Anti-PR to 1338; revert library updates and restructuring of CR3 API flask lambda apps
  • Loading branch information
frankhereford authored Jan 30, 2024
2 parents 964f51c + 9008e54 commit fdd9e66
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 25 deletions.
17 changes: 8 additions & 9 deletions atd-cr3-api/.env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
AUTH0_DOMAIN=atd-datatech.auth0.com
CLIENT_ID=2qbqz2sf8L9idBOwn0d5YA9efNgQbL7c
AWS_DEFALUT_REGION=us-east-1
AWS_S3_CR3_LOCATION=staging/path_to_files
AWS_S3_BUCKET=your_bucket_name_here
AWS_S3_KEY=your_s3_key_here
AWS_S3_SECRET=your_s3_secret_here
API_CLIENT_ID=secret_here
API_CLIENT_SECRET=secret_here
API_ENVIRONMENT="STAGING"
AUTH0_DOMAIN="atd-datatech.auth0.com"
CLIENT_ID="2qbqz2sf8L9idBOwn0d5YA9efNgQbL7c"
AWS_DEFALUT_REGION="us-east-1"
AWS_S3_CR3_LOCATION="staging/path_to_files"
AWS_S3_BUCKET="your_bucket_name_here"
AWS_S3_KEY="your_s3_key_here"
AWS_S3_SECRET="your_s3_secret_here"
46 changes: 41 additions & 5 deletions atd-cr3-api/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
boto3==1.34.*
requests==2.31.*
python-dotenv==1.0.*
Flask-Cors==4.0.*
python-jose==3.3.*
argcomplete==1.11.1
boto3==1.*
botocore==1.*
certifi==2022.12.7
cfn-flip==1.2.2
chardet==3.0.4
Click==7.0
docutils==0.15.2
durationpy==0.5
ecdsa==0.15
Flask==1.1.1
Flask-Cors==3.0.9
future==0.18.3
hjson==3.0.1
idna==2.9
importlib-metadata==1.5.0
itsdangerous==1.1.0
Jinja2==2.11.3
jmespath==0.9.5
kappa==0.6.0
MarkupSafe==1.1.1
pip-tools==4.5.1
placebo==0.9.0
pyasn1==0.4.8
python-dateutil==2.6.1
python-dotenv==0.12.0
python-jose==3.1.0
python-slugify==4.0.0
PyYAML==5.4
requests==2.*
rsa==4.7
s3transfer==0.3.3
six==1.14.0
text-unidecode==1.3
toml==0.10.0
tqdm==4.43.0
troposphere==4.*
urllib3==1.26.5
Werkzeug==0.16.1
wsgi-request-logger==0.4.6
zappa==0.56.*
zipp==3.1.0
15 changes: 4 additions & 11 deletions atd-cr3-api/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
from functools import wraps
from six.moves.urllib.request import urlopen

from flask import Flask, request, redirect, jsonify, abort, g

from flask import Flask, request, redirect, jsonify, _request_ctx_stack, abort
from flask_cors import cross_origin
from werkzeug.local import LocalProxy
from jose import jwt
Expand Down Expand Up @@ -215,7 +214,7 @@ def decorated(*args, **kwargs):
},
401,
)
g.current_user = payload
_request_ctx_stack.top.current_user = payload
return f(*args, **kwargs)
raise AuthError(
{"code": "invalid_header", "description": "Unable to find appropriate key"},
Expand All @@ -225,7 +224,7 @@ def decorated(*args, **kwargs):
return decorated


current_user = LocalProxy(lambda: getattr(g, "current_user", None))
current_user = LocalProxy(lambda: getattr(_request_ctx_stack.top, "current_user", None))

# Controllers API

Expand Down Expand Up @@ -329,13 +328,7 @@ def user_list_users():
page = request.args.get("page")
per_page = request.args.get("per_page")
if isValidUser(user_dict) and hasUserRole("admin", user_dict):
endpoint = (
f"https://{AUTH0_DOMAIN}/api/v2/users?page="
+ page
+ "&per_page="
+ per_page
+ "&include_totals=true"
)
endpoint = f"https://{AUTH0_DOMAIN}/api/v2/users?page=" + page + "&per_page=" + per_page + "&include_totals=true"
headers = {"Authorization": f"Bearer {get_api_token()}"}
response = requests.get(endpoint, headers=headers).json()
return jsonify(response)
Expand Down

0 comments on commit fdd9e66

Please sign in to comment.