Require specific configured roles for access to a :mod:`flask` route.

        :param roles: Role or list of roles to test for access
                      (only one role is required to pass).
        :type roles: str OR list(str)
        :raises: FlaskKeystoneForbidden

        This method will gate a particular endpoint to only be accessed by
        :class:`FlaskKeystone.User`'s with a particular configured role. If the
        role given does not exist, or if the user does not have the requested
        role, a FlaskKeystoneForbidden exception will be thrown, resulting in a
        403 response to the client.

def requires_role(self, roles):
        """
        Require specific configured roles for access to a :mod:`flask` route.

        :param roles: Role or list of roles to test for access
                      (only one role is required to pass).
        :type roles: str OR list(str)
        :raises: FlaskKeystoneForbidden

        This method will gate a particular endpoint to only be accessed by
        :class:`FlaskKeystone.User`'s with a particular configured role. If the
        role given does not exist, or if the user does not have the requested
        role, a FlaskKeystoneForbidden exception will be thrown, resulting in a
        403 response to the client.
        """
        def wrap(f):
            @wraps(f)
            def wrapped_f(*args, **kwargs):
                if isinstance(roles, list):
                    if any(current_user.has_role(role) for role in roles):
                        return f(*args, **kwargs)

                elif isinstance(roles, str):
                    if current_user.has_role(roles):
                        return f(*args, **kwargs)
                else:
                    msg = ("roles parameter for requires_role on endpoint %s "
                           "should be a list or str, but is type %s.")
                    self.logger.error(msg % (
                        request.path,
                        type(roles)
                    ))

                msg = ("Rejected User '%s' access to '%s' "
                       "due to RBAC. (Requires '%s')")

                self.logger.info(msg % (
                    current_user.user_id,
                    request.path,
                    roles
                ))

                raise FlaskKeystoneForbidden()

            return wrapped_f
        return wrap