def basic_auth(username, password) -> bool:
    ' HTTP basic authorization '
    query_result = Application.query.join(User, (User.id == Application.userIntID)).with_entities(Application, User).filter((Application.appStatus == 1), (User.enable == 1), (Application.appID == username)).first()
    if (not query_result):
        raise AuthFailed(field='appID')
    (application, user) = query_result
    date_now = arrow.now().naive
    if (application.expiredAt and (date_now > application.expiredAt)):
        raise AuthFailed(field='expiredAt')
    if (application.appToken != password):
        raise AuthFailed(field='appToken')
    g.user_id: int = user.id
    g.tenant_uid: str = user.tenantID
    g.role_id: int = application.roleIntID
    g.app_uid: str = application.appID
    user.lastRequestTime = date_now
    user.update()
    return True
HTTP basic authorization
def basic_auth(username, password) -> bool:
    '  '
    query_result = Application.query.join(User, (User.id == Application.userIntID)).with_entities(Application, User).filter((Application.appStatus == 1), (User.enable == 1), (Application.appID == username)).first()
    if (not query_result):
        raise AuthFailed(field='appID')
    (application, user) = query_result
    date_now = arrow.now().naive
    if (application.expiredAt and (date_now > application.expiredAt)):
        raise AuthFailed(field='expiredAt')
    if (application.appToken != password):
        raise AuthFailed(field='appToken')
    g.user_id: int = user.id
    g.tenant_uid: str = user.tenantID
    g.role_id: int = application.roleIntID
    g.app_uid: str = application.appID
    user.lastRequestTime = date_now
    user.update()
    return True