Table of Contents

Interface IGrantDataProtector

Namespace
Fdyay.IdentityServer.Services
Assembly
Fdyay.IdentityServer.Core.dll

Protects and unprotects the Data a persisted grant carries.

public interface IGrantDataProtector

Remarks

What that column holds is the reason this exists. A persisted grant's Data is the serialized thing itself — for a refresh token or an authorization code, that is the whole claim set the subject was issued, every claim a profile service added included. Four stores wrote it as plaintext JSON, so the grant table held, in the clear, the full identity of everybody with a live session.

The tree already had the pattern and applied it to one of two things in the same database. DataProtectionKeyProtector has data-protected the signing keys since key management shipped, with a flag on the row so a store written before the change still reads. Grants got none of it. Note 11 at storage scale: the rule was applied to the half whose row had somewhere to put a flag.

Reading never consults the option, and that asymmetry is the migration. DataProtectData governs writes only; a read always tries to unprotect and falls back to treating the value as plaintext. So turning protection on does not strand the rows already there, and turning it off does not strand the rows written while it was on. A protected payload and a JSON document are not mistakable for one another — data protection's own format check refuses the second — so the fallback discriminates on a real answer rather than on a guess.

Methods

Protect(string)

Protects data for storage, or returns it unchanged when switched off.

string Protect(string data)

Parameters

data string

Returns

string

Unprotect(string)

Returns the original value, whether the stored one was protected or not.

string Unprotect(string data)

Parameters

data string

Returns

string