Self-Firejailing Web Framework
Tags: nim, webframework, firejail, 2factorauth
Published: 2019-04-25 03:04:30

---
title: Self-Firejailing Web Framework
published: true
description: New Self-Firejailing 2 Factor Auth Web Framework with Plugin Store
tags: Nim, Web Framework, Firejail, 2 Factor Auth
---


![](https://raw.githubusercontent.com/ThomasTJdev/nim_websitecreator/master/docs/nimwc_design.jpg "Nim Website Creator Dashboard")


![](https://raw.githubusercontent.com/ThomasTJdev/nim_websitecreator/master/docs/nimwc-editor-summer.png)


# The Nonconformism

Once upon a time a bored Developer was looking for new cool Web Frameworks,
and the adventure begins...

Not far from the starting point some very *Trendy* frameworks appear on the horizon, 
their homepage have super state-of-the-art CSS and a lot of Sponsor companies,
then to evaluate the list of Features I turn to its official Documentation,
very surprised I found most of them (if not all) tend to use basic plain text Auth,
saying that you must use that or implement your own, and is up to you.
Similar story with any means of security too, none of the Features was too deep, 
the addition of new parts was kinda Glue-Code it up,
because Trendy framework moves too fast they do not have time for that.

...I was wondering, *so they wasted all the Sponsors money on CSS and Marketing?*

Sometimes you just have to make a pause, drink some [Mate](https://en.wikipedia.org/wiki/Mate_(drink)) or coffee,
take some distance and look at the landscape from far, and think.

We are in 2019, I think it should be possible to do it different, 
even if is not so Hipster and Trendy, and we got no sponsors.

I do not care too much how fast you say your language move if its a kaleidoscope of tiny pieces by different magicians.

Ones say single-threading is the future, others say a global-lock is the future,
we think you should be able to squeeze all the hardware you payed for,
even more nowadays with 32 CPU Cores, Raspberry Pi will have 8 Cores,
if its a rented *Cloud* you are literally paying for CPU and RAM usage too.



# The Jester and the Beast

![](https://raw.githubusercontent.com/ThomasTJdev/nim_websitecreator/master/docs/nim-bad-cat.png "Nim Programming Language")

Back to GitHub, we have the best tools for the job, the [Nim programming language](https://nim-lang.org).

1 language for the whole stack, Backend & Frontend,
including [high performance modules](https://github.com/sashkavalent/benchmark_languages_fib/blob/master/README.md), [scripting, devops, deploy](https://nim-lang.org/docs/nims.html).
From WebAssembly to [Assembly](https://github.com/juancarlospaco/nim-presentation-slides/blob/master/ejemplos/avanzado/assembly/asm_example.nim). [Python modules](https://github.com/yglukhov/nimpy#nimpy-) and [JavaScript](https://nim-lang.org/docs/backends.html#backends-the-javascript-target).

From a humble blank text file the new web framework was born, 
Nim Website Creator its name, [inspired by previous experiences](https://tonsky.me/blog/disenchantment/), but copying none.

Building the new framework, brick by brick, on top of [Jester](https://github.com/dom96/jester) and the [Beast](https://github.com/dom96/httpbeast), 
for Authentication we use 2 Factor Authentication (TOTP), available from [Nimble](http://nimble.directory),
the 2FA is enabled by default, so you can use it right away, because we are on 2019.

ReCaptcha built-in (optional), BCrypt+Salt passwords, Postgres or SQLite,
JavaScript framework agnostic, Auto-Rotating file Logger, Server Status Page.
Edit main config file (INI format) directly from browser for Admins.

We made a "DevOps" folder on the repo with useful resources.



# The Dance of Nim and Fire

![](https://raw.githubusercontent.com/ThomasTJdev/nim_websitecreator/master/docs/nimwc-firejail0.png "Self-Firejailing Web Framework")

Looking to improve the security we went trekking on the land of the Linux kernel,
we hunt down a really nice tool named [Firejail](https://firejail.wordpress.com) (Pure C, no dependencies), 
then wrap it on a library, uploaded to Nimble, to integrate it on the core, 
finally **the framework Firejails itself**.

This allows the Admin of the site to control the security, 
isolating software to the very bare minimum that it should "see" of the server to run, 
it can run with no-root, no-Shell, no file system visible, 
and also it comes with hardware level isolation and control, 
the Admin can control how much CPU & RAM & Cores the framework can use,
other smaller features like auto-restart, high availability, Net isolation, etc.

Firejail is 100% Optional, you can compile NimWC without the Firejail integration.



# Selfie

![](https://user-images.githubusercontent.com/1189414/53709326-72ef5180-3e16-11e9-944e-8120d6ab2959.png "Libravatar/Gravatar Integration")

[Libravatar](https://libravatar.org) is an Open Source alternative to [Gravatar](https://gravatar.com), that also supports Gravatar,
support is built-in and ready to be used by Plugin developers to display avatars.

Also a local custom uploaded image file can be used too.
Private and public files and images uploads and downloads with counter is built-in.

[WebP](https://caniuse.com/#feat=webp) automatic image and photo optimizations.

WebP is optional, you can compile without the WebP feature.



# The Silk Road

![](https://raw.githubusercontent.com/ThomasTJdev/nimwc_plugins/master/nimwc-plugin-store.jpg "NimWC Plugin Store")

The framework comes with a graphical Plugin Store integrated, 
so you can add your own custom features and functionalities,
directly from the browser from a friendly UI. A feature, a click.

Each Plugin has name, MarkDown/RST description, version, author, license, tags,
buttons to install/uninstall, update, talk to the developer, even the authors photo.
You can have Plugins installed but Disabled too.

The store works backed by Git, so you can use your GitHub or GitLab, Free or Pro.

We would love to make Open Source Self-Sustainable (will you help us?), 
so theres a field were you can put your Bitcoin or Patreon or LiberaPay address,
and it will be rendered on the Plugin Store as a button, 
so users can Subscribe to you if they love your Plugin!.

[Upload your Plugin to the Store today!](https://github.com/ThomasTJdev/nimwc_plugins#plugins-for-nim-website-creator-nimwc).



# Army of Skeletons

NimWC has a Skeleton creator built-in,
the Plugin Skeleton creator makes a new plugin (empty) for you, 
some basic plugin information is written to a JSON file 
(to generate a pretty UI on the Store for your Plugin), 
and some files and folders are created (HTML, CSS, JS, Nim, etc),
the files will have useful comments with help, docs and links,
its like a project template or cookiecutter on other languages.

Making a plugin is coding vanilla HTML,
[CSS with Bulma](https://bulma.io) or [Bootstrap](https://getbootstrap.com) or manual,
JS with [Nim](https://nim-lang.org/docs/backends.html#backends-the-javascript-target) or other language,
Templating with Nims standard library [templating engine](https://nim-lang.org/docs/filters.html),
you can use [Karax](https://github.com/pragmagic/karax) or React or other language,
you can even use Nim's [Web Assembly](https://github.com/2vg/nim-wasm-example).

You can check the documentation for Plugins and peek at the existing [Plugin code](https://github.com/ThomasTJdev/nimwc_plugins#available-plugins).

Create your Skeleton and code your ideas into features.



# Hello World

- So... How to make a web *Hello World*?.

```nim
routes:
  get "/":
    resp "Hello World"
```

*Yes, that is actual valid Nim lang code*  :)

Nim compiles to tiny single-file dependency-free optimized native binary executable.

[A more complete example.](https://github.com/juancarlospaco/nim-presentation-slides/blob/master/ejemplos/basico/jester/hello_web_3.nim#L38)



# Video or didnt happen

{% youtube 3R1l4Ha0tDI %}



# Live Demo

There's an official [public free access instance running](https://nimwc.org/login) to showcase the framework.

We added a limited Demo mode, optional via compile-time flag.



# Presentation

[Nim Website Creator Presentation Slides](http://htmlpreview.github.io/?https://raw.githubusercontent.com/ThomasTJdev/nim_websitecreator/master/docs/nimwc-presentation-presentation.html)



# Futurology

Most of the issues are feature plannings or related. This is just a peek into NimWC.

Some incoming stuff is Material Design, better UI/UX, more Docs and Plugins!.



# Community

![](https://raw.githubusercontent.com/ThomasTJdev/nim_websitecreator/master/docs/gatas.jpg "Nim community")

There's bridged [Gitter](https://gitter.im/nim-lang/Nim), [Matrix](https://matrix.to/#/#freenode_#nim:matrix.org), [Telegram](https://t.me/nim_lang), [IRC](irc://freenode.net/nim), [Discord](https://discord.gg/ezDFDw2) for Nim, come say *Hi*.

[Learn Nim today.](https://nim-lang.org/learn.html)
[NimWC on Nimble.](https://nimble.directory/pkg/nimwc)
[NimWC on GitHub.](https://github.com/ThomasTJdev/nim_websitecreator#features)
[Python Modules on PyPI](https://pypi.org/project/faster_than_csv/) [written 100% on Nim.](https://pypi.org/project/faster_than_walk/)
[Nim Sticker Pack.](https://t.me/addstickers/nimlang)
[Grupo de Telegram en Español.](https://t.me/NimArgentina)

We don't have Crabs, we don't have squinting Rats, we have a friendly community,
we have the Performance of C with Python-like syntax, come to the Nim side...
👑