def METHOD_NAME(types: tuple[str] = ('user', 'node', 'container')):
    """
    JWT endpoint protection decorator
    Parameters
    ----------
    types : list[str]
        List of types that are allowed to access the endpoint. Possible types
        are 'user', 'node' and 'container'.
    Returns
    -------
    function
        Decorator function that can be used to protect endpoints
    """
    def protection_decorator(fn):
        @wraps(fn)
        def decorator(*args, **kwargs):
            # decode JWT-token
            identity = get_jwt_identity()
            claims = get_jwt()
            # check that identity has access to endpoint
            g.type = claims["client_type"]
            # log.debug(f"Endpoint accessed as {g.type}")
            if g.type not in types:
                # FIXME BvB 23-10-19: user gets a 500 error, would be better to
                # get an error message with 400 code
                msg = f"{g.type}s are not allowed to access {request.url} " \
                      f"({request.method})"
                log.warning(msg)
                raise Exception(msg)
            # do some specific stuff per identity
            g.user = g.container = g.node = None
            if g.type == 'user':
                user = get_and_update_authenticatable_info(identity)
                g.user = user
                assert g.user.type == g.type
                log.debug(
                    f"Received request from user {user.username} ({user.id})")
            elif g.type == 'node':
                node = get_and_update_authenticatable_info(identity)
                g.node = node
                assert g.node.type == g.type
                log.debug(
                    f"Received request from node {node.name} ({node.id})")
            elif g.type == 'container':
                g.container = identity
                log.debug(
                    "Received request from container with node id "
                    f"{identity['node_id']} and task id {identity['task_id']}")
            else:
                raise Exception(f"Unknown entity: {g.type}")
            return fn(*args, **kwargs)
        return jwt_required()(decorator)
    return protection_decorator