first commit

This commit is contained in:
Yevhen Odynets 2024-02-11 08:19:22 +02:00
commit 3105ae2c4b
9 changed files with 873 additions and 0 deletions

5
README.md Normal file
View File

@ -0,0 +1,5 @@
> # __APU__
> - ### GRPc Protos generator

56
apu/v1/apu.proto Normal file
View File

@ -0,0 +1,56 @@
syntax = "proto3";
package auth;
import "buf/validate/validate.proto";
service Auth {
rpc Register (RegisterRequest) returns (RegisterResponse);
rpc Login (LoginRequest) returns (LoginResponse);
rpc IsAdmin (IsAdminRequest) returns (IsAdminResponse);
}
message RegisterRequest {
/* Відповідно до стандартів електронної пошти (RFC 5321 і RFC 5322),
максимальна довжина електронної адреси становить 320 символів,
поєднання локальної та доменної частин.
Деякі системи електронної пошти можуть не приймати довші адреси електронної пошти.
Інтернаціоналізовані електронні адреси (із символами, відмінними від ASCII) можуть бути довшими через кодування.
Однак вони повинні дотримуватися обмеження в 320 символів.
*/
string email = 1 [(buf.validate.field).string = {email: true, min_len: 3, max_len: 320}, (buf.validate.field).required = true];
/* Password must contain one digit from 1 to 9, one lowercase letter, one uppercase letter,
no space and it must be 8-24 characters long. Usage of any other special character is optional.
*/
string password = 2 [(buf.validate.field).cel = {
id: "RegisterRequest.password",
message: 'Passwords should contain three of the four character types: upper-, lowercase letters and numbers. Special symbols are optional. The length must be at least 8 and no more than 24 characters.',
expression: "this.matches('[a-z]+') && this.matches('[A-Z]+') && this.matches('[0-9]+') && this.matches('^[!-~]{8,24}$')",
}, (buf.validate.field).string = {min_len: 8, max_len: 24}];
}
message RegisterResponse {
uint64 user_id = 1 [(buf.validate.field).uint64.gt = 1, (buf.validate.field).required = true];
}
message LoginRequest {
string email = 1 [(buf.validate.field).string = {email: true, min_len: 3, max_len: 320}, (buf.validate.field).required = true];
string password = 2 [(buf.validate.field).cel = {
id: "LoginRequest.password",
message: 'Passwords should contain three of the four character types: upper-, lowercase letters and numbers. Special symbols are optional. The length must be at least 8 and no more than 24 characters.',
expression: "this.matches('[a-z]+') && this.matches('[A-Z]+') && this.matches('[0-9]+') && this.matches('^[!-~]{8,24}$')",
}, (buf.validate.field).string = {min_len: 8, max_len: 24}];
int32 app_id = 3 [(buf.validate.field).int32.gt = 1, (buf.validate.field).required = true]; // ID of authorized application for the validation of the user
}
message LoginResponse {
string token = 1 [(buf.validate.field).required = true]; // Returned JWT token of the logged in user
}
message IsAdminRequest {
int64 user_id = 1 [(buf.validate.field).uint64.gt = 1, (buf.validate.field).required = true]; // User ID to validate for admin permissions
}
message IsAdminResponse {
bool is_admin = 1 [(buf.validate.field).bool.const = true, (buf.validate.field).required = true]; // Confirmation whether the user is an administrator
}

22
buf.gen.yaml Normal file
View File

@ -0,0 +1,22 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: ../
except:
- buf.build/bufbuild/protovalidate
plugins:
# - name: go
# out: gen/go
# opt: paths=source_relative
# - name: go-grpc
# out: gen/go
# opt: paths=source_relative
- plugin: buf.build/grpc/go
out: gen/go
opt:
- paths=source_relative
- plugin: buf.build/protocolbuffers/go
out: gen/go
opt:
- paths=source_relative

8
buf.lock Normal file
View File

@ -0,0 +1,8 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: bufbuild
repository: protovalidate
commit: e097f827e65240ac9fd4b1158849a8fc
digest: shake256:f19252436fd9ded945631e2ffaaed28247a92c9015ccf55ae99db9fb3d9600c4fdb00fd2d3bd7701026ec2fd4715c5129e6ae517c25a59ba690020cfe80bf8ad

9
buf.yaml Normal file
View File

@ -0,0 +1,9 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT
deps:
- buf.build/bufbuild/protovalidate

550
gen/go/apu/v1/apu.pb.go Normal file
View File

@ -0,0 +1,550 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.32.0
// protoc (unknown)
// source: apu/v1/apu.proto
package v1
import (
_ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type RegisterRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// According to email standards (RFC 5321 and RFC 5322),
//the maximum length of an email address is 320 characters,
//combining the local and domain parts.
//Longer email addresses may not be accepted by some email systems.
//
//Internationalized email addresses (those with non-ASCII characters) can be longer due to encoding.
//However, they must still adhere to the 320-character limit.
Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
// Password must contain one digit from 1 to 9, one lowercase letter, one uppercase letter,
//one underscore, no space and it must be 8-16 characters long.
//Usage of any other special character other than underscore is optional.
//pattern: "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*_)(?!.* ).{8,16}$",
//NOT SUPPORTED USING RE2
Password []byte `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
}
func (x *RegisterRequest) Reset() {
*x = RegisterRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_apu_v1_apu_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RegisterRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegisterRequest) ProtoMessage() {}
func (x *RegisterRequest) ProtoReflect() protoreflect.Message {
mi := &file_apu_v1_apu_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RegisterRequest.ProtoReflect.Descriptor instead.
func (*RegisterRequest) Descriptor() ([]byte, []int) {
return file_apu_v1_apu_proto_rawDescGZIP(), []int{0}
}
func (x *RegisterRequest) GetEmail() string {
if x != nil {
return x.Email
}
return ""
}
func (x *RegisterRequest) GetPassword() []byte {
if x != nil {
return x.Password
}
return nil
}
type RegisterResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId uint64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
}
func (x *RegisterResponse) Reset() {
*x = RegisterResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_apu_v1_apu_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RegisterResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RegisterResponse) ProtoMessage() {}
func (x *RegisterResponse) ProtoReflect() protoreflect.Message {
mi := &file_apu_v1_apu_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RegisterResponse.ProtoReflect.Descriptor instead.
func (*RegisterResponse) Descriptor() ([]byte, []int) {
return file_apu_v1_apu_proto_rawDescGZIP(), []int{1}
}
func (x *RegisterResponse) GetUserId() uint64 {
if x != nil {
return x.UserId
}
return 0
}
type LoginRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
//bytes password = 2 [(buf.validate.field).bytes = {pattern: "^[a-zA-Z0-9_]*$", min_len: 8, max_len: 24}, (buf.validate.field).required = true];
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
AppId int32 `protobuf:"varint,3,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` // ID of authorized application for the validation of the user
}
func (x *LoginRequest) Reset() {
*x = LoginRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_apu_v1_apu_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LoginRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LoginRequest) ProtoMessage() {}
func (x *LoginRequest) ProtoReflect() protoreflect.Message {
mi := &file_apu_v1_apu_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead.
func (*LoginRequest) Descriptor() ([]byte, []int) {
return file_apu_v1_apu_proto_rawDescGZIP(), []int{2}
}
func (x *LoginRequest) GetEmail() string {
if x != nil {
return x.Email
}
return ""
}
func (x *LoginRequest) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
func (x *LoginRequest) GetAppId() int32 {
if x != nil {
return x.AppId
}
return 0
}
type LoginResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` // Returned JWT token of the logged in user
}
func (x *LoginResponse) Reset() {
*x = LoginResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_apu_v1_apu_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *LoginResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LoginResponse) ProtoMessage() {}
func (x *LoginResponse) ProtoReflect() protoreflect.Message {
mi := &file_apu_v1_apu_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LoginResponse.ProtoReflect.Descriptor instead.
func (*LoginResponse) Descriptor() ([]byte, []int) {
return file_apu_v1_apu_proto_rawDescGZIP(), []int{3}
}
func (x *LoginResponse) GetToken() string {
if x != nil {
return x.Token
}
return ""
}
type IsAdminRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // User ID to validate for admin permissions
}
func (x *IsAdminRequest) Reset() {
*x = IsAdminRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_apu_v1_apu_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *IsAdminRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*IsAdminRequest) ProtoMessage() {}
func (x *IsAdminRequest) ProtoReflect() protoreflect.Message {
mi := &file_apu_v1_apu_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use IsAdminRequest.ProtoReflect.Descriptor instead.
func (*IsAdminRequest) Descriptor() ([]byte, []int) {
return file_apu_v1_apu_proto_rawDescGZIP(), []int{4}
}
func (x *IsAdminRequest) GetUserId() int64 {
if x != nil {
return x.UserId
}
return 0
}
type IsAdminResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsAdmin bool `protobuf:"varint,1,opt,name=is_admin,json=isAdmin,proto3" json:"is_admin,omitempty"` // Confirmation whether the user is an administrator
}
func (x *IsAdminResponse) Reset() {
*x = IsAdminResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_apu_v1_apu_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *IsAdminResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*IsAdminResponse) ProtoMessage() {}
func (x *IsAdminResponse) ProtoReflect() protoreflect.Message {
mi := &file_apu_v1_apu_proto_msgTypes[5]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use IsAdminResponse.ProtoReflect.Descriptor instead.
func (*IsAdminResponse) Descriptor() ([]byte, []int) {
return file_apu_v1_apu_proto_rawDescGZIP(), []int{5}
}
func (x *IsAdminResponse) GetIsAdmin() bool {
if x != nil {
return x.IsAdmin
}
return false
}
var File_apu_v1_apu_proto protoreflect.FileDescriptor
var file_apu_v1_apu_proto_rawDesc = []byte{
0x0a, 0x10, 0x61, 0x70, 0x75, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x70, 0x75, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x12, 0x04, 0x61, 0x75, 0x74, 0x68, 0x1a, 0x1b, 0x62, 0x75, 0x66, 0x2f, 0x76, 0x61,
0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x65, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x71, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65,
0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69,
0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0d, 0xba, 0x48, 0x0a, 0xc8, 0x01, 0x01, 0x72,
0x05, 0x18, 0xc0, 0x02, 0x60, 0x01, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x39, 0x0a,
0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x42,
0x1d, 0xba, 0x48, 0x1a, 0xc8, 0x01, 0x01, 0x7a, 0x15, 0x10, 0x08, 0x18, 0x18, 0x22, 0x0f, 0x5e,
0x5b, 0x61, 0x2d, 0x7a, 0x41, 0x2d, 0x5a, 0x30, 0x2d, 0x39, 0x5f, 0x5d, 0x2a, 0x24, 0x52, 0x08,
0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x37, 0x0a, 0x10, 0x52, 0x65, 0x67, 0x69,
0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x07,
0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x42, 0x0a, 0xba,
0x48, 0x07, 0xc8, 0x01, 0x01, 0x32, 0x02, 0x20, 0x01, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49,
0x64, 0x22, 0xc9, 0x03, 0x0a, 0x0c, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x23, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28,
0x09, 0x42, 0x0d, 0xba, 0x48, 0x0a, 0xc8, 0x01, 0x01, 0x72, 0x05, 0x18, 0xc0, 0x02, 0x60, 0x01,
0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0xf0, 0x02, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73,
0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0xd3, 0x02, 0xba, 0x48, 0xcf,
0x02, 0xba, 0x01, 0xc5, 0x02, 0x0a, 0x15, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x72, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x2e, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0xbe, 0x01, 0x50,
0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x20, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x20,
0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x72, 0x65, 0x65, 0x20, 0x6f, 0x66,
0x20, 0x74, 0x68, 0x65, 0x20, 0x66, 0x6f, 0x75, 0x72, 0x20, 0x63, 0x68, 0x61, 0x72, 0x61, 0x63,
0x74, 0x65, 0x72, 0x20, 0x74, 0x79, 0x70, 0x65, 0x73, 0x3a, 0x20, 0x75, 0x70, 0x70, 0x65, 0x72,
0x2d, 0x2c, 0x20, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x63, 0x61, 0x73, 0x65, 0x20, 0x6c, 0x65, 0x74,
0x74, 0x65, 0x72, 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x73,
0x2e, 0x20, 0x53, 0x70, 0x65, 0x63, 0x69, 0x61, 0x6c, 0x20, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c,
0x73, 0x20, 0x61, 0x72, 0x65, 0x20, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x2e, 0x20,
0x54, 0x68, 0x65, 0x20, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20,
0x62, 0x65, 0x20, 0x61, 0x74, 0x20, 0x6c, 0x65, 0x61, 0x73, 0x74, 0x20, 0x38, 0x20, 0x61, 0x6e,
0x64, 0x20, 0x6e, 0x6f, 0x20, 0x6d, 0x6f, 0x72, 0x65, 0x20, 0x74, 0x68, 0x61, 0x6e, 0x20, 0x32,
0x34, 0x20, 0x63, 0x68, 0x61, 0x72, 0x61, 0x63, 0x74, 0x65, 0x72, 0x73, 0x2e, 0x1a, 0x6b, 0x74,
0x68, 0x69, 0x73, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x28, 0x27, 0x5b, 0x61, 0x2d,
0x7a, 0x5d, 0x2b, 0x27, 0x29, 0x20, 0x26, 0x26, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x6d, 0x61,
0x74, 0x63, 0x68, 0x65, 0x73, 0x28, 0x27, 0x5b, 0x41, 0x2d, 0x5a, 0x5d, 0x2b, 0x27, 0x29, 0x20,
0x26, 0x26, 0x20, 0x74, 0x68, 0x69, 0x73, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x28,
0x27, 0x5b, 0x30, 0x2d, 0x39, 0x5d, 0x2b, 0x27, 0x29, 0x20, 0x26, 0x26, 0x20, 0x74, 0x68, 0x69,
0x73, 0x2e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x73, 0x28, 0x27, 0x5e, 0x5b, 0x21, 0x2d, 0x7e,
0x5d, 0x7b, 0x38, 0x2c, 0x32, 0x34, 0x7d, 0x24, 0x27, 0x29, 0x72, 0x04, 0x10, 0x08, 0x18, 0x18,
0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x12, 0x21, 0x0a, 0x06, 0x61, 0x70,
0x70, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x42, 0x0a, 0xba, 0x48, 0x07, 0xc8,
0x01, 0x01, 0x1a, 0x02, 0x20, 0x01, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x22, 0x2d, 0x0a,
0x0d, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c,
0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x06, 0xba,
0x48, 0x03, 0xc8, 0x01, 0x01, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x35, 0x0a, 0x0e,
0x49, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23,
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x42,
0x0a, 0xba, 0x48, 0x07, 0xc8, 0x01, 0x01, 0x32, 0x02, 0x20, 0x01, 0x52, 0x06, 0x75, 0x73, 0x65,
0x72, 0x49, 0x64, 0x22, 0x38, 0x0a, 0x0f, 0x49, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x25, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x61, 0x64, 0x6d,
0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x42, 0x0a, 0xba, 0x48, 0x07, 0xc8, 0x01, 0x01,
0x6a, 0x02, 0x08, 0x01, 0x52, 0x07, 0x69, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x32, 0xab, 0x01,
0x0a, 0x04, 0x41, 0x75, 0x74, 0x68, 0x12, 0x39, 0x0a, 0x08, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74,
0x65, 0x72, 0x12, 0x15, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74,
0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x61, 0x75, 0x74, 0x68,
0x2e, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x30, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x12, 0x2e, 0x61, 0x75, 0x74,
0x68, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13,
0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x49, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x14,
0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x49, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x15, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x49, 0x73, 0x41, 0x64,
0x6d, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x4f, 0x0a, 0x08, 0x63,
0x6f, 0x6d, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x42, 0x08, 0x41, 0x70, 0x75, 0x50, 0x72, 0x6f, 0x74,
0x6f, 0x50, 0x01, 0x5a, 0x09, 0x2e, 0x2e, 0x2f, 0x61, 0x70, 0x75, 0x2f, 0x76, 0x31, 0xa2, 0x02,
0x03, 0x41, 0x58, 0x58, 0xaa, 0x02, 0x04, 0x41, 0x75, 0x74, 0x68, 0xca, 0x02, 0x04, 0x41, 0x75,
0x74, 0x68, 0xe2, 0x02, 0x10, 0x41, 0x75, 0x74, 0x68, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74,
0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x04, 0x41, 0x75, 0x74, 0x68, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
file_apu_v1_apu_proto_rawDescOnce sync.Once
file_apu_v1_apu_proto_rawDescData = file_apu_v1_apu_proto_rawDesc
)
func file_apu_v1_apu_proto_rawDescGZIP() []byte {
file_apu_v1_apu_proto_rawDescOnce.Do(func() {
file_apu_v1_apu_proto_rawDescData = protoimpl.X.CompressGZIP(file_apu_v1_apu_proto_rawDescData)
})
return file_apu_v1_apu_proto_rawDescData
}
var file_apu_v1_apu_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_apu_v1_apu_proto_goTypes = []interface{}{
(*RegisterRequest)(nil), // 0: auth.RegisterRequest
(*RegisterResponse)(nil), // 1: auth.RegisterResponse
(*LoginRequest)(nil), // 2: auth.LoginRequest
(*LoginResponse)(nil), // 3: auth.LoginResponse
(*IsAdminRequest)(nil), // 4: auth.IsAdminRequest
(*IsAdminResponse)(nil), // 5: auth.IsAdminResponse
}
var file_apu_v1_apu_proto_depIdxs = []int32{
0, // 0: auth.Auth.Register:input_type -> auth.RegisterRequest
2, // 1: auth.Auth.Login:input_type -> auth.LoginRequest
4, // 2: auth.Auth.IsAdmin:input_type -> auth.IsAdminRequest
1, // 3: auth.Auth.Register:output_type -> auth.RegisterResponse
3, // 4: auth.Auth.Login:output_type -> auth.LoginResponse
5, // 5: auth.Auth.IsAdmin:output_type -> auth.IsAdminResponse
3, // [3:6] is the sub-list for method output_type
0, // [0:3] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_apu_v1_apu_proto_init() }
func file_apu_v1_apu_proto_init() {
if File_apu_v1_apu_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_apu_v1_apu_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RegisterRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_apu_v1_apu_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RegisterResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_apu_v1_apu_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_apu_v1_apu_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*LoginResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_apu_v1_apu_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*IsAdminRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_apu_v1_apu_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*IsAdminResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_apu_v1_apu_proto_rawDesc,
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_apu_v1_apu_proto_goTypes,
DependencyIndexes: file_apu_v1_apu_proto_depIdxs,
MessageInfos: file_apu_v1_apu_proto_msgTypes,
}.Build()
File_apu_v1_apu_proto = out.File
file_apu_v1_apu_proto_rawDesc = nil
file_apu_v1_apu_proto_goTypes = nil
file_apu_v1_apu_proto_depIdxs = nil
}

View File

@ -0,0 +1,183 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc (unknown)
// source: apu/v1/apu.proto
package v1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
const (
Auth_Register_FullMethodName = "/auth.Auth/Register"
Auth_Login_FullMethodName = "/auth.Auth/Login"
Auth_IsAdmin_FullMethodName = "/auth.Auth/IsAdmin"
)
// AuthClient is the client API for Auth service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type AuthClient interface {
Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error)
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error)
IsAdmin(ctx context.Context, in *IsAdminRequest, opts ...grpc.CallOption) (*IsAdminResponse, error)
}
type authClient struct {
cc grpc.ClientConnInterface
}
func NewAuthClient(cc grpc.ClientConnInterface) AuthClient {
return &authClient{cc}
}
func (c *authClient) Register(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) {
out := new(RegisterResponse)
err := c.cc.Invoke(ctx, Auth_Register_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
out := new(LoginResponse)
err := c.cc.Invoke(ctx, Auth_Login_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authClient) IsAdmin(ctx context.Context, in *IsAdminRequest, opts ...grpc.CallOption) (*IsAdminResponse, error) {
out := new(IsAdminResponse)
err := c.cc.Invoke(ctx, Auth_IsAdmin_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// AuthServer is the server API for Auth service.
// All implementations must embed UnimplementedAuthServer
// for forward compatibility
type AuthServer interface {
Register(context.Context, *RegisterRequest) (*RegisterResponse, error)
Login(context.Context, *LoginRequest) (*LoginResponse, error)
IsAdmin(context.Context, *IsAdminRequest) (*IsAdminResponse, error)
mustEmbedUnimplementedAuthServer()
}
// UnimplementedAuthServer must be embedded to have forward compatible implementations.
type UnimplementedAuthServer struct {
}
func (UnimplementedAuthServer) Register(context.Context, *RegisterRequest) (*RegisterResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Register not implemented")
}
func (UnimplementedAuthServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
}
func (UnimplementedAuthServer) IsAdmin(context.Context, *IsAdminRequest) (*IsAdminResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method IsAdmin not implemented")
}
func (UnimplementedAuthServer) mustEmbedUnimplementedAuthServer() {}
// UnsafeAuthServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AuthServer will
// result in compilation errors.
type UnsafeAuthServer interface {
mustEmbedUnimplementedAuthServer()
}
func RegisterAuthServer(s grpc.ServiceRegistrar, srv AuthServer) {
s.RegisterService(&Auth_ServiceDesc, srv)
}
func _Auth_Register_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RegisterRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthServer).Register(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Auth_Register_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServer).Register(ctx, req.(*RegisterRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Auth_Login_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LoginRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthServer).Login(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Auth_Login_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServer).Login(ctx, req.(*LoginRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Auth_IsAdmin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(IsAdminRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthServer).IsAdmin(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Auth_IsAdmin_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServer).IsAdmin(ctx, req.(*IsAdminRequest))
}
return interceptor(ctx, in, info, handler)
}
// Auth_ServiceDesc is the grpc.ServiceDesc for Auth service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Auth_ServiceDesc = grpc.ServiceDesc{
ServiceName: "auth.Auth",
HandlerType: (*AuthServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Register",
Handler: _Auth_Register_Handler,
},
{
MethodName: "Login",
Handler: _Auth_Login_Handler,
},
{
MethodName: "IsAdmin",
Handler: _Auth_IsAdmin_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "apu/v1/apu.proto",
}

17
go.mod Normal file
View File

@ -0,0 +1,17 @@
module git.amok.space/yevhen/apu-protos.git
go 1.22
require (
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1
google.golang.org/grpc v1.61.0
google.golang.org/protobuf v1.32.0
)
require (
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect
)

23
go.sum Normal file
View File

@ -0,0 +1,23 @@
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1 h1:u0olL4yf2p7Tl5jfsAK5keaFi+JFJuv1CDHrbiXkxkk=
buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1/go.mod h1:tiTMKD8j6Pd/D2WzREoweufjzaJKHZg35f/VGcZ2v3I=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 h1:FSL3lRCkhaPFxqi0s9o+V4UI2WTzAVOvkgbd4kVV4Wg=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014/go.mod h1:SaPjaZGWb0lPqs6Ittu0spdfrOArqji4ZdeP5IC/9N4=
google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0=
google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=