Authorize Unary Calls and Long-Lived Streams
Compare unary and streaming interceptors, per-object subscriptions, revocation, message limits, deadlines, and cancellation.
You’re reading a preview. Premium includes the full lesson and specialist practice. View the full curriculum.
A stream is a continuing authorization decision
A unary RPC receives a request and returns a response. A streaming RPC can keep sending or receiving messages over time. Authentication at connection or method start is necessary, but the server still needs permission for the selected object, each supported operation, and any later change in subscription scope.
LedgerLive has a protected unary GetAccount method and a WatchEntries stream. Both receive a valid user identity over TLS. The unary method checks account membership; the stream accepts any account ID after login. A caller who cannot read account 82 through the unary method can subscribe to its future entries.
service Accounts {
rpc GetAccount(GetAccountRequest) returns (Account);
rpc WatchEntries(WatchEntriesRequest) returns (stream Entry);
}
message WatchEntriesRequest { string account_id = 1; }