1.0.6 • Published 2 months ago

directus-extension-block-endpoints v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Directus Extension Block Endpoints

As the name suggests this extension will allow you to block any endpoint with a custom message.

Tested with Directus 10.10.4

Note: blocking /server/info seems to break the app in > 9.23.1

Installation

The package is published to npm: npm install directus-extension-block-endpoints

Manual Installation

  • Download or fork the repository
  • Install the requirements\ npm install
  • Build the extension\ npm run build
  • Move the result to your extension folder\ mv dist extensions/hooks/directus-extension-block-endpoints
  • Add required environment variables (see below)
  • Restart your Directus instance

Environment Variables

nametypedefaultexample
BLOCKED_ENDPOINTS_ENABLEDbooleantrue
BLOCKED_ENDPOINTS_PATHSstring|string[]/server/info,/test
BLOCKED_ENDPOINTS_STATUSnumber418401
BLOCKED_ENDPOINTS_TYPEstringapplication/json
BLOCKED_ENDPOINTS_BODYstring{ "error": "Page blocked! I\'m a teapot now" }

Usages

warning: This will only block GET requests! but the script should be easy to modify to any METHOD you want (making it configurable seemed like a mess)

To block /server/info from exposing info when using Directus API only:

ENV

BLOCKED_ENDPOINTS_PATHS="/server/info"
BLOCKED_ENDPOINTS_STATUS=401
BLOCKED_ENDPOINTS_TYPE="text/plain"
BLOCKED_ENDPOINTS_BODY="Access Denied!!"

REQUEST

GET /server/info
Access Denied!!
-> 401