directus-extension-block-endpoints

1.0.6 • Public • Published

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

name type default example
BLOCKED_ENDPOINTS_ENABLED boolean true
BLOCKED_ENDPOINTS_PATHS string|string[] /server/info,/test
BLOCKED_ENDPOINTS_STATUS number 418 401
BLOCKED_ENDPOINTS_TYPE string application/json
BLOCKED_ENDPOINTS_BODY string { "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

Package Sidebar

Install

npm i directus-extension-block-endpoints

Weekly Downloads

0

Version

1.0.6

License

MIT

Unpacked Size

59.5 kB

Total Files

4

Last publish

Collaborators

  • brainslug