Public Access
Make the vault the thing you share, and ask a host which one it lives in
The teams screen listed teams that owned vaults, so sharing four servers with two
colleagues meant creating a team, then a vault inside it, then wrapping a key.
Two of those three steps are about a concept nobody arrives wanting. The screen
now lists vaults: naming one creates the membership list that carries it, named
after the vault and owned by you, and members, invitations, roles, hand-over and
key holders all hang off the vault they apply to.
Nothing on the server moved. VaultAccessService still resolves a shared vault
through team_membership and every membership call still names a team id — what
went is the requirement that anybody make one. The split the whole design rests
on is untouched and is still what the screen is built around: adding somebody
authorises the server to serve them, and only a machine holding the key can make
the vault readable. ADR 0009 keeps its decision and gains an addendum recording
which half of it a person is now asked about.
The one place the team resurfaces is a membership list carrying several vaults,
which this screen cannot produce and does not hide: the members section says so,
because "adding somebody here adds them there" is precisely the fact a
vault-shaped screen is in a position to conceal.
Two things left the interface and one arrived. Creating a team is gone, and so is
archiving one — it was only ever possible for a team owning no vaults, and a
screen whose rows are vaults has no row for one, so the button would have been
unreachable or always refused. The endpoint is unchanged and the screen states
the limit instead, since a vault cannot be deleted at all. The exception is a
create whose second call failed: cancelling that form archives the membership
list it left behind, which is a deliberate departure from this client's rule
against tidying up on the user's behalf, made because nothing else can reach it.
What arrived is PUT /api/v1/vaults/{id}. Without it the screen loses its only
editing action, since renaming the team behind a vault is invisible to everybody
who was never shown the team. It is gated on PermissionFlags.Admin — the line
UpdateTeamEndpoint already draws, because a name is what everybody in the vault
sees it called rather than part of its contents — and it renames the owning team
with it when that team carries nothing else, so the row an operator reads and the
name a user says cannot drift apart. The slug never moves, for the reason it does
not move on a team rename. The session edits its cached vault row rather than
replacing it with the response, which deliberately carries no wrapped key.
The host editor now asks which vault a host goes into, beside the name, while
adding and only where there is more than one vault to write to. It is a second
picker rather than the keychain screen's reused, and the two selections are
separate on purpose: that one is a standing preference about where new items go,
this is a field of the host in front of you, and binding both to one selection
would mean a click on the other screen could move a half-typed host. An existing
host is not offered it at all rather than offered it disabled — the two vaults
are encrypted under different keys, so moving an item is a delete and a retype.
That forced a fix worth naming. The group picker was built from the active
vault's groups whatever vault the host was being filed into, so a host put in a
shared vault could be filed under a group only its author can resolve — a
colleague would see it filed under nothing, which is the quietest kind of wrong.
Groups are now kept per vault and the picker follows the vault choice.
Two renames, because the pair they would otherwise have made is a bug farm:
ShellScreen.Vault became Keychain and VaultScreen became KeychainScreen, which is
what the rail has always labelled that screen, leaving Vault for one vault's
contents and Vaults for the vaults themselves. The enum values are unchanged;
NavRail.axaml writes them as x:Static literals.
1536 tests pass, seven more than before. Five are new on the server — the rename
endpoint's success, the team it does and does not take with it, the two refusals
and the empty name — and the client suite gains six and folds four together,
having lost the two about archiving a team.
This commit is contained in:
@@ -252,6 +252,134 @@ public sealed class TeamEndpointTests(ApiFixture fixture)
|
||||
.Role.ShouldBe(TeamMemberRole.Owner);
|
||||
}
|
||||
|
||||
// ---- Renaming a vault ----
|
||||
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The rename the vaults screen offers, and the assertion that matters is the second one: the team is
|
||||
/// renamed with the vault when it owns nothing else. A vault made from that screen gets a team of its
|
||||
/// own that nobody was ever shown, so a rename that moved only the vault would leave the operator, the
|
||||
/// logs and the database naming it something no user recognises.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The slug is asserted unchanged in the same breath. It is unique only among live teams, so a rename
|
||||
/// that moved it could take one an archived team is still holding — the same limit
|
||||
/// <c>UpdateTeamRequest</c> records.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public async Task RenamingAVault_RenamesTheTeamBehindItAndLeavesItsSlugAlone()
|
||||
{
|
||||
var owner = await EnrolledClientAsync("vault-rename-owner");
|
||||
|
||||
var team = await CreateTeamAsync(owner, "Platform secrets");
|
||||
var vaultId = await CreateVaultAsync(owner, team.TeamId);
|
||||
|
||||
var response = await owner.PutContractAsync(
|
||||
VaultUrl(vaultId), new UpdateVaultRequest("Platform"));
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var renamed = (await response.Content.ReadContractAsync<VaultSummary>())!;
|
||||
|
||||
renamed.Name.ShouldBe("Platform");
|
||||
|
||||
var me = await ReadAsync<MeResponse>(owner, MeUrl);
|
||||
|
||||
me.Vaults.Single(vault => vault.VaultId == vaultId).Name.ShouldBe("Platform");
|
||||
|
||||
var listed = await ReadAsync<IReadOnlyList<TeamSummary>>(owner, TeamsUrl);
|
||||
var after = listed.Single(row => row.TeamId == team.TeamId);
|
||||
|
||||
after.Name.ShouldBe("Platform");
|
||||
after.Slug.ShouldBe(team.Slug);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// A team carrying several vaults has a name of its own that somebody chose, so renaming one of its
|
||||
/// vaults must not take it. This is the arrangement the vaults screen cannot make and does not hide;
|
||||
/// the server draws the same line.
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public async Task RenamingOneOfSeveralVaults_LeavesTheTeamsOwnNameAlone()
|
||||
{
|
||||
var owner = await EnrolledClientAsync("vault-rename-shared-owner");
|
||||
|
||||
var team = await CreateTeamAsync(owner, "Platform Engineering");
|
||||
var vaultId = await CreateVaultAsync(owner, team.TeamId);
|
||||
|
||||
await CreateVaultAsync(owner, team.TeamId);
|
||||
|
||||
var response = await owner.PutContractAsync(
|
||||
VaultUrl(vaultId), new UpdateVaultRequest("Production"));
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var listed = await ReadAsync<IReadOnlyList<TeamSummary>>(owner, TeamsUrl);
|
||||
|
||||
listed.Single(row => row.TeamId == team.TeamId).Name.ShouldBe("Platform Engineering");
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// Admin rather than Write, and the line is the one the team rename draws: a name is what everybody in
|
||||
/// the vault sees it called, so a member who may add hosts to it may not rename it out from under them.
|
||||
/// A member is refused with 403 rather than 404 because the vault is visible to them, so naming the
|
||||
/// reason leaks nothing.
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public async Task APlainMember_CannotRenameAVaultTheyCanWriteTo()
|
||||
{
|
||||
var owner = await EnrolledClientAsync("vault-rename-limits-owner", "vrowner@example.com");
|
||||
var member = await EnrolledClientAsync("vault-rename-limits-member", "vrmember@example.com");
|
||||
|
||||
var team = await CreateTeamAsync(owner, "Limits");
|
||||
var vaultId = await CreateVaultAsync(owner, team.TeamId);
|
||||
var entry = await LookupAsync(owner, "vrmember@example.com");
|
||||
|
||||
await AddMemberAsync(owner, team.TeamId, entry.UserId, TeamMemberRole.Member);
|
||||
|
||||
var response = await member.PutContractAsync(
|
||||
VaultUrl(vaultId), new UpdateVaultRequest("Theirs now"));
|
||||
|
||||
await ShouldBeProblemAsync(response, HttpStatusCode.Forbidden, ProblemCodes.Forbidden);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// An outsider gets 404 rather than 403, which is the rule <c>IVaultAccessService</c> states: a
|
||||
/// distinct "exists but forbidden" answer is an existence oracle for other tenants' vault ids.
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public async Task RenamingSomebodyElsesVault_IsNotFound()
|
||||
{
|
||||
var owner = await EnrolledClientAsync("vault-rename-outsider-owner");
|
||||
var outsider = await EnrolledClientAsync("vault-rename-outsider");
|
||||
|
||||
var team = await CreateTeamAsync(owner, "Private");
|
||||
var vaultId = await CreateVaultAsync(owner, team.TeamId);
|
||||
|
||||
var response = await outsider.PutContractAsync(
|
||||
VaultUrl(vaultId), new UpdateVaultRequest("Mine now"));
|
||||
|
||||
response.StatusCode.ShouldBe(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// An empty name is refused rather than stored, because a vault has to be pickable by name before
|
||||
/// anything in it is decrypted — one called nothing is one nobody can choose.
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public async Task RenamingAVaultToNothing_IsRefused()
|
||||
{
|
||||
var owner = await EnrolledClientAsync("vault-rename-empty-owner");
|
||||
|
||||
var team = await CreateTeamAsync(owner, "Named");
|
||||
var vaultId = await CreateVaultAsync(owner, team.TeamId);
|
||||
|
||||
var response = await owner.PutContractAsync(VaultUrl(vaultId), new UpdateVaultRequest(" "));
|
||||
|
||||
await ShouldBeProblemAsync(response, HttpStatusCode.BadRequest, ProblemCodes.InvalidTeam);
|
||||
}
|
||||
|
||||
// ---- Archiving ----
|
||||
|
||||
/// <remarks>
|
||||
@@ -1092,6 +1220,8 @@ public sealed class TeamEndpointTests(ApiFixture fixture)
|
||||
|
||||
private static string TeamVaultsUrl(Guid teamId) => $"{TeamsUrl}/{teamId}/vaults";
|
||||
|
||||
private static string VaultUrl(Guid vaultId) => $"/api/v1/vaults/{vaultId}";
|
||||
|
||||
/// <summary>An address no account holds, uniquified because the container is shared.</summary>
|
||||
private static string NewAddress() => $"invitee-{Guid.CreateVersion7():N}@example.com";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user