dehaze

Securing your Database APIs

You can easily configure access control for the database APIs with Space Cloud’s security rules. The security rules in the database module work on the operation level (create, read, update, delete) for each table/collection. This means that you can have different rules for different operations on each table/collection.

Here’s a sample snippet which shows the rules on the users table. Operations create and read are allowed while update and delete are blocked:

{
  "create": {
    "rule": "allow"
  },
  "read": {
    "rule": "allow"
  },
  "update": {
    "rule": "deny"
  },
  "delete": {
    "rule": "deny"
  }
}

Space Cloud’s security rules are flexible enough to enforce any access control logic including querying your databases, validating conditions and masking private data. Check out the documentation of security rules to learn more.

Configuring security ruleslink

Head over to the Overview tab in the Database section of the Mission Control.

Tracked Tables

Click on the Secure action on any of the tracked tables/collections.

This will open a Rule Builder UI to configure the rules easily:

Tracked Tables

The rule editor also comes packed with few shortcuts to make you feel productive.

If you are more comfortable with JSON, you can switch to the JSON editor as well by clicking on the JSON tab.

The API Explorer of Mission Control comes packed with a token builder as well to make testing your security rules for different JWT claims a breeze!

Available variableslink

Following are the variables available in the security rules for different operations in the database module:

Database createlink

Variable Data type Description
args.auth Object Object containing the JWT claims present in the token.
args.doc Object Document/row to be inserted into the database.
args.token String Raw token present under the Authorization header in the request. (with the Bearer prefix removed)

Database readlink

Variable Data type Description
args.auth Object Object containing the JWT claims present in the token.
args.find Object The find/where clause of the read operation. Follows the MongoDB DSL.
args.token String Raw token present under the Authorization header in the request. (with the Bearer prefix removed)
args.opts.limit Number Value of the limit clause if specified in the request.
args.opts.skip Number Value of the skip clause if specified in the request.

Database updatelink

Variable Data type Description
args.auth Object Object containing the JWT claims present in the token.
args.find Object The find/where clause of the update operation. Follows the MongoDB DSL.
args.update Object The update clause of the update operation. Follows the MongoDB DSL.
args.token String Raw token present under the Authorization header in the request. (with the Bearer prefix removed)

Database deletelink

Variable Data type Description
args.auth Object Object containing the JWT claims present in the token.
args.find Object The find/where clause of the delete operation. Follows the MongoDB DSL.
args.token String Raw token present under the Authorization header in the request. (with the Bearer prefix removed)

Database prepared querylink

Variable Data type Description
args.auth Object Object containing the JWT claims present in the token.
args.params Object Object containing the params to be passed to the prepared query.
args.token String Raw token present under the Authorization header in the request. (with the Bearer prefix removed)

Have a technical question?

Improve the docs!