Add a banner to the Quay UI when an app specific token is about to expire
This commit is contained in:
parent
5b4f5f9859
commit
888b564a9b
9 changed files with 60 additions and 9 deletions
|
@ -11,13 +11,17 @@ from util.timedeltastring import convert_to_timedelta
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@lru_cache(maxsize=1)
|
||||
def _default_expiration():
|
||||
expiration_str = config.app_config.get('APP_SPECIFIC_TOKEN_EXPIRATION')
|
||||
return datetime.now() + convert_to_timedelta(expiration_str) if expiration_str else expiration_str
|
||||
|
||||
|
||||
_default_expiration_opt = 'deo'
|
||||
# Define a "unique" value so that callers can specifiy an expiration of None and *not* have it
|
||||
# use the default.
|
||||
_default_expiration_opt = '__deo'
|
||||
|
||||
def create_token(user, title, expiration=_default_expiration_opt):
|
||||
""" Creates and returns an app specific token for the given user. If no expiration is specified
|
||||
(including `None`), then the default from config is used. """
|
||||
|
|
Reference in a new issue