+ {
+ // Validate the token and it's users API access
+ $this->ensureAuthorizedBySessionOrToken();
+
+ return $next($request);
+ }
+
+ /**
+ * Ensure the current user can access authenticated API routes, either via existing session
+ * authentication or via API Token authentication.
+ *
+ * @throws ApiAuthException
+ */
+ protected function ensureAuthorizedBySessionOrToken(): void