Proto
Internal calls between the services use Connect, defined in Protocol Buffers under proto/ and generated with buf into gen/. None of these services is reachable through the gateway.
LoginService
Section titled “LoginService”user.v1.LoginService is called only by auth, with its own token: client_id auth, carrying the login-codes:redeem scope. Any other token gets PERMISSION_DENIED, even one with the scope. It listens on the user service’s RPC_ADDR.
syntax = "proto3";
package user.v1;
// LoginService turns one-time login codes into the users they sign in. Only// the auth service calls it, with a token carrying the login-codes:redeem// scope; it isn't reachable through the gateway.service LoginService { // RedeemLoginCode consumes a login code and returns the user it signs in, // registering them first when the code was sent to a new email. A code // works once: an unknown, used or expired code fails with UNAUTHENTICATED. rpc RedeemLoginCode(RedeemLoginCodeRequest) returns (RedeemLoginCodeResponse);}
message RedeemLoginCodeRequest { // The code from the sign-in link, as the browser sent it. string code = 1;}
message RedeemLoginCodeResponse { string user_id = 1; string email = 2;}| Method | Request | Response | Errors |
|---|---|---|---|
RedeemLoginCode |
code: the code from the sign-in link |
user_id, email |
UNAUTHENTICATED for an unknown, used or expired code; PERMISSION_DENIED for a token not issued to auth |
Generated code:
gen/: the messages.user/ v1/ login.pb.go gen/: the Connect client and server interfaces.user/ v1/ userv1connect/ login.connect.go
version: v2modules: - path: protolint: use: - STANDARDbreaking: use: - FILEversion: v2managed: enabled: true override: - file_option: go_package_prefix value: github.com/vardius/go-api-boilerplate/genplugins: - local: [go, tool, protoc-gen-go] out: gen opt: paths=source_relative - local: [go, tool, protoc-gen-connect-go] out: gen opt: paths=source_relativeclean: trueThe generators run through go tool, at the versions pinned in go.mod. To add a method, see Add an RPC.