-
Notifications
You must be signed in to change notification settings - Fork 75
Description
This issue will serve as the parent issue for adding user plugins to politeiawww. This work was funded by the Pi 2021 Q3 proposal.
Proposal Text
Politeia is split into two layers: politeiad and politeiawww.
politeiad is the data layer. It accepts and stores records. A record is an arbitrary set of files. A record can be a proposal, a CMS invoice, a forum post, or any other set of files.
politeiawww is the user layer. All user data is saved to a database in this layer. This includes data such as login credentials, user sessions, notification preferences, and any other type of data for user accounts.
The recent Politeia v1.0.0 release adds a composable plugin architecture to politeiad. A politeiad plugin extends a record with additional functionality like adding comments to a record or voting on a record using dcr tickets.
This same plugin architecture now needs to be added to the user layer in politeiawww. A user plugin will extend a user with additional functionality. Examples include adding a DCR paywall for specific user read/write actions or compiling github statistics for a user that is submitting a CMS invoice. This is going to be the largest chunk of work for this proposal since it includes refactoring the 25% of the codebase that the v1.0.0 release did not cover.
Listed below are the user layer deliverables:
-
Add a composable plugin architecture to the user layer. This will require re-writing the user database implementation in a manner that supports composable user plugins.
-
Add a user API that is designed for plugins. The user API will need to be re-written to accommodate the plugin model and the new database implementation. The existing user API will be deprecated.
-
Add a DCR payments plugin. The proposal system currently has a feature that requires users pay a registration fee in DCR before they can submit data and a feature that requires they pay a fee in DCR to submit proposals. This functionality will be abstracted into a generic plugin that allows the server operator to configure one-time and recurring paywalls for server operator defined read/write operations, payable in DCR.
-
Remove scaling impediments. There are a few memory caches in politeiawww for user data that are preventing politeiawww from being scaled out. Since we are re-architecting the user layer, we can use this opportunity to remove all impediments to scaling politeiawww and running multiple politeiawww instances.
-
Make email optional. A site that wants to allow anonymity should not require the use of email. Since we are re-architecting the user layer, we can use this opportunity to make email optional. A user will have the option of authenticating using their identity (key pair that is specific to the user) and a TOTP.
Implementation
1. Add a base user data model and API routes.
- The base user will contain the fields and functionality that all users will share. This will be very limited.
- Additional user functionality will be layered on via plugins.
- The login method should be able to be replaced by a custom plugin login method.
2. Add the plugin model.
- Ability to extend a user with additional functionality via plugin commands.
- Ability to save data clear text or encrypted. Clear text data should be queryable via SQL.
- Ability to add user permissions onto the record routes and record plugin commands.
- Ability to hook into record and record plugin routes.
3. Add user plugins.
- auth - provides various user authentication methods.
- identity - provides user key creation, storage, and signature validation.
- ntfns - provides user notifications.
- dcrpay - provides dcr payment functionality.
4. Add a user database CLI tool.
The new user layer will require a CLI tool for interacting with the user database. The tool will need to allow for plugin specific commands.
This is a good opportunity to start experimenting with golang plugins since the scope of a CLI tool is small, allowing us to experiment in a rapid, low risk manner.
Golang plugins
One of the long term goals for Politeia is to use a plugin architecture that allows the plugin code to be hosted outside of the Politeia repo. This will let third-party developers use Politeia as a general purpose platform that can be built on top of. Golang plugins may allow us to accomplish this. Hashicorp's go-plugin could also be a potential solution.