Skip to content

Commit abe1b7f

Browse files
authored
dont look up user if no api key is given (#1185)
* dont look up user if no api key is given * disable recording of last key usage in redis (temporarily)
1 parent e977b01 commit abe1b7f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/server/_common.py

+4
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ def after_request_execute(response):
162162

163163
@app.teardown_appcontext
164164
def teardown_db(exception=None):
165+
# drop reference to "user" (if it exists)
166+
if "user" in g:
167+
g.pop("user")
168+
165169
# close the db connection
166170
db = g.pop("db", None)
167171

src/server/_security.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ def require_api_key() -> bool:
8181
def _get_current_user():
8282
if "user" not in g:
8383
api_key = resolve_auth_token()
84-
g.user = User.find_user(api_key=api_key)
84+
if api_key:
85+
g.user = User.find_user(api_key=api_key)
86+
else:
87+
g.user = None
8588
return g.user
8689

8790

@@ -122,6 +125,8 @@ def decorated_function(*args, **kwargs):
122125

123126

124127
def update_key_last_time_used(user):
128+
# TODO: reenable this once cc<-->aws latency issues are sorted out, or maybe do this call asynchronously
129+
return
125130
if user:
126131
# update last usage for this user's api key to "now()"
127132
r = redis.Redis(host=REDIS_HOST, password=REDIS_PASSWORD)

0 commit comments

Comments
 (0)