aboutsummaryrefslogtreecommitdiffstats
path: root/license-generator
AgeCommit message (Collapse)Author
2018-11-23Move the `bin/` directory into the project rootTeddy Wing
Makes more sense to run `./bin/setup` from the root.
2018-11-23lighttpd.conf: Allow running from the project rootTeddy Wing
* Move the `make run` target into the project root's Makefile * Update paths in lighttpd.conf to correspond to its new location
2018-11-23Move lighttpd.conf to project rootTeddy Wing
I want to be able to run `make run` from the project root.
2018-11-22Add `brew services` commands to thank-you & fulfillment instructionsTeddy Wing
Include the new step 2 of installation, starting the program with `brew services`. After the license has been added, the daemon must be restarted in order for the license to be recognised.
2018-11-21Add license (mostly GNU AGPLv3+)Teddy Wing
License the software with the GNU AGPLv3+ with the exception of the 'aquatic-prime' and 'paddle' libraries and 'aquatic-prime' binary, which are licensed under the GNU GPLv3+.
2018-11-21zip: Update test to pass a mutable reference to the fileTeddy Wing
Forgot to change this when I changed the function signature.
2018-11-21aquatic-prime: Switch to my public fork of `rust-plist`Teddy Wing
Published my local fork publicly with the base64 format change.
2018-11-20license-generator: Use compile-time environment variablesTeddy Wing
For whatever reason, the environment variables in my `.htaccess` weren't getting passed to my FastCGI executables on my production server. Wasn't sure how to get them passed to the programs, so decided instead to compile the env variables into the binaries. To do that, we source the environment file before building the release builds in the Docker container.
2018-11-20create_purchasers: Use a single trigger per actionTeddy Wing
Got this error from the production MySQL server: (details: Error 1235: This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table') Change our triggers so we only have one for `BEFORE INSERT`.
2018-11-20create_purchasers: Remove `DEFAULT UTC_TIMESTAMP()`Teddy Wing
Ended up with this error when running my migrations against the production server: error: migration failed in line 0: BEGIN; CREATE TABLE purchasers ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, secret VARCHAR(255), created_at DATETIME NOT NULL DEFAULT UTC_TIMESTAMP(), updated_at DATETIME NOT NULL DEFAULT UTC_TIMESTAMP() ); CREATE TRIGGER purchasers_updated_at BEFORE UPDATE ON purchasers FOR EACH ROW SET NEW.updated_at = UTC_TIMESTAMP(); COMMIT; (details: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UTC_TIMESTAMP(), updated_at DATETIME NOT NULL DEFAULT UTC_TIMESTAMP() ); CR' at line 6) Using MySQL 5.6.34 in production and MariaDB 10.3.10 locally. Guess you can't use `DEFAULT UTC_TIMESTAMP()` there. To use `UTC_TIMESTAMP()`, create a couple new triggers to set the timestamp in the `created_at` and `updated_at` columns.
2018-11-20Add deployment scriptTeddy Wing
To deploy, run $ make deploy This checks prerequisites and runs `scripts/deploy.sh`. Makefile: Include a new target that builds the Rust binaries for Linux using Docker. The script `rsync`s the website files to the server, moves some files around on the server, and runs the database migrations. Currently I'm getting an error at the database migration stage, as it seems I can't use `UTC_TIMESTAMP()` as a default column value. Need to correct that to get a clean deployment.
2018-11-19Rename `bin/license-generator.rs` to bin/fulfillment.rs`Teddy Wing
Renames the binary. The name "license-generator" no longer seems apt at this point. That binary doesn't actually generate a license, it serves as the webhook endpoint for Paddle's license fulfillment. Our `license` binary handles the actual license generation. The URL I'll be using for the webhook is `/fulfillment`, so this also makes sense from that perspective.
2018-11-19/license: Add install & license instructionsTeddy Wing
Add the instructions we put in the fulfillment email to the thank-you/license download page. Want to make sure buyers know how to license the software after purchasing it. Rephrase the install text to be simpler and more to the point.
2018-11-19license-generator: Add instructions to fulfillment emailTeddy Wing
Include install and license instructions in the purchase fulfillment email.
2018-11-19license-generator: Respond with text for fulfillment emailTeddy Wing
Paddle will take the text from the response of this endpoint and include it in the purchase fulfillment email to a customer. Include the URL for the purchaser to download their license. Use the 'url' crate's parser to build the URL in order to URL-escape special characters. Honestly I'd rather have had a system where the license file gets included in the receipt email. Unfortunately, with the Paddle fulfillment mechanism I'm using, we can only send text. I learned after building the download endpoint that I could manage fulfillment myself. This would require me to listen to an "alert"-type Paddle webhook, and send the email myself (which would include the license file). Since I already built the license download page, I decided to just use it instead of doing the emailing. Also, my web host limits my SMTP usage, so there could be issues there. I'd have to do the emailing in a separate batch process instead of in the webhook handler to ensure that no emails would get dropped.
2018-11-19Add purchase flow thank-you pageTeddy Wing
Move the existing thank-you page to `thank-you-license-download.html`. Use `thank-you.html` as the final page of the purchase flow. Paddle will redirect to this page at the end of purchase. Allows us to retain some branding during purchase. Using the existing HTML file for a better URL.
2018-11-19license: Remove TODOTeddy Wing
Done already.
2018-11-14purchaser: Add timestamp to secretTeddy Wing
Trying to add a little more entropy to the calculation. Went with chrono instead of `std::time` because it gives me an `i64` timestamp instead of a `Result`.
2018-11-14license: Add HTML 500 error responseTeddy Wing
2018-11-14license: Add thank-you page at `/license`Teddy Wing
2018-11-13Add 400 error pageTeddy Wing
HTML copied from the 404 page, but I remove the `text-center` on the error message because it doesn't look good. Took a multiline message for me to realise it.
2018-11-13license: Add "Content-Type" to 404 responseTeddy Wing
The `set_404()` function doesn't do this, as it makes no assumptions about response content type.
2018-11-13license: Get URL path without query string parametersTeddy Wing
The `REQUEST_URI` parameter gives us the URL path including the query string. Unfortunately, there's no param for just the path without the query string. Well, that's not entirely true. On my production server I'll be using Apache, and in development I'm using Lighttpd. Apache provides a `SCRIPT_URL` param that does include just the path, but Lighttpd doesn't appear to have an equivalent. I wasn't able to figure out how to add a `SCRIPT_URL` param in Lighttpd manually, either. Using `bin-environment` in the FastCGI config didn't work, and using `setenv.add-environment` wouldn't allow me to set it to both of our routes (I assume). In light of this, just grab the path from `REQUEST_URI` by getting the part in front of `?`.
2018-11-13logger: Remove query string from log lineTeddy Wing
The query string is already included in the `REQUEST_URI` param. What we had would just print it twice.
2018-11-13license: Render HTML 404 page from /licenseTeddy Wing
2018-11-13lighttpd.conf: Serve static assetsTeddy Wing
Want to be able to use our static image and CSS assets from the FCGI code when rendering HTML.
2018-11-13Makefile: Restart `lighttpd` when both binaries changeTeddy Wing
2018-11-13license: Extract response logic from `/license/download`Teddy Wing
I want to be able to use the exact same logic for the `/license` route. To do so, we move the common logic to a new `build_response()` function. For all responses we need to return from `build_response()`, make new structs `HtmlResponse` and `ZipResponse` that write the response in the desired format. The `ZipResponse` does what we're already doing in `/license/download`. The `HtmlResponse` will respond with HTML and show a thank-you page on success.
2018-11-13logger: Use `REQUEST_URI` instead of `SCRIPT_NAME`Teddy Wing
The script name isn't necessarily the same as the request path. We really want the request path.
2018-11-13license: Respond 404 if purchaser not foundTeddy Wing
2018-11-13license: Send 400 Bad Request if requested with incorrect parametersTeddy Wing
2018-11-13license: Clean up commentsTeddy Wing
2018-11-13license: Remove `unwrap`sTeddy Wing
Respond with a 500 on error. Add 'aquatic-prime' to `foreign_links` errors to be able to convert it with `into()`.
2018-11-13database: Reduce connection pool sizeTeddy Wing
Read https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing recently, and reducing the pool size seemed like a good idea.
2018-11-13license: Combine zip response writersTeddy Wing
2018-11-13license: Move database query to a functionTeddy Wing
Will make it a bit easier to handle errors from `Result`s.
2018-11-13license: Refuse non-POST requestsTeddy Wing
2018-11-13licene: Set filename of license Zip fileTeddy Wing
2018-11-13license: Replace `include_bytes!` with `include_str!` for keysTeddy Wing
Forgot that `include_str!` existed. Certainly makes things a lot cleaner this way.
2018-11-13license: Generate a license and send it in HTTP responseTeddy Wing
If the purchaser coming from POST params is found in the database, generate a license for the purchaser, zip the license, and send a response containing the zipped data. zip: Change the writer input to a mutable reference to enable us to use the zip data when writing to the response. Otherwise we get a borrow error.
2018-11-13license: Get purchaser from database using paramsTeddy Wing
Use POST params `name`, `email`, and `secret` to get a purchaser from the database. If none exists, we should probably send a 404, otherwise we'll generate a license for that purchaser and send it in the response as a Zip archive.
2018-11-13lighttpd.conf: Use `license` binary for `/license/download` routeTeddy Wing
2018-11-12Add src/bin/license.rsTeddy Wing
This binary will show a thank-you page to purchasers. I had also planned to make a third binary to send the license file as a Zip archive, but now I think I'm going to do that here too, working out the routing inside this program.
2018-11-12lighttpd.conf: Add routes for additional license handlersTeddy Wing
We want another route for a thank-you page, and a third for a Zip download of the license.
2018-11-11main(): Move logging code into its own moduleTeddy Wing
This will enable us to use the logging code in other binaries.
2018-11-11Add `zip::license()` to make a Zip archive of a license plistTeddy Wing
2018-11-11aquatic-prime.rs: Add a "usage" messageTeddy Wing
2018-11-11Add `src/bin/aquatic-prime.rs`Teddy Wing
Binary to generate a license plist.
2018-11-11aquatic-prime: Make things publicTeddy Wing
So we can use them from outside the crate.
2018-11-11Rename `src/bin/license_generator.rs` to `src/bin/license-generator.rs`Teddy Wing
Want a `license-generator` binary with a hyphen. Normally I'd name my Rust files with underscores, but I didn't want to add `[[bin]]` sections to `Cargo.toml`.