Your leaking thatched hut during the restoration of a pre-Enlightenment state.

 

Hello, my name is Judas Gutenberg and this is my blaag (pronounced as you would the vomit noise "hyroop-bleuach").



links

decay & ruin
Biosphere II
Chernobyl
dead malls
Detroit
Irving housing

got that wrong
Paleofuture.com

appropriate tech
Arduino μcontrollers
Backwoods Home
Fractal antenna

fun social media stuff


Like asecular.com
(nobody does!)

Like my brownhouse:
   tenantification
Wednesday, July 24 2024
I come to my software problems from the world of multi-user web applications, so I tend to solve them with databases that have a user table and a web frontends featuring a login mechanism. There are a lot of cloud-based solutions that can work this way, with every user having access to mostly their own data (and perhaps, through narrow apertures, the data of others). This is how my Network Spelling Bee works, for example. All the users have their own individual game state for every day's game, though there is also a mechanism for logged-in users to see others' scores and another that even allows the sending of messages between users. Some applications, such as the text analysis software I wrote for my former boss Alex (who has been AWOL for months, by the way), doesn't permit any communication between users' data, though everyone starts with a common copy of data (such as a word dictionary) that they can customize without affecting similar data being used by others.
My ESP8266 Remote Control system started out with a similar model, one where every users' data was walled off from every others. There was also a role that allowed some users to add other users and create and run reports (which gives them access to all the data in the database server). Such a system works fine when the goal is to give other users access to a common backend where they can have their own walled-off complexes of data. But it only permits a one-to-one relationship between users and such data complexes. This means that if, say, I want to give Gretchen access to the ESP8266 Remote website so she can check temperatures or remotely control devices, I have to give her my personal login, which would then give her superuser access to the entire database server (since that is what the "super" role confers upon me). What I really would've preferred would've been a tenant-based permissions system, where each tenant can have multiple users, each with potentially different specified roles. Users belonging to one tenant could then access only that tenant's data, though in such systems there is often a many-to-many relationship between tenants and users, meaning I can belong to several different tenants, and those tenants can have many users. I was unfamiliar with tenant-based permission models before working at SCA-Corp.com, the municipality-targeted software firm over in Redhook. But they definitely needed such a system, since each municipality (the "tenant" in this case) has different users with different access requirements. And some of those users (particularly admins working for SCA itself) needed access to all the municipalities. Mind you, SCA's software was not especially well written, but the tenant-based permissions model did what was needed (though often tenants were isolated from each other by having their own separate SQL Server database).
I'd been nervous about migrating to a tenant-based model, since it would likely disrupt numerous systems and lead to bugs I wouldn't be able to uncover without lots of testing. But today I finally pulled the trigger on it. I started by asking ChatGPT to write me a MySQL script to rename all the user_id columns in all the database tables to tenant_id. I then made a copy of the user table (since I would still need one of those). Next I created a new mapping table called tenant_user, which I populated with my user linked to the one tenant I cared about (which had been a user before I renamed the old 'user' table "tenant'). I also did a search and replace of all the PHP and Javascript code to replace every instance of "user_id" with "tenant_id" and every instance of "userId" with "tenantId." (This is because I name database entities with underscore_convention and code variables with the camelCase convention.) I then ran all this SQL on the server and copied over the modified code. The site immediately broke, of course, but with a little tweaking (changing some "user" references to a "tenant" instead and copying some of the tenant properties to the user object). It didn't take much effort to get the user-based login system working again in a way that passed tenant_id to the relevant functions so as wall off all the device data so that only users beloging to my tenant could access it. There were a few other glitches along the way, such as some anti-hacker code that automatically added "AND tenant_id={the logged-in user}" to certain SQL queries. (I had to make it not do that on the tenant table, which does not have a user_id.)
Once I had all that working reliably, it wasn't much work to add tenant-management code to the user editor, since I could leverage an existing many-to-many editing functionality that I'd build for management_rules that was so generic that it could work for any many-to-many relationship. By this evening, I'd created new test users that could access most of the web-based tools while being prevented from running reports or adding users. I'd taken 150 mg of pseudoephedrine, which definitely helped me maintain the focus necessary to get all of this done.

Earlier this afternoon, I taken the dogs for a drive out to Adams Fairacre Farms, where I bought rice, spaghetti, cherries, cremini mushrooms, pizza sauce, and pizza dough. Then, after taking Charlotte for another walk up the Chamomile Headwaters Trail (and gathering a fair amount of chanterelles), I proceeded to make a nice big pizza for dinner. While walking with Charlotte, I'd left the bag of pizza dough floating in water, so it was nice and fluffy when it came time to spread it out on a pizza pan. Somehow my timing was perfect and Gretchen arrived home just as I was pulling the pizza out of the oven! Gretchen seemed to think this was one of my best pizzas yet; she particularly liked the tiny cubes of pan-seared extra-firm Trader Joes tofu I'd used as a topping.

I ended up staying up very late under the combined effects of pseudoephedrine and diphenhydramine, a combination that has had this effect in the past. It's such a good buzz that I'm finding it a healthy alternative to drinking alcohol.

For the past couple days I've had another symptom encroaching decrepitude: a swollen left calf. I'd first noticed it early in the week when I got down in a crouched position and the calf came into contact with my lower thigh, where I felt a slight pain. It hasn't caused me any pain when I've been moving, but by this evening it was feeling swollen, like it was pressing against the limited envelope of leg skin like an overstuffed sausage. I'm not sure what the problem is, because I don't remember any injuries to that leg. And the most strenuous physical activity in the past week was wrestling that 100 pound Lincoln Electric stick welder from the ruins of Bob's Body Shp to my Forester at Creekside.


For linking purposes this article's URL is:
http://asecular.com/blog.php?240724

feedback
previous | next