simple online nosql database database with REST API and MongoDB queries
  • Features
  • Docs
  • Blog
  • Templates
  • Pricing
  • Contact
  • Sign Up
  • Log In

Blog

 The latest news and articles about restdb.io  

Database templates!
Don't forget to visit our template catalog! It's the fastest way to get up and running with a restdb.io database. View templates »

Password protected Pages

by Jon Erik Solheim
|
User|Howto|
  • Share on Facebook
  • Tweet
  • Add to Pocket
  • Share on LinkedIn
  • Send email
Restdb Pages lets you create any content from your database and deliver it on a custom route. However, sensitive content must be protected. That's why we made it simple to include user authentication in any Page. All you have to do is to add the #auth tag to the Page source code.

The #auth tag instructs the server to require an authenticated user before serving the Page content. The example below shows how to protect a page with a simple username and password.

{{#auth}}
{"password": "secret", "user": "jane"}
{{/auth}}

My sensitive content here ...
Hard coding a username and a password is ok for a quick-fix or ad-hoc needs. For a more scalable solution the users and the passwords should be managed in your database.

This example shows how to authenticate users against a database Collection called "myusers". This collection must contain fields for username and password.

The #context query uses the credentials object from the Page authentication to match a record from the database Collection, and the #auth tag matches the first record from this result to verify an user.

{{#context}}
{
    "user": {
        "collection": "myusers",
        "query": {"username": "{{credentials.name}}", "password": "{{credentials.pass}}"}
    }
 }
{{/context}}

{{#auth}}
{
    "password": "{{user.0.password}}", "user": "{{user.0.username}}"
}
{{/auth}}
... 
Top secret content here
This is how a web browser will present a Page with authentication:


Check out the demo site for examples at restdb.site.

Read the docs: https://restdb.io/docs/Pages
  • Share on Facebook
  • Tweet
  • Add to Pocket
  • Share on LinkedIn
  • Send email

All Posts


Search

Topics

  • API
  • Authentication
  • Case study
  • Features
  • Howto
  • Integrations
  • Newsletter
  • Productivity
  • Prototyping
  • Tutorials
  • User

restdb.io is a fast and simple NoSQL cloud database service. With restdb.io you get schema, relations, REST API and an efficient multi-user admin UI for working with data.

Our customers use it for backends, business databases, API-first CMS, data collection and much more. It is easy to get started with the free development plan.

Start Building »

  • Site Links
  • Home Page
  • About Us
  • Contact
  • Blog
  • Templates Catalog
  • Cloud Service
  • Features
  • Pricing
  • Terms & Conditions
  • Privacy Policy
  • Sign Up »
  • Documentation
  • Overview
  • Getting Started
  • Coding against the API
  • Utils
  • Security and Admin
© 2025 restdb.io