wechaty/puppet-service

Add authorization for puppet server to make sure the puppet service consumer is valid

huan opened this issue · 3 comments

huan commented

What is the grpc.default_authority

From @grpc/grpc-js/url-parser.ts

export function uriToString(uri: GrpcUri): string {
  let result = '';
  if (uri.scheme !== undefined) {
    result += uri.scheme + ':';
  }
  if (uri.authority !== undefined) {
    result += '//' + uri.authority + '/';
  }
  result += uri.path;
  return result;
}
huan commented

gRPC: The "xds" URI scheme does not support any authority

xds Resolver

Clients will enable use of xDS by using the xds resolver in the target URI used to create the gRPC channel. For example, a user may create a channel using the URI "xds:example.com:123" or "xds:///example.com:123", which will use xDS to establish contact with the server "example.com:123". The "xds" URI scheme does not support any authority.

Source: https://github.com/grpc/proposal/blob/master/A27-xds-global-load-balancing.md#xds-resolver

huan commented

Final solution

We finally decided to use the Authorization key in gRPC call metadata with Wechaty: ${TOKEN} to authorize the client, with the SSL enabled.

To be deprecated

We have put the TOKEN to the grpc.default_authority in the previous merged #78 to identify the client.

However, this is not secure and should be deprecated after Dec 31, 2022.

This method will be supported for now as a workaround when the client can not establish an SSL connection.