Conversation
90d44f7 to
c55947e
Compare
codingllama
left a comment
There was a problem hiding this comment.
Quick pass over the non-teleterm parts. I'll come back shortly for the rest.
| if err := json.Unmarshal(loginRespJSON.Bytes(), loginResp); err != nil { | ||
| return nil, trace.Wrap(err) | ||
| } | ||
| return loginResp, nil |
There was a problem hiding this comment.
This block is all copy-pasta, right? Just to confirm.
There was a problem hiding this comment.
yup! only difference is that i added setting a CustomPrompt if any
| } | ||
|
|
||
| // PwdlessLogin processes passwordless logins for this cluster. | ||
| func (c *Cluster) PwdlessLogin(ctx context.Context, stream api.TerminalService_LoginPasswordlessServer) error { |
There was a problem hiding this comment.
FYI, I wouldn't advise passing gRPC streams around, but I assume you are following suite from other methods.
It tends to make testing awkward, as it ties various parts of the code to gRPC's behavior.
There was a problem hiding this comment.
FYI, I wouldn't advise passing gRPC streams around, but I assume you are following suite from other methods.
It tends to make testing awkward, as it ties various parts of the code to gRPC's behavior.
What would be another way to solve this? The only thing which comes to my mind is accepting an interface with Recv/Send, would something like that work?
There was a problem hiding this comment.
I tend to write simpler gRPC layers than what I'm seeing here. My first instinct would be to code the stream in the "topmost" gRPC handler and (possibly) call out streaming-unaware methods to solve its stages. This way you'll have a full gRPC test for the
"topmost" method (as we usually do) and plain Go tests for everything downstream. (Passing proto messages around is fine, protos are meant to carry data after all.)
Now, TBH, I would avoid streaming if I have a fixed number of request-response calls, like we have here - I would chain unary RPCs instead. I think streaming shines when we need an arbitrary number of server-to-client messages, but otherwise the feature isn't (wasn't?) very well supported by a number of language clients.
That's my 2c on this particular scenario, but I don't expect any changes to PR. Happy to chat about gRPC/project design/organization sometime.
4c35bbf to
1fd78eb
Compare
codingllama
left a comment
There was a problem hiding this comment.
Thanks for the changes, Lisa.
Added a few minor comments, but essentially it LGTM. Just waiting to see if we'll get more code/test changes or if it's settled.
1696ec4 to
4c50bd9
Compare
ravicious
left a comment
There was a problem hiding this comment.
Commented on some minor stuff but overall looks good.
| // PASSWORDLESS_PROMPT_CREDENTIAL is used when we require a user to select a username | ||
| // associated with their account. | ||
| PASSWORDLESS_PROMPT_CREDENTIAL = 3; |
There was a problem hiding this comment.
Thanks a lot for providing meaningful comments! 👍
There was a problem hiding this comment.
credits to @codingllama who taught me to write better comments :)
| message LoginPasswordlessCredentialResponse { | ||
| // index is the associated number in the list of credentials that the user selected to log | ||
| // in as. | ||
| int64 index = 3; |
There was a problem hiding this comment.
Does this need to be 3 or could it be 1?
There was a problem hiding this comment.
ack, thanks for catching this
| } | ||
|
|
||
| // PwdlessLogin processes passwordless logins for this cluster. | ||
| func (c *Cluster) PwdlessLogin(ctx context.Context, stream api.TerminalService_LoginPasswordlessServer) error { |
There was a problem hiding this comment.
Excluding docs and so on, it seems that we generally tend to use the full passwordless form more so I'd be for using it here too.
$ rg passwordless -g '!docs' -g '!*.pb.go' -g '!*.js' -g '!*_pb.d.ts' -g '!*.md' | wc -l
445
$ rg pwdless -g '!docs' -g '!*.pb.go' -g '!*.js' -g '!*_pb.d.ts' -g '!*.md' | wc -l
72
There was a problem hiding this comment.
+1 for full spelling in public APIs, well spotted.
Besides being able to use a CustomPrompt, this just mainly rearranges how things are being defined and passed around.
d3219c0 to
e5be839
Compare
Description
wancli.LoginPromptinterface):wancli.PromptTouchdefinitions to return an error even thoughwancli.DefaultPromptimplementation will never return an error. It was required to allow returning stream errors for this implementation for teleterm.pwdlessLoginlogic into a reusable func that can be used by both tsh and teleterm. Nothing new was added other than allowing the use ofCustomPromptTODO: I need to test this with a mac with touchID to see if i need further tweaking