Delegation for the day the account holder dies
DEV Community

Delegation for the day the account holder dies

Years ago I built an authentication system with a feature in it that I hoped most of its users would never need. It let you hand someone else access to your account, properly, as themselves. And one of the reasons it existed was the day you died.

I'd half forgotten it until recently, when I sat down to design sign-in for Scout's portal and went digging to see whether the old code was still around.

The spare key

It was a JWT system with revocation and delegation, written in Scala at Wakelet, a good few years ago now. The revocation part was what you'd expect: tokens recorded as well as signed, so one could be killed before it expired.

The delegation part was what I'd come back for, and we'd needed it for three reasons:

  • an account holder letting support staff act on their encrypted data, with their permission, to sort a problem out
  • a family member being able to get in after the account holder had passed away
  • corporate access passing from one person to another inside a team, to cover absences

Each of those is a spare key left with a neighbour. What you hand the neighbour is a key and a reason, and you'd quite like the lock to know it was them and not you.

Being you, or acting for you

That last bit is the design in a nutshell, and it's an easy one to get wrong. There are two ways to let someone into an account that isn't theirs. One is impersonation: they log in and, as far as the system can tell, they are you. The other is delegation: they stay themselves, and the system records that they're acting on your behalf.

The OAuth people eventually wrote this down in RFC 8693, the token exchange spec, and the distinction is that one. With delegation, the acting party "still has its own identity separate from" the one they're acting for, and "any actions taken are being taken by A representing B". It even gives the acting party a claim of its own in the token, act.

My old system did it the delegation way, with an extra claim naming the person the token had been issued to alongside the owner it was for, plus an optional date before which it wasn't valid and one after which it expired. A normal sign-in was the case where owner and assignee were the same person.

That was a couple of years before the RFC existed, which I only mention because it suggests the shape falls out of the problem on its own once you take it seriously (so no prizes for cleverness here).

And the reason it matters is the support case and the bereavement case. If the support engineer is indistinguishable from you, then your account's history says you did whatever they did. If a grieving family member is indistinguishable from the person who died, the record of the last things that account ever did is now a lie.

Not for the alpha, but not for later either

Scout's alpha doesn't need any of this. Sign-in is Discord only for now, built so other ways in can be added later. Delegation isn't on the list either... I wanted the mechanism kept, but I was clear when I wrote the alpha's scope that it wasn't a requirement. What I didn't want was for the alpha to make it hard.

And that's where the old design came in handy, since the cheapest time to leave room for delegation is before there's a single token in the world. So Scout's sessions are opaque tokens pointing at a session stored on the server, which can be ended at any time (ending one stamps it instead of deleting it, so there's a record).

And the session table has two columns where you might expect one: the account the session is for, and the account actually doing the acting. Today those are always the same, sign-in writes them equal, and a test asserts it. The migration that created the table says what the second column is for, and that a delegated session is one where the two differ, which "needs no change of shape". So that's the whole cost, one column that's always equal... for now.

The big platforms, eventually

It's not as if this is an exotic need. Apple added a Legacy Contact to its accounts, someone you nominate in advance who can request access to much of your data after your death, with the access key you gave them and a death certificate. Google has its Inactive Account Manager, which shares chosen parts of your account with people you've picked once you've been inactive for long enough.

Both of them only work if the account holder set them up beforehand, which is the point. As far as I can see, neither can be retrofitted on the day, by the person who needs it, for the person who can no longer ask. They exist because those companies decided the system had to know about the neighbour before the neighbour turned up at the door.

The day it's needed

The timing is what gets me. The day you need delegation is, almost by definition, a bad day. Someone's ill, or on leave, or locked out with a support ticket open, or gone. It's the last day anyone wants to be told the auth model can't express what's happening, and that the fix is a migration of every session the product has ever issued.

Leaving a column for it on day one cost next to nothing, and I'll be quite happy if Scout never needs it. The spare key's cut all the same, and the lock already knows the difference between me and whoever I hand it to.

Originally published at phpboyscout.uk on 26 November 2026.

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.