Public Access
Let a team be joined only by somebody who is already here
An invitation decided access from an assertion about an address. Everything else
in this model decides it from something a person did — an admin naming an
account, a key holder wrapping a vault key to a key they verified — and this was
the one place a token's email claim was the thing that let somebody in.
It was guarded as tightly as that can be guarded: the claim was refused outright
on an unverified or absent `email_verified`, with no setting to relax it. But the
guard and the risk were the same shape. The whole defence was one boolean sent by
a system the deployment does not control.
So `POST /teams/{id}/members` is the only way in, and an address with no account
is refused with `no-such-account` — which is now the end of the road rather than
the signal to invite. Both clients say the remedy: that person signs in here
once, which is what creates the account, and then they can be added. The desktop
leaves the address in the box, because a message telling you to come back later
is one you act on later.
Gone with it: the `team_invitation` table, the claim hook in the sign-in path,
and `Oidc:EmailVerifiedClaim`, which that hook was the only reader of. Nothing in
the server now reads the email claim to decide anything.
Pending invitations are dropped rather than converted. Converting one would mean
creating a membership because an address matched, which is the property being
removed — and an invitation to an address that did have an account here had
already been claimed by the hourly sweep, so what is left is offers to people who
never arrived.
Two tests carry the property rather than the feature: the endpoint inventory
asserts the three routes are absent, and the API suite adds an address that has
no account, watches the refusal, then signs that address in and checks it joined
nothing. Without the second half, a server that merely renamed the deferred path
would pass.
This commit is contained in:
1 parent
7dc3b8950d
commit
69bc9e270b
39 files changed
+2258
-2275
No files matched your search
@@ -62,47 +62,6 @@ public sealed class TeamMembershipConfiguration : IEntityTypeConfiguration<TeamM
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Maps <see cref="TeamInvitation"/>.</summary>
|
||||
public sealed class TeamInvitationConfiguration : IEntityTypeConfiguration<TeamInvitation>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void Configure(EntityTypeBuilder<TeamInvitation> builder)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(builder);
|
||||
|
||||
builder.ToTable("team_invitation");
|
||||
builder.HasKey(i => i.Id);
|
||||
builder.Property(i => i.Id).ValueGeneratedNever();
|
||||
builder.UseXminConcurrencyToken();
|
||||
|
||||
// citext, matching user_account.email: the claim at sign-in compares an address the identity
|
||||
// provider chose the casing of against one a person typed, and lower() on both sides of that
|
||||
// is a rule somebody eventually forgets on one side.
|
||||
builder.Property(i => i.Email).HasColumnType("citext").HasMaxLength(320).IsRequired();
|
||||
builder.Property(i => i.Role).HasConversion<int>();
|
||||
|
||||
builder.HasOne(i => i.Team)
|
||||
.WithMany(t => t.Invitations)
|
||||
.HasForeignKey(i => i.TeamId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
// One live invitation per address per team. Filtered on the two tombstones rather than on a
|
||||
// deletion marker, as vault_key_grant is: an accepted or withdrawn invitation is kept, and
|
||||
// re-inviting an address whose invitation lapsed has to be possible.
|
||||
//
|
||||
// Expiry is deliberately not in this predicate. A partial index predicate must be IMMUTABLE,
|
||||
// so now() cannot appear in one; an expired invitation therefore still holds the slot, and
|
||||
// the service treats replacing one as a revoke-and-reissue rather than a second insert.
|
||||
builder.HasIndex(i => new { i.TeamId, i.Email })
|
||||
.IsUnique()
|
||||
.HasFilter("accepted_at_utc IS NULL AND revoked_at_utc IS NULL");
|
||||
|
||||
// The claim at sign-in knows the address and nothing else — it is looking for every team that
|
||||
// invited this person, across all of them — so the address is the hot direction here.
|
||||
builder.HasIndex(i => i.Email);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Maps <see cref="Vault"/>.</summary>
|
||||
public sealed class VaultConfiguration : IEntityTypeConfiguration<Vault>
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user