HelloThere

17th April 2025 at 5:04pm

TiddlyWiki is Growing Up

MultiWikiServer is a new development that drastically improves TiddlyWiki's capabilities when running as a server under Node.js. It brings TiddlyWiki up to par with common web-based tools like WordPress or MediaWiki by supporting multiple wikis and multiple users at the same time.

Planned features include:

  • Hosting multiple wikis at once, using the Bags and Recipes mechanism for sharing data between them
  • Full support for SQLite, as well as MariaDB/MySQL, Postgres, and Microsoft SQL Server
  • Robust built-in synchronisation handlers for syncing data to the filesystem
  • Flexible authentication and authorisation options
  • Improved handling of file uploads and attachments, allowing gigabyte video files to be uploaded and streamed
  • Instantaneous synchronisation of changes between the server and all connected clients
  • Workflow processing on the server, for example to automatically compress images, or to archive webpages

MWS is currently under development at GitHub but it is already functional and usable.

Installation

17th April 2025 at 4:58pm

These instructions require minimal knowledge of the terminal and require NodeJS to be installed.

  1. Open a terminal window and set the current directory to the folder you want to create the project folder in.
  2. The init command creates the project folder and installs the required dependencies and config files. You can change the name to whatever you like.
    npm init @tiddlywiki/mws@latest "new_folder_name" 
  3. Set the current directory to the project folder that was just created:
    cd "new_folder_name" 
  4. Start MWS:
    npm start
  5. Visit http://localhost:8080 in a browser on the same computer.
  6. When you have finished using MWS, stop the server with ctrl-C

See Troubleshooting if you encounter any errors.

Updating MWS

To update your copy of MWS in the future with newer changes will require re-downloading the code, taking care not to lose any changes you might have made.

  1. Make a backup: Copy or zip your project folder to a safe backup folder.
    tar -cf archive.tar my_folder
  2. Get the latest version. Notice that the second word is install instead of init. This pulls the latest version from NPM and installs it.
    npm install @tiddlywiki/mws@latest
  3. Start the server. On startup, MWS checks the database schema and updates it automatically if there are changes. Normally this works just fine, but it can fail, which is why it's important to save a backup first.
    npm start

Usage

17th April 2025 at 5:05pm

Once MWS is successfully installed, you can access it by visiting http://localhost:8080 in a browser on the same computer.

On first start, a default user is created with username admin and password 1234. However, also by default, the server is only accessible to browsers on the same machine.

If you intend to put an MWS installation on a public network like the Internet, the server will need to be secured with the following steps:

  • Change the administrator password.
  • Install HTTPS server certificates.

Reference

Authentication & Authorization

Overview

Our application has transitioned from a conventional username/password authentication system to a more robust Authentication and Authorization implementation. This new system supports multiple user accounts, roles, permissions, and a comprehensive access control list.

Key Features

  1. Multiple User Accounts
  2. Role-based Access Control
  3. Granular Permissions
  4. Access Control List (ACL)

Application Access & Security

Access Levels

Conceptually, there are 6 access levels.

  • Site owner - has file system access to the server, and can run CLI commands. Presumably they also have a site admin account.
  • Site admin - Users with the admin role. They can assign owners and change permissions, and have full read and write access.
  • Entity owner - Users who "own" an entity (bag or recipe). They can change permissions for that entity, and have full read and write access.
  • Entity admin - Users granted the admin permission on an entity. They cannot change the owner, but they can change the permissions of other users for that entity.
  • Entity write - Users granted the write permission on an enitity. They can list, read, create, update, and delete tiddlers, but cannot change permissions.
  • Entity read - Users granted the read permission on an entity. They can list and read tiddlers, but cannot do anything else.

Initial Setup

When you first launch the Multiwiki Server, it creates a default admin user. The username is admin and the password is 1234. To secure your installation you should change this immediately.

Entities

  • Bag - A collection of tiddlers with unique titles
  • Recipe - A stack of bags in a specific order. Bags may inherit the ACL of a recipe they are included in.

Roles

  • Roles have names and descriptions
  • Multiple users can be assigned to a role

Permissions

  • READ - Read tiddlers from an entity.
  • WRITE - Write tiddlers to an entity.
  • ADMIN - Update ACL for an entity.

ACL

  • Grants the Permission for an Entity to a Role.
  • Entities without an ACL are either public or private (configurable).

Ownership

  • Ownership of an entity grants the "admin" permission.
  • Only site admins can change the owner of an entity.
  • Users with "admin" permission cannot change ownership.

User Types

Administrator (ADMIN) Role

  • Full system access and configuration rights
  • Most access checks are skipped
  • Can create, modify, and delete user accounts
  • Manages role assignments and permissions
  • Has full permissions on all recipes and bags

Regular Users

  • Created by administrators
  • Permissions determined by assigned roles
  • Access limited to specific recipes based on role permissions
  • Access to recipes without an ACL is based on recipe config

Guest Users

  • Users not logged in.
  • No inherent permissions
  • Can access recipes which allow it
  • Read/write can be enabled by server config
  • Useful for public wikis or documentation sites

Access Control

Access Control is implemented separately for both recipes and bags, but bags can in inherit the ACL of recipes they are added to.

Permission Inheritance

  • Users receive combined permissions from all assigned roles
  • When roles grant different permission levels for the same resource, the higher access level is granted. For example, if one role grants "read" and another grants "write" access to a recipe, the user receives "write" access since it includes all lower-level permissions.

If this were reversed, and users with explicit "read" access were forbidden from writing, it would significantly complicate roles.

Imagine a group of engineers working on several projects. Each project has people who are responsible for editing the documentation for everyone else. So everyone needs to be granted the read permission on all projects, but only a few people are granted the write permission on each project.

The easiest approach is to maintain one role which grants "read" access to all users, and then maintain additional roles to grant "write" access to the users responsible for each project.

If granting read access explicitly prevented a user from writing, we would need to create two roles for each project, one which which grants write access for the project, and another which grants read access to all other projects.

Every time a new project is added, all other projects would need to grant "read" access to that new "all projects but one" role on every single wiki for every single project in the entire organization.

User Management & Security Architecture

User Account Management

Users can be administered through two interfaces:

  1. Web-based Administrative Interface
    • Accessible to all users.
    • Provides graphical interface for user operations
    • Real-time validation and feedback
  2. Command-line Interface (CLI) Tools
    • Only available to server owner.
    • Suitable for automation and scripting
    • Enables batch operations
    • Useful for system initialization

Each user account contains the following essential components:

  • Username
    • Must be unique across the system
    • Case-sensitive
    • Used for authentication and audit trails
  • Password
    • Stored using secure hashing algorithms
    • Never stored in plaintext
    • Subject to complexity requirements
  • Email
    • Eventually used for the obvious password reset.
  • Role Assignments
    • Multiple roles can be assigned
    • Inherited permissions from all assigned roles
    • Dynamic permission calculation based on role combination

HTTP API

The MultiWikiServer HTTP API provides management and tiddler endpoints. It was based on the API of TiddlyWeb, first developed in 2008 by Chris Dent, but is more oriented around JSON and Typescript.

The design goals of the API are:

  • Connect the client and server as transparently as possible.
  • Follow the principles of remote procedure calls.
  • Be easy to understand and use via Javascript.
  • Have strict validation of incoming requests.

General points about the design:

  • On the client, most request paths are defined by a single adaptor function which accepts the input for the server and returns a promise which resolves to the server's parsed response.
  • The server may throw a user error, which is expected to return to the client. It should give them an actionable understanding of what went wrong.