def is_authorized_for_domain(name):
    """
    If authorization plugin is available, perform the check to see if current user can issue certificate for a given
    domain.
    Raises UnauthorizedError if unauthorized.
    If authorization plugin is not available, it returns without performing any check

    :param name: domain (string) for which authorization check is being done
    """
    if current_app.config.get("USER_DOMAIN_AUTHORIZATION_PROVIDER") is None:
        # nothing to check since USER_DOMAIN_AUTHORIZATION_PROVIDER is not configured
        return

    user_domain_authorization_provider = plugins.get(current_app.config.get("USER_DOMAIN_AUTHORIZATION_PROVIDER"))
    # if the caller can be mapped to an application name, use that to perform authorization
    # this could be true when using API key to call lemur (migration script e2d406ada25c_.py)
    caller = g.caller_application if hasattr(g, 'caller_application') else g.user.email
    authorized, error = user_domain_authorization_provider.is_authorized(domain=name, caller=caller)

    if error:
        raise error
    if not authorized:
        raise UnauthorizedError(user=caller, resource=name, action="issue_certificate")

    If authorization plugin is available, perform the check to see if current user can issue certificate for a given
    domain.
    Raises UnauthorizedError if unauthorized.
    If authorization plugin is not available, it returns without performing any check

    :param name: domain (string) for which authorization check is being done
    
lemur/domains/service.py