HostAdmission

class HostAdmission(val policy: AdmissionPolicy, val revocations: RevocationList)

Everything a host needs to decide who comes in: the app's policy for newcomers, and the host's revocations for devices whose passes it no longer honours.

There is deliberately no host key here. The room checks every pass against its own device key, the one it signs passes with, so the key that issues passes and the key that checks them cannot differ.

Samples

// RejectCode is open. The joiner does not know this code, so it arrives as
// RejectCode.Unknown("not-welcome", retryable = false), and a reconnecting device stops knocking.
val notWelcome = object : RejectCode {
    override val id: String = "not-welcome"
    override val retryable: Boolean = false
}
// The room checks returning passes against this list. Kept in the store, since a friend's pass
// never expires: an in-memory list forgets on restart, and the voided passes work again.
val revocations = RevocationList.open(store)
val policy = AdmissionPolicy { request ->
    // `key` is the device key the joiner proved it holds. `displayName` is only its say-so.
    when {
        // The app's blocked set, never the revocations: a revocation cannot be taken back, so
        // refusing every revoked key here would ban it for good.
        request.key in blocked.value -> AdmissionDecision.Reject(notWelcome)
        request.key in friends -> AdmissionDecision.Admit(GrantTerms(Duration.INFINITE, GrantReach.AnyRoomOfIssuer))
        else -> AdmissionDecision.Admit(GrantTerms(readmitFor = 1.hours))
    }
}
return HostAdmission(policy, revocations)
// One past the clock, so a pass issued in this same millisecond is void too.
admission.revocations.revoke(lost, notBefore = clock().toEpochMilliseconds() + 1)

Constructors

Link copied to clipboard
constructor(policy: AdmissionPolicy, revocations: RevocationList)

Properties

Link copied to clipboard

Decides every newcomer; never asked about a returning device.

Link copied to clipboard

Per-device cutoffs. A device revoked after its seat was admitted does not get that seat back, and goes to the policy as a newcomer; while it stays connected it keeps its seat, but the room stops renewing its pass (Decided 14). A pass issued before its device's cutoff does not let it back in unvetted either (#3222). They void seats and passes; they do not keep a device out, which is the policy's job.

Functions

Link copied to clipboard
open override fun toString(): String