{"id":47681707,"url":"https://github.com/sbordelais-dev/citizeng","last_synced_at":"2026-04-04T16:22:37.392Z","repository":{"id":44083361,"uuid":"100805155","full_name":"sbordelais-dev/citizeng","owner":"sbordelais-dev","description":"A turnkey user-password framework to create an systematically-authenticated HTTP-server. ","archived":false,"fork":false,"pushed_at":"2022-12-11T02:07:36.000Z","size":6689,"stargazers_count":1,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-19T17:39:30.193Z","etag":null,"topics":["authentication","https-server","passport-local","socket-io","sqlite3"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sbordelais-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-19T16:00:13.000Z","updated_at":"2019-09-14T16:52:02.000Z","dependencies_parsed_at":"2023-01-26T14:01:06.182Z","dependency_job_id":null,"html_url":"https://github.com/sbordelais-dev/citizeng","commit_stats":null,"previous_names":["lordhadder/citizeng"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sbordelais-dev/citizeng","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbordelais-dev%2Fcitizeng","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbordelais-dev%2Fcitizeng/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbordelais-dev%2Fcitizeng/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbordelais-dev%2Fcitizeng/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sbordelais-dev","download_url":"https://codeload.github.com/sbordelais-dev/citizeng/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sbordelais-dev%2Fcitizeng/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31307460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","https-server","passport-local","socket-io","sqlite3"],"created_at":"2026-04-02T14:01:08.565Z","updated_at":"2026-04-02T14:01:40.311Z","avatar_url":"https://github.com/sbordelais-dev.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# citizeng\nA turnkey username-password framework to create a systematically-authenticated HTTP-server. \n## Purpose\nThis project provides a parent HTTP-server class users can derive from to build authenticated Web services. It is supposed to be used on a **small** and **local network**. A particular attention is paid to ensure it can run easily on small devices (more particularly on a [Raspberry pi](https://www.raspberrypi.org/) system).\n## Features\n* Easy to integrate : just concentrate on your server design!\n* Use [Passport](http://passportjs.org/) as an authentication method (*'passport-local'* strategy).\n* Support real-time HTML rendering thanks to [socket.io](https://socket.io/) framework.\n* Simple and lightweight users management using a [sqlite3](https://www.npmjs.com/package/sqlite3) database.\n* Offer basic users management: list, add, remove and password change.\n## Overview\n### What does the framework provide?\nThe framework provides only **tree static routes** : `/login`, `/admin` and `/404`.\n\n* The `/login` route presents a basic username/password login interface. This is where unhauthenticated users will be redirected to. Here the user could connect to the server and/or change its password on the fly.\n\n* The `/admin` route presents a elementary users administration interface. This is where authorized users will be able to interact with the users database.\n\n* The `/404` route provides a fordidden access page when the user try to access an non-authorized service (because it does not exist or because the user does not hav the right to access it).\n\n\u003e Note : Theses **static routes** are said to be **reserved**.\n\nThe framework provides a way to dynamically render services too thanks to the `socket.io` framework. The following routes are used for internal purpose:\n\n* The `connect`, `connection`/`disconnect` routes are use to respectively open/close the `socket.io` connection.\n\n* The `userpresent`, `userlist`, `useradd`, `userdelete` and `userchangepassword` are used to manage users database.\n\n\u003e Note : Theses **dynamic routes** are said to be **reserved**, too.\n\n### Users type\nThis framework considers **tree types of users**, depending on their given access right :\n1. `basic` user : it is the default user. It will access default services. It may not be able to reach user administration service (`/admin` route).\n2. `super` user : it is an administrator user. It can reach `/admin` route.\n3. `master` user : even if is the top-level-ever user type, it remains anecdotic because it is simply a `super` user (declared when inializing the server) that cannot be removed during the session.\n\n\u003e Note: A `basic` user can be removed from the users database by any `super` user. The `master` user cannot be removed from the users database.\n### Password save strategy\nUser's password is never directly saved in the users database. To do so, sha512 is used to hash it before saving:\n```JavaScript\nfunction sha512(userpassword, salt){\n  var hmac = crypto.createHmac('sha512', salt);\n  hmac.update(userpassword);\n  var value = hmac.digest('hex');\n return { salt:salt, hash:value };\n};\n```\n## Installation\n### Default installation\n```Shell\nnpm install citizeng\n```\n### Installation for development\n```Shell\n# Clone the repository.\ngit clone https://github.com/LordHadder/citizeng.git mydir\n\n# Go the cloned repository.\ncd mydir\n\n# Install required modules.\nnpm install express passport passport-local body-parser express-session sqlite3 socket.io nodemailer --save\n\n# Run the demo.\nnode citizeng-demo\n```\n## How to use\n### Default usage\nFirst, you need to load `citizeng` module to retrieve an HTTP-server object:\n```JavaScript\nvar citizeng = require(\"citizeng\");\n```\nThe server object must be initialized first by providing a `port number`, a master `user name` and and the master user `password`.\n\nIn the following sample, the server will be accessible from the URL **http://localhost:3030** by the `master` user **Groot** with password **root**:\n```JavaScript\ncitizeng.init(3030, \"Groot\", \"root\");\n```\nTo access services, just make [express](http://expressjs.com/)-like GET and POST requests. This sample render a specific HTML file depending on if the user is a `basic` or a `super` user:\n```JavaScript\ncitizeng.get  ( \"/\"\n              , path.join(__dirname, \"index.html\")         /* HTML file for basic user */\n              , path.join(__dirname, \"indexsuper.html\"));  /* HTML file for super user */\n```\nDeclaring a static **reserved** route may have no effect. The user will be redirected to the default administration page.\n```JavaScript\ncitizeng.get(\"/admin\", path.join(__dirname, \"index.html\"));\n```\nThe following example shows how to use the `socket.io` layer to render dynamically a service.\n```JavaScript\n/* On client side, Emit a simple message. */\nvar socket = io.connect();\nsocket.emit(\"consolemessage\", \"Bonjour !!\");\n\n/* On server side, receive the message and just print. */\ncitizeng.ioset(\"consolemessage\", function(data, ackfunc) {\n  // Log.\n  console.log(data);\n});\n```\nDeclaring a dynamic **reserved** route may have no effect.\n```JavaScript\ncitizeng.ioset(\"useradd\", function(data, ackfunc) {\n  // Log.\n  console.log(\"This may have not effect!\");\n});\n```\nNow start the server:\n```JavaScript\ncitizeng.run();\n```\n### Support Javascript and CSS references\nYou will need to add the current path during initialization:\n```JavaScript\ncitizeng.init(3030, \"Groot\", \"root\", Groot@mymail.com, __dirname);\n```\nThen, create subfolders named `/js` and `/css` in the current path to respectively put Javacript and CSS files.\n\nFor example, let's consider the custom CSS file **style-demo.css**, a possible way to reference it in HTML is:\n```HTML\n\u003clink rel=\"stylesheet\" type=\"text/css\" href=\"./css/style-demo.css\"/\u003e\n```\n## Next things to do\n- [ ] To make unit test ([mocha](https://mochajs.org/)?)\n- [ ] To support secured protocol (HTTPS)\n- [ ] To offer a way to stylize `/login`, `/admin` and `/404` HTML rendering (generic CSS)\n## License\n[MIT](https://github.com/socketio/socket.io/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbordelais-dev%2Fcitizeng","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsbordelais-dev%2Fcitizeng","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsbordelais-dev%2Fcitizeng/lists"}