Notes about generic-sessions Plugin =================================== @section gseb Enabling lwsgs for build Enable at CMake with -DLWS_WITH_GENERIC_SESSIONS=1 This also needs sqlite3 (libsqlite3-dev or similar package) @section gsi lwsgs Introduction The generic-sessions protocol plugin provides cookie-based login authentication for lws web and ws connections. The plugin handles everything about generic account registration, email verification, lost password, account deletion, and other generic account management. Other code, in another eg, ws protocol handler, only needs very high-level state information from generic-sessions, ie, which user the client is authenticated as. Everything underneath is managed in generic-sessions. - random 20-byte session id managed in a cookie - all information related to the session held at the server, nothing managed clientside - sqlite3 used at the server to manage active sessions and users - defaults to creating anonymous sessions with no user associated - admin account (with user-selectable username) is defined in config with a SHA-1 of the password; rest of the accounts are in sqlite3 - user account passwords stored as salted SHA-1 with additional confounder only stored in the JSON config, not the database - login, logout, register account + email verification built-in with examples - in a mount, some file suffixes (ie, .js) can be associated with a protocol for the purposes of rewriting symbolnames. These are read-only copies of logged-in server state. - When your page fetches .js or other rewritten files from that mount, "$lwsgs_user" and so on are rewritten on the fly using chunked transfer encoding - Eliminates server-side scripting with a few rewritten symbols and javascript on client side - 32-bit bitfield for authentication sectoring, mounts can provide a mask on the loggin-in session's associated server-side bitfield that must be set for access. - No code (just config) required for, eg, private URL namespace that requires login to access. @section gsin Lwsgs Integration to HTML Only three steps are needed to integrate lwsgs in your HTML. 1) lwsgs HTML UI is bundled with the javascript it uses in `lwsgs.js`, so import that script file in your head section 2) define an empty div of id "lwsgs" somewhere 3) Call lwsgs_initial() in your page That's it. An example is below ```
![]() |