def __init__(self): config_dir = os.environ['SILVER_APP_CONFIG'] config = None for name in ['local.yaml', 'velruse.yaml']: if os.path.exists(os.path.join(config_dir, name)): config = os.path.join(config_dir, name) break tmp = os.environ['TEMP'] self.auth_app = VelruseApp( config, {'Store': { 'Type': 'SQL', 'DB': os.environ['CONFIG_MYSQL_SQLALCHEMY'], }, 'OpenID Store': { 'Type': 'openid.store.filestore:FileOpenIDStore', 'directory': os.path.join(tmp, 'openid'), } }) tmp = os.environ['TEMP'] self.auth_session_app = SessionMiddleware( self.auth_app, data_dir=os.path.join(tmp, 'beaker'), lock_dir=os.path.join(tmp, 'beaker.lock'), type='cookie', cookie_expires=False, encrypt_key=get_secret(), validate_key=get_secret(), ) self.debug = not is_production() self.store = SQLStore.from_silver()
def check_value(encoded, secret=get_secret()): data, salt, hash = encoded.split('|') value = str(urllib.unquote(data)) check_hash = hash_signature(salt, value, secret) if hash != check_hash: ## FIXME: log return None return value
def sign_value(value, secret=get_secret()): salt = create_salt() hash = hash_signature(salt, value, secret) data = urllib.quote(value, '') return data + '|' + salt + '|' + hash