diff --git a/cmd/microauth2sqld/handler/auth2.go b/cmd/microauth2sqld/handler/auth2.go index d2b8797..2df138b 100644 --- a/cmd/microauth2sqld/handler/auth2.go +++ b/cmd/microauth2sqld/handler/auth2.go @@ -210,6 +210,7 @@ func (s *Handler) genTokens(ctx context.Context, user *db.User, out *authpb.Toke return err } + out.Id = user.ID.String() out.RefreshToken = refreshSignedToken out.RefreshTokenExpiresAt = refreshClaims.ExpiresAt.Unix() out.AccessToken = accessSignedToken diff --git a/internal/proto/authpb/authpb.pb.go b/internal/proto/authpb/authpb.pb.go index 7738572..c44c47d 100644 --- a/internal/proto/authpb/authpb.pb.go +++ b/internal/proto/authpb/authpb.pb.go @@ -389,10 +389,11 @@ type Token struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AccessToken string `protobuf:"bytes,1,opt,name=accessToken,proto3" json:"accessToken,omitempty"` - AccessTokenExpiresAt int64 `protobuf:"varint,2,opt,name=accessTokenExpiresAt,proto3" json:"accessTokenExpiresAt,omitempty"` - RefreshToken string `protobuf:"bytes,3,opt,name=refreshToken,proto3" json:"refreshToken,omitempty"` - RefreshTokenExpiresAt int64 `protobuf:"varint,4,opt,name=refreshTokenExpiresAt,proto3" json:"refreshTokenExpiresAt,omitempty"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + AccessToken string `protobuf:"bytes,2,opt,name=accessToken,proto3" json:"accessToken,omitempty"` + AccessTokenExpiresAt int64 `protobuf:"varint,3,opt,name=accessTokenExpiresAt,proto3" json:"accessTokenExpiresAt,omitempty"` + RefreshToken string `protobuf:"bytes,4,opt,name=refreshToken,proto3" json:"refreshToken,omitempty"` + RefreshTokenExpiresAt int64 `protobuf:"varint,5,opt,name=refreshTokenExpiresAt,proto3" json:"refreshTokenExpiresAt,omitempty"` } func (x *Token) Reset() { @@ -427,6 +428,13 @@ func (*Token) Descriptor() ([]byte, []int) { return file_authpb_proto_rawDescGZIP(), []int{6} } +func (x *Token) GetId() string { + if x != nil { + return x.Id + } + return "" +} + func (x *Token) GetAccessToken() string { if x != nil { return x.AccessToken @@ -743,17 +751,18 @@ var file_authpb_proto_rawDesc = []byte{ 0x61, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, 0xb7, 0x01, - 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, - 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, + 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x72, 0x6f, 0x6c, 0x65, 0x73, 0x22, 0xc7, 0x01, + 0x0a, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, + 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x32, 0x0a, 0x14, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x14, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, + 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x14, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x12, 0x22, 0x0a, - 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, + 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x34, 0x0a, 0x15, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, - 0x6e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, + 0x6e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x15, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x45, 0x78, 0x70, 0x69, 0x72, 0x65, 0x73, 0x41, 0x74, 0x22, 0x5f, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, diff --git a/internal/proto/authpb/authpb.proto b/internal/proto/authpb/authpb.proto index 2ce4886..c781dd7 100644 --- a/internal/proto/authpb/authpb.proto +++ b/internal/proto/authpb/authpb.proto @@ -62,10 +62,11 @@ message UpdateRolesRequest { } message Token { - string accessToken = 1; - int64 accessTokenExpiresAt = 2; - string refreshToken = 3; - int64 refreshTokenExpiresAt = 4; + string id = 1; + string accessToken = 2; + int64 accessTokenExpiresAt = 3; + string refreshToken = 4; + int64 refreshTokenExpiresAt = 5; } message RegisterRequest {