Add a banner to the Quay UI when an app specific token is about to expire

This commit is contained in:
Joseph Schorr 2017-12-12 17:51:54 -05:00
parent 5b4f5f9859
commit 888b564a9b
9 changed files with 60 additions and 9 deletions

View file

@ -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. """