Skip to content

Commit d45b8db

Browse files
authored
L112 update: Add getConnectionInfo and getAuthContext to ServerInterceptingCall (#483)
1 parent fea3788 commit d45b8db

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

L112-node-server-interceptors.md

+25
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Server interceptors are one of the longest-standing feature requests in the Node
1818

1919
### Related Proposals:
2020
* [L5: NodeJS Client Interceptors][L5]
21+
* [L35: Exposing the per-call authentication context data in Node][L35]
2122
* [A41: xDS RBAC Support][A41]
2223

2324
## Proposal
@@ -51,6 +52,17 @@ export interface ServerMethodDefinition<RequestType, ResponseType> {
5152
}
5253
```
5354

55+
A `ConnectionInfo` object describes the connection that was used to make the call, and it is defined as follows:
56+
57+
```ts
58+
export interface ConnectionInfo {
59+
localAddress?: string | undefined;
60+
localPort?: number | undefined;
61+
remoteAddress?: string | undefined;
62+
remotePort?: number | undefined
63+
}
64+
```
65+
5466
A `ServerInterceptingCall` has the following API:
5567

5668
```ts
@@ -87,6 +99,14 @@ class ServerInterceptingCall {
8799
* Return the host requested by the client in the ":authority" header.
88100
*/
89101
getHost(): string;
102+
/**
103+
* Return information about the connection used to make the call.
104+
*/
105+
getConnectionInfo(): string;
106+
/**
107+
* Get the auth context for the call.
108+
*/
109+
getAuthContext(): AuthContext;
90110
}
91111
```
92112

@@ -276,9 +296,14 @@ For consistency with the client interceptors design, interceptors will see un-se
276296

277297
The client interceptor design has interceptor lists and interceptor provider lists, and interceptors specified at client construction vs interceptors specified for individual call invocations. In contrast, this design only specifies that an interceptor list can be provided at server construction. Per-call interceptors simply don't make sense on the server side, because there is no reasonable point at which to inject them that wouldn't just act as a regular interceptor. Interceptor providers on the other hand could work on the server, but they are not necessary for basic interceptor functionality. The primary purpose of this design is to solidify the interceptor part of the design. Additional injection points for interceptors could be specified in the future, and the way they interact with each other can be decided at that time.
278298

299+
### Optional fields in `ConnectionInfo`
300+
301+
The type information for Node indicates that the corresponding fields on the `Socket` class are not guaranteed to be populated, so we cannot guarantee that we can populate them here.
302+
279303
## Implementation
280304

281305
I (murgatroid99) will implement this immediately.
282306

283307
[L5]: https://github.com/grpc/proposal/blob/master/L5-node-client-interceptors.md
284308
[A41]: https://github.com/grpc/proposal/blob/master/A41-xds-rbac.md
309+
[L35]: https://github.com/grpc/proposal/blob/master/L35-node-getAuthContext.md

0 commit comments

Comments
 (0)