Public Access
A Spelunk API key reaches one organisation, so a server elsewhere - oc-linux in Orange Climate - was refused before it reached the agent. Each device now signs in to a Spelunk once, under Settings -> Security -> Spelunk or from a Spelunk host's editor: the OAuth authorization code flow with PKCE for a native app (RFC 8252), with Spelunk as the authorization server. The browser opens Spelunk's /api/app-sign-in/authorize with a loopback redirect (the app's own scheme on Android), the person signs in there however they normally do and allows "DodoSSH on <device>", and the code is redeemed at /api/app-sign-in/token for an app session token. That token opens terminals in every organisation its person is in, with the role they have on each server at the time; tunnel tickets send no organisation. The sign-in stays on the device: sealed in the local cache under the LocalCacheKey (AAD resource type 18, bound to its row), never synced, wiped with the cache, and only ever sent to the Spelunk it came from. A 401 from Spelunk forgets it; SIGN OUT ends it there and here, and so does signing out of DodoSSH. Before every Spelunk connection DodoSSH asks its own identity provider whether its sign-in still stands (a forced refresh, at most once a minute), and an account it refuses is signed out of DodoSSH and of every Spelunk on the device. A route names no key any more: Spelunk hosts are written at host schema 11, which an older build shows read-only and asks to be updated for, and a payload that still names a key credential decodes with the id skipped. The SpelunkKey item type is gone: SyncEntityType 14, ChangeEntityType 14 and AAD type 17 are retired, the server drops spelunk_key and its change-log rows, and the client cache drops its cached items, outbox entries and conflicts of that type. A link still never starts a sign-in: from a Spelunk this device is not signed in to it opens the editor, which offers to. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
2.2 KiB
C#
62 lines
2.2 KiB
C#
using DodoSSH.Client.Session;
|
|
|
|
namespace DodoSSH.Client.Shell.ViewModels;
|
|
|
|
/// <summary>
|
|
/// The shell's half of a link from Spelunk: holding it until there is a vault to act on it.
|
|
/// </summary>
|
|
internal sealed partial class MainWindowViewModel
|
|
{
|
|
/// <summary>
|
|
/// Acts on a <c>dodossh://spelunk/connect</c> link now, or as soon as a vault is open.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// <para>
|
|
/// Called by the head, on the UI thread, for a link this launch was started with, a link a second launch
|
|
/// passed down the doorbell, or one the platform delivered to the running application. The link has
|
|
/// already been checked by <see cref="SpelunkLink.TryParse"/>; what it may do is decided by
|
|
/// <see cref="VaultViewModel.OpenSpelunkLinkAsync"/>, which never starts a sign-in by itself, and only
|
|
/// connects through a Spelunk this device is already signed in to.
|
|
/// </para>
|
|
/// <para>
|
|
/// <b>A locked application keeps it rather than dropping it.</b> Clicking a server in Spelunk and being
|
|
/// asked for the passphrase is the ordinary first half of this; losing the click at the second half would
|
|
/// make the button look broken. It is not kept across a restart.
|
|
/// </para>
|
|
/// </remarks>
|
|
internal void OpenLink(SpelunkLink link)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(link);
|
|
|
|
pendingLink = link;
|
|
|
|
if (State is ShellState.Unlocked && Vault is not null)
|
|
{
|
|
DeliverPendingLink();
|
|
return;
|
|
}
|
|
|
|
if (State is ShellState.Locked)
|
|
{
|
|
StatusMessage = $"Unlock to open {link.Name} from Spelunk.";
|
|
}
|
|
}
|
|
|
|
/// <summary>Hands a waiting link to the open vault, on the Hosts screen where its answer appears.</summary>
|
|
private void DeliverPendingLink()
|
|
{
|
|
if (pendingLink is not { } link || Vault is not { } vault)
|
|
{
|
|
return;
|
|
}
|
|
|
|
pendingLink = null;
|
|
|
|
ShowScreen(ShellScreen.Hosts);
|
|
|
|
// Not awaited: a connect reports its own progress and failures on the vault's status line and in its
|
|
// tab, as a tap on the row does, and this is called from places that must not wait on a handshake.
|
|
_ = vault.OpenSpelunkLinkAsync(link);
|
|
}
|
|
}
|