from typing import Optional
from typing import Sequence
from typing import Callable
from typing import Any


def auth(
    policy: Optional[str] = None,
    *,
    authentication_schemes: Optional[Sequence[str]] = None
) -> Callable[..., Any]:
    """
    Configures authorization for a decorated request handler,
    optionally with a policy.
    If no policy is specified, the default policy of the configured
    AuthorizationStrategy is used.

    :param policy: optional, name of the policy to use for authorization.
    :param authentication_schemes: optional, authentication schemes to use
    for this handler. If not specified, all configured authentication handlers
    are used.
    """

    def decorator(f):
        f.auth = True
        f.auth_policy = policy
        f.auth_schemes = authentication_schemes
        return f

    return decorator