Skip to content

Quick Start

This document is a step-by-step guide for basically adding support for authentication and authorization to your Hitchy-based application using this plugin.

Setup Project

Create a folder for your application and enter it:

bash
mkdir my-new-app
cd my-new-app

Initialize your application's package management so dependencies are tracked:

bash
npm init -y

Add @hitchy/core, @hitchy/plugin-auth and the latter one's dependencies:

bash
npm install @hitchy/core @hitchy/plugin-auth @hitchy/plugin-odem @hitchy/plugin-cookies @hitchy/plugin-session

This plugin maintains a user's authentication in a server-side session controlled by a cookie included with succeeding requests. Users, roles and their authorizations are managed in a connected datasource. Thus, these additional plugins must be installed, too.

Start Hitchy

At this point Hitchy is ready. Thus, start it with:

bash
hitchy start

Hitchy not found?

If Hitchy is not found this might be due to issues with your Node.js and npm setup. In most cases using npx solves this issue for now:

bash
npx hitchy start

Keep it running while trying out next.

TIP

Whenever you want to stop Hitchy press Ctrl+C to gracefully shut it down.

Try It Out

The plugin injects special endpoints for managing a user's authentication by default. You should be able to authenticate with an HTTP request like this:

http
POST /api/auth/login HTTP/1.0
Content-Type: application/x-www-form-urlencoded

username=admin&password=nimda

This works due to the default configuration asking to implicitly set up an administrator account if missing on application start.

Next steps

There are additional guides you might want to check out next: