def add_auth_attribute(attr, value, actor=False):
    """
    Helper function for login managers. Adds authorization attributes
    to :obj:`current_auth` for the duration of the request.

    :param str attr: Name of the attribute
    :param value: Value of the attribute
    :param bool actor: Whether this attribute is an actor
       (user or client app accessing own data)

    If the attribute is an actor and :obj:`current_auth` does not currently
    have an actor, the attribute is also made available as
    ``current_auth.actor``, which in turn is used by
    ``current_auth.is_authenticated``.

    The attribute name ``user`` is special-cased:

    1. ``user`` is always treated as an actor
    2. ``user`` is also made available as ``_request_ctx_stack.top.user`` for
       compatibility with Flask-Login
    """
    if attr in ('actor', 'anchors', 'is_anonymous', 'not_anonymous', 'is_authenticated', 'not_authenticated'):
        raise AttributeError("Attribute name %s is reserved by current_auth" % attr)

    # Invoking current_auth will also create it on the local stack. We can
    # then proceed to set attributes on it.
    ca = current_auth._get_current_object()
    # Since :class:`CurrentAuth` overrides ``__setattr__``, we need to use :class:`object`'s.
    object.__setattr__(ca, attr, value)

    if attr == 'user':
        # Special-case 'user' for compatibility with Flask-Login
        _request_ctx_stack.top.user = value
        # A user is always an actor
        actor = True

    if actor:
        object.__setattr__(ca, 'actor', value)
Helper function for login managers. Adds authorization attributes
    to :obj:`current_auth` for the duration of the request.

    :param str attr: Name of the attribute
    :param value: Value of the attribute
    :param bool actor: Whether this attribute is an actor
       (user or client app accessing own data)

    If the attribute is an actor and :obj:`current_auth` does not currently
    have an actor, the attribute is also made available as
    ``current_auth.actor``, which in turn is used by
    ``current_auth.is_authenticated``.

    The attribute name ``user`` is special-cased:

    1. ``user`` is always treated as an actor
    2. ``user`` is also made available as ``_request_ctx_stack.top.user`` for
       compatibility with Flask-Login