-
Notifications
You must be signed in to change notification settings - Fork 3
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 #35 from uc-cdis/fix/do-not-allow-infinite-access-…
…tokens (PXP-8420): Do not allow infinite access tokens
- Loading branch information
Showing
7 changed files
with
25 additions
and
35 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
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
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 |
---|---|---|
@@ -1,16 +1,10 @@ | ||
from functools import wraps | ||
import flask | ||
|
||
from .auth_plugins import find_user | ||
from cdiserrors import AuthError | ||
|
||
|
||
def login_required(f): | ||
@wraps(f) | ||
def decorated_function(*args, **kwargs): | ||
if not hasattr(flask.g, "user"): | ||
flask.g.user = find_user() | ||
if not flask.g.user: | ||
raise AuthError("You need to be authenticated to use this resource") | ||
return f(*args, **kwargs) | ||
|
||
return decorated_function | ||
def authenticate(allow_access_token=False): | ||
flask.g.user = find_user(allow_access_token) | ||
if not flask.g.user: | ||
raise AuthError("You need to be authenticated to use this resource") |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
from .base import DefaultPlugin | ||
from .base import AccessTokenPlugin | ||
from .k8s import K8SPlugin | ||
import flask | ||
|
||
|
||
def find_user(): | ||
if flask.request.headers.get("Authorization"): | ||
return DefaultPlugin().find_user() | ||
def find_user(allow_access_token=False): | ||
if allow_access_token and flask.request.headers.get("Authorization"): | ||
return AccessTokenPlugin().find_user() | ||
return K8SPlugin().find_user() |
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