Question
Error: No 'authenticate' hook on service leads to open endpoint
Rin Lane
0 reputation · 23 Apr 2021, 03:34 UTC
42.9K views0
Preventing Accidental Public Access in FeathersJS
The goal is to ensure that every service exposed via REST or Socket.io is protected by an authentication check. By default, if a service lacks the authenticate hook, FeathersJS treats it as public and returns data without requiring credentials.
Key constraints include:
- Services are automatically reachable unless the
beforehook chain containsauthenticate. - Hook ordering matters: a data‑fetching hook placed before the authentication hook can leak sensitive data.
- There is no built‑in global flag that forces all services to be authenticated.
Given these uncertainties, the following questions need resolution:
- How can a developer enforce the presence of an
authenticatehook on every service automatically, without manually editing each service file? - What best practices exist to guarantee that no data‑retrieval hook runs before the authentication hook, preventing accidental data leakage?
- Is there a configuration option or middleware that blocks all endpoints unless an explicit authentication hook is defined?