Source code for luna_licenses.app.handlers.base_handler
import hashlib
from app.app import LicensesApp
from configs.configs.configs.services.licenses import SettingsLicenses
from crutches_on_wheels.web.handlers import BaseHandler
[docs]class BaseLicensesRequestHandler(BaseHandler):
"""
Base handler for other handlers.
"""
@property
def app(self) -> LicensesApp:
"""
Get running app
Returns:
app
"""
return self.request.app
@property
def config(self) -> SettingsLicenses:
"""
Get app config
Returns:
app config
"""
return self.app.serviceConfig
[docs] def successWithSignature(self, **kwargs):
"""Success response with signature header"""
webResponse = self.success(**kwargs)
# Sign response
signature = hashlib.pbkdf2_hmac("sha256", webResponse.body, self.requestId.encode(), 1000)
webResponse.headers["Signature"] = signature.hex()
return webResponse