| Layer | Units | Role |
|---|---|---|
| Snif | StreamSec.Snif.* | the server / application side |
| Snic | StreamSec.Snic.* | the client side |
| Snip | StreamSec.Snip.* | the transport (IsnipConnection) |
TsnifClassServer.RegisterServerClass(AClass) publishes a class. The class is
compiled with {$TYPEINFO ON}{$METHODINFO ON}; calls are dispatched by RTTI (no
skeletons to hand-write).StreamSec.Snif.ServerAttributes) decorate the class:
InstanceKind(perCall | perConnection | perSession | perUser | ...) — the lifetime / scope of the server object.Roles('admin', ...) — role-based access control (ownership + per-method gating).MediatorKind(viaSession | viaUser | viaRole | viaApplication) with ColleagueRoles('...') — control peer ("colleague") access to an instance owned by another connection.Login, LoginPlain and ChangePassword
are auto-registered by the unit's initialization — do NOT register them yourself.TsnicClassClient.MakeInstance(QualifiedClassName, TypeInfo(IFoo), Obj, Role)
returns a TVirtualInterface proxy. Calling a method on the proxy marshals a request
over the connection and returns the result.
TsnipBaseOctetConnection does the varint-framed wire encoding; concrete subclasses
supply the raw bytes: SSHOctetConnection (over SSH, requests the 'snip'
subsystem), TLSOctetConnection (over TLS), or an in-memory pipe (see the demos'
SnifDemo.MemConn).TsnipServer / TsnipClient bundle the SSH socket
server/client + the snip subsystem + authentication, with modern defaults out of the box:
KEX mlkem768x25519-sha256 (hybrid post-quantum) and cipher
AEAD_AES_256_GCM. The server picks its host-key type via HostKeyKind
(hkRSA = RSA-3072 / hkECDSA = NIST P-384 / hkEdDSA = Ed25519); the client verifies any of
the three and can pin a specific server key.Over SSH, authentication is two-layered: (1) the SSH transport user, and (2) the Snif
application user via the Login exchange. The in-memory transport has only the Snif
layer. The Snif password login is an augmented (asymmetric) PAKE built on a KEM (it
replaced the library's earlier bespoke verifier-based challenge-response scheme): the server
stores only a per-user verifier, never the password — see the
Tunnel Bound KAPA notes. Records are persisted by the
TsnifUserFileStorage component, and the session is
bound to the authentication through StreamSec.Snif.ChannelBinding.
Declare the interface and the server class in a shared unit (compiled into both ends so the proxy type matches):
{$M+}
IMyService = interface
['{...GUID...}']
function DoThing(const A: string): Integer;
end;
{$M-}
{$TYPEINFO ON}{$METHODINFO ON}
[InstanceKind(perSession),Roles('myrole')] // a class with NEITHER Roles NOR Anonymous is DENIED
TMyService = class
public
[Roles('myrole')]
function DoThing(const A: string): Integer;
end;
{$METHODINFO OFF}
Server startup:
Server.RegisterServerClass(TMyService); // before accepting connections // provision SSH users (Server.SSHUsers) and Snif users (UpdateUserList) Server.Start;
Client:
Client.MakeInstance('MyUnit.TMyService', TypeInfo(IMyService), Svc, '');
n := Svc.DoThing('hello');
[Roles(...)] attribute the caller satisfies, or an explicit [Anonymous]
attribute. A class with neither is unreachable by every connection (including not-logged-in
ones) — a deliberate guard so that forgetting a Roles attribute denies access
instead of silently exposing the class. Mark a class [Anonymous] only when it is meant to
be callable without authentication; per-method [Roles] still apply.TsnipServer / TsnipClient ship mutually-compatible modern defaults,
so a default server and client interoperate with no tweaking. To talk to a peer needing other
algorithms (e.g. stock OpenSSH, which does not yet speak mlkem768x25519-sha256),
widen the set by selecting AllOptionNames on the relevant Kex/ServerKey/Cipher/Mac
lists. The server selects its host-key algorithm automatically from the assigned key — set
the key type via HostKeyKind, not ServerKeyOptions.'snip' subsystem per SSH user:
with Server.SSHUsers.Add do SubSystems.SelectedOptionNames := 'snip';TArray<> of scalars, strings or records), and
stDERUtils.TSafeBytes (the supported way to pass a tBytes value — a
raw tBytes has no RTTI element type and will not marshal; wrap it as
TSafeBytes). The server class must be declared in a unit's interface section
(not a program type section) or RegisterServerClass raises ENonPublicType,
and both interface and class need {$M+} / {$TYPEINFO ON}{$METHODINFO ON}.
Open-array array of X params are rejected (use a dynamic-array type).perSession / perConnection instances: the client must open a session
(Client.Session := 'new') before MakeInstance, or the call fails.while Connection.HasData do HandleRequest), coordinated with outgoing calls.Runnable demos live in Demos\Delphi 13\Snif\; the shared mock "business" classes
and client interfaces are used identically across transports.
TsnipServer / TsnipClient) over loopback;
shows both auth layers.A client passes an IChatListener to TChatRoom.Subscribe; the framework
wraps it as a server-held proxy bound to that connection, and TChatRoom.Publish calls
OnMessage back on every subscriber — the inverse of a normal RPC, needing a
background pump thread on each client. Demos: CallbackProof (in-memory),
CallbackServer + CallbackSshProof (SSH), and ChatClient
(VCL; run two instances).
One "owner" connection creates an instance; other "colleague" connections reach that same
instance via SubscribeMediator. Acceptance depends on the class
MediatorKind and Roles: viaSession (same session), viaUser
(same user, any session), viaRole (share a class role — ownership needs ALL roles,
subscription needs ANY one), viaApplication (any authenticated colleague). Demos:
MediatorProof (in-memory accept/deny matrix), MediatorServer +
MediatorSshProof (SSH), and MediatorOwner / MediatorColleague (VCL).
Building: RAD Studio 13 (BDS 37.0); demo .dproj search paths point at
..\..\..\Source. For a full application built on this framework (the PersonalAdmin
self-service class over snip-over-SSH), see the SSH Tunnel Server / Client demos in
..\SSH\.