-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
609dd99
commit 7fa29be
Showing
8 changed files
with
58 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python3 | ||
|
||
__copyright__ = 'Copyright (c) 2024, Utrecht University' | ||
__license__ = 'GPLv3, see LICENSE' | ||
|
||
from flask import g, request, session | ||
from flask_caching import Cache | ||
|
||
config = { | ||
'CACHE_TYPE': 'FileSystemCache', | ||
'CACHE_DIR': '/tmp', | ||
'CACHE_DEFAULT_TIMEOUT': 300 | ||
} | ||
|
||
|
||
def authenticated() -> bool: | ||
return g.get('user') is not None and g.get('irods') is not None | ||
|
||
|
||
def make_key(key=None) -> str: | ||
if key is None: | ||
key = f"{request.endpoint}_{request.method}" | ||
|
||
if authenticated(): | ||
return f"{session.sid}-{key}" | ||
else: | ||
return f"unauthenticated-{key}" | ||
|
||
|
||
# Create a Cache instance. | ||
cache = Cache(config=config) |
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
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