feat(epic2): Implement core authentication and authorization services

- Implement Audit Service (2.5)
  - gRPC server with Record and Query operations
  - Database persistence with audit schema
  - Service registry integration
  - Entry point: cmd/audit-service

- Implement Identity Service (2.2)
  - User CRUD operations
  - Password hashing with argon2id
  - Email verification and password reset flows
  - Entry point: cmd/identity-service
  - Fix package naming conflicts in user_service.go

- Implement Auth Service (2.1)
  - JWT token generation and validation
  - Login, RefreshToken, ValidateToken, Logout RPCs
  - Integration with Identity Service
  - Entry point: cmd/auth-service
  - Note: RefreshToken entity needs Ent generation

- Implement Authz Service (2.3, 2.4)
  - Permission checking and authorization
  - User roles and permissions retrieval
  - RBAC-based authorization
  - Entry point: cmd/authz-service

- Implement gRPC clients for all services
  - Auth, Identity, Authz, and Audit clients
  - Service discovery integration
  - Full gRPC communication

- Add service configurations to config/default.yaml
- Create SUMMARY.md with implementation details and testing instructions
- Fix compilation errors in Identity Service (password package conflicts)
- All services build successfully and tests pass
This commit is contained in:
2025-11-06 20:07:20 +01:00
parent da7a4e3703
commit b1b895e818
91 changed files with 19502 additions and 375 deletions

View File

@@ -0,0 +1,486 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.10
// protoc v6.30.2
// source: audit.proto
package auditv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
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)
)
// AuditLogEntry represents an audit log entry.
type AuditLogEntry struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Action string `protobuf:"bytes,2,opt,name=action,proto3" json:"action,omitempty"` // e.g., "user.create", "user.update"
Resource string `protobuf:"bytes,3,opt,name=resource,proto3" json:"resource,omitempty"` // e.g., "user", "role"
ResourceId string `protobuf:"bytes,4,opt,name=resource_id,json=resourceId,proto3" json:"resource_id,omitempty"`
IpAddress string `protobuf:"bytes,5,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"`
UserAgent string `protobuf:"bytes,6,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"`
Metadata map[string]string `protobuf:"bytes,7,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
Timestamp int64 `protobuf:"varint,8,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AuditLogEntry) Reset() {
*x = AuditLogEntry{}
mi := &file_audit_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AuditLogEntry) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AuditLogEntry) ProtoMessage() {}
func (x *AuditLogEntry) ProtoReflect() protoreflect.Message {
mi := &file_audit_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AuditLogEntry.ProtoReflect.Descriptor instead.
func (*AuditLogEntry) Descriptor() ([]byte, []int) {
return file_audit_proto_rawDescGZIP(), []int{0}
}
func (x *AuditLogEntry) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *AuditLogEntry) GetAction() string {
if x != nil {
return x.Action
}
return ""
}
func (x *AuditLogEntry) GetResource() string {
if x != nil {
return x.Resource
}
return ""
}
func (x *AuditLogEntry) GetResourceId() string {
if x != nil {
return x.ResourceId
}
return ""
}
func (x *AuditLogEntry) GetIpAddress() string {
if x != nil {
return x.IpAddress
}
return ""
}
func (x *AuditLogEntry) GetUserAgent() string {
if x != nil {
return x.UserAgent
}
return ""
}
func (x *AuditLogEntry) GetMetadata() map[string]string {
if x != nil {
return x.Metadata
}
return nil
}
func (x *AuditLogEntry) GetTimestamp() int64 {
if x != nil {
return x.Timestamp
}
return 0
}
// RecordRequest contains an audit log entry to record.
type RecordRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Entry *AuditLogEntry `protobuf:"bytes,1,opt,name=entry,proto3" json:"entry,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RecordRequest) Reset() {
*x = RecordRequest{}
mi := &file_audit_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RecordRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RecordRequest) ProtoMessage() {}
func (x *RecordRequest) ProtoReflect() protoreflect.Message {
mi := &file_audit_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RecordRequest.ProtoReflect.Descriptor instead.
func (*RecordRequest) Descriptor() ([]byte, []int) {
return file_audit_proto_rawDescGZIP(), []int{1}
}
func (x *RecordRequest) GetEntry() *AuditLogEntry {
if x != nil {
return x.Entry
}
return nil
}
// RecordResponse indicates success.
type RecordResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` // Audit log entry ID
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RecordResponse) Reset() {
*x = RecordResponse{}
mi := &file_audit_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RecordResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RecordResponse) ProtoMessage() {}
func (x *RecordResponse) ProtoReflect() protoreflect.Message {
mi := &file_audit_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RecordResponse.ProtoReflect.Descriptor instead.
func (*RecordResponse) Descriptor() ([]byte, []int) {
return file_audit_proto_rawDescGZIP(), []int{2}
}
func (x *RecordResponse) GetSuccess() bool {
if x != nil {
return x.Success
}
return false
}
func (x *RecordResponse) GetId() string {
if x != nil {
return x.Id
}
return ""
}
// QueryRequest contains filters for querying audit logs.
type QueryRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId *string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3,oneof" json:"user_id,omitempty"`
Action *string `protobuf:"bytes,2,opt,name=action,proto3,oneof" json:"action,omitempty"`
Resource *string `protobuf:"bytes,3,opt,name=resource,proto3,oneof" json:"resource,omitempty"`
ResourceId *string `protobuf:"bytes,4,opt,name=resource_id,json=resourceId,proto3,oneof" json:"resource_id,omitempty"`
StartTime *int64 `protobuf:"varint,5,opt,name=start_time,json=startTime,proto3,oneof" json:"start_time,omitempty"`
EndTime *int64 `protobuf:"varint,6,opt,name=end_time,json=endTime,proto3,oneof" json:"end_time,omitempty"`
Limit int32 `protobuf:"varint,7,opt,name=limit,proto3" json:"limit,omitempty"` // Max number of results
Offset int32 `protobuf:"varint,8,opt,name=offset,proto3" json:"offset,omitempty"` // Pagination offset
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *QueryRequest) Reset() {
*x = QueryRequest{}
mi := &file_audit_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *QueryRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*QueryRequest) ProtoMessage() {}
func (x *QueryRequest) ProtoReflect() protoreflect.Message {
mi := &file_audit_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use QueryRequest.ProtoReflect.Descriptor instead.
func (*QueryRequest) Descriptor() ([]byte, []int) {
return file_audit_proto_rawDescGZIP(), []int{3}
}
func (x *QueryRequest) GetUserId() string {
if x != nil && x.UserId != nil {
return *x.UserId
}
return ""
}
func (x *QueryRequest) GetAction() string {
if x != nil && x.Action != nil {
return *x.Action
}
return ""
}
func (x *QueryRequest) GetResource() string {
if x != nil && x.Resource != nil {
return *x.Resource
}
return ""
}
func (x *QueryRequest) GetResourceId() string {
if x != nil && x.ResourceId != nil {
return *x.ResourceId
}
return ""
}
func (x *QueryRequest) GetStartTime() int64 {
if x != nil && x.StartTime != nil {
return *x.StartTime
}
return 0
}
func (x *QueryRequest) GetEndTime() int64 {
if x != nil && x.EndTime != nil {
return *x.EndTime
}
return 0
}
func (x *QueryRequest) GetLimit() int32 {
if x != nil {
return x.Limit
}
return 0
}
func (x *QueryRequest) GetOffset() int32 {
if x != nil {
return x.Offset
}
return 0
}
// QueryResponse contains audit log entries.
type QueryResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Entries []*AuditLogEntry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
Total int32 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"` // Total number of matching entries
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *QueryResponse) Reset() {
*x = QueryResponse{}
mi := &file_audit_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *QueryResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*QueryResponse) ProtoMessage() {}
func (x *QueryResponse) ProtoReflect() protoreflect.Message {
mi := &file_audit_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use QueryResponse.ProtoReflect.Descriptor instead.
func (*QueryResponse) Descriptor() ([]byte, []int) {
return file_audit_proto_rawDescGZIP(), []int{4}
}
func (x *QueryResponse) GetEntries() []*AuditLogEntry {
if x != nil {
return x.Entries
}
return nil
}
func (x *QueryResponse) GetTotal() int32 {
if x != nil {
return x.Total
}
return 0
}
var File_audit_proto protoreflect.FileDescriptor
const file_audit_proto_rawDesc = "" +
"\n" +
"\vaudit.proto\x12\baudit.v1\"\xd9\x02\n" +
"\rAuditLogEntry\x12\x17\n" +
"\auser_id\x18\x01 \x01(\tR\x06userId\x12\x16\n" +
"\x06action\x18\x02 \x01(\tR\x06action\x12\x1a\n" +
"\bresource\x18\x03 \x01(\tR\bresource\x12\x1f\n" +
"\vresource_id\x18\x04 \x01(\tR\n" +
"resourceId\x12\x1d\n" +
"\n" +
"ip_address\x18\x05 \x01(\tR\tipAddress\x12\x1d\n" +
"\n" +
"user_agent\x18\x06 \x01(\tR\tuserAgent\x12A\n" +
"\bmetadata\x18\a \x03(\v2%.audit.v1.AuditLogEntry.MetadataEntryR\bmetadata\x12\x1c\n" +
"\ttimestamp\x18\b \x01(\x03R\ttimestamp\x1a;\n" +
"\rMetadataEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\">\n" +
"\rRecordRequest\x12-\n" +
"\x05entry\x18\x01 \x01(\v2\x17.audit.v1.AuditLogEntryR\x05entry\":\n" +
"\x0eRecordResponse\x12\x18\n" +
"\asuccess\x18\x01 \x01(\bR\asuccess\x12\x0e\n" +
"\x02id\x18\x02 \x01(\tR\x02id\"\xd2\x02\n" +
"\fQueryRequest\x12\x1c\n" +
"\auser_id\x18\x01 \x01(\tH\x00R\x06userId\x88\x01\x01\x12\x1b\n" +
"\x06action\x18\x02 \x01(\tH\x01R\x06action\x88\x01\x01\x12\x1f\n" +
"\bresource\x18\x03 \x01(\tH\x02R\bresource\x88\x01\x01\x12$\n" +
"\vresource_id\x18\x04 \x01(\tH\x03R\n" +
"resourceId\x88\x01\x01\x12\"\n" +
"\n" +
"start_time\x18\x05 \x01(\x03H\x04R\tstartTime\x88\x01\x01\x12\x1e\n" +
"\bend_time\x18\x06 \x01(\x03H\x05R\aendTime\x88\x01\x01\x12\x14\n" +
"\x05limit\x18\a \x01(\x05R\x05limit\x12\x16\n" +
"\x06offset\x18\b \x01(\x05R\x06offsetB\n" +
"\n" +
"\b_user_idB\t\n" +
"\a_actionB\v\n" +
"\t_resourceB\x0e\n" +
"\f_resource_idB\r\n" +
"\v_start_timeB\v\n" +
"\t_end_time\"X\n" +
"\rQueryResponse\x121\n" +
"\aentries\x18\x01 \x03(\v2\x17.audit.v1.AuditLogEntryR\aentries\x12\x14\n" +
"\x05total\x18\x02 \x01(\x05R\x05total2\x85\x01\n" +
"\fAuditService\x12;\n" +
"\x06Record\x12\x17.audit.v1.RecordRequest\x1a\x18.audit.v1.RecordResponse\x128\n" +
"\x05Query\x12\x16.audit.v1.QueryRequest\x1a\x17.audit.v1.QueryResponseBGZEgit.dcentral.systems/toolz/goplt/api/proto/generated/audit/v1;auditv1b\x06proto3"
var (
file_audit_proto_rawDescOnce sync.Once
file_audit_proto_rawDescData []byte
)
func file_audit_proto_rawDescGZIP() []byte {
file_audit_proto_rawDescOnce.Do(func() {
file_audit_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_audit_proto_rawDesc), len(file_audit_proto_rawDesc)))
})
return file_audit_proto_rawDescData
}
var file_audit_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
var file_audit_proto_goTypes = []any{
(*AuditLogEntry)(nil), // 0: audit.v1.AuditLogEntry
(*RecordRequest)(nil), // 1: audit.v1.RecordRequest
(*RecordResponse)(nil), // 2: audit.v1.RecordResponse
(*QueryRequest)(nil), // 3: audit.v1.QueryRequest
(*QueryResponse)(nil), // 4: audit.v1.QueryResponse
nil, // 5: audit.v1.AuditLogEntry.MetadataEntry
}
var file_audit_proto_depIdxs = []int32{
5, // 0: audit.v1.AuditLogEntry.metadata:type_name -> audit.v1.AuditLogEntry.MetadataEntry
0, // 1: audit.v1.RecordRequest.entry:type_name -> audit.v1.AuditLogEntry
0, // 2: audit.v1.QueryResponse.entries:type_name -> audit.v1.AuditLogEntry
1, // 3: audit.v1.AuditService.Record:input_type -> audit.v1.RecordRequest
3, // 4: audit.v1.AuditService.Query:input_type -> audit.v1.QueryRequest
2, // 5: audit.v1.AuditService.Record:output_type -> audit.v1.RecordResponse
4, // 6: audit.v1.AuditService.Query:output_type -> audit.v1.QueryResponse
5, // [5:7] is the sub-list for method output_type
3, // [3:5] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_audit_proto_init() }
func file_audit_proto_init() {
if File_audit_proto != nil {
return
}
file_audit_proto_msgTypes[3].OneofWrappers = []any{}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_audit_proto_rawDesc), len(file_audit_proto_rawDesc)),
NumEnums: 0,
NumMessages: 6,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_audit_proto_goTypes,
DependencyIndexes: file_audit_proto_depIdxs,
MessageInfos: file_audit_proto_msgTypes,
}.Build()
File_audit_proto = out.File
file_audit_proto_goTypes = nil
file_audit_proto_depIdxs = nil
}

View File

@@ -0,0 +1,167 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.2
// source: audit.proto
package auditv1
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
AuditService_Record_FullMethodName = "/audit.v1.AuditService/Record"
AuditService_Query_FullMethodName = "/audit.v1.AuditService/Query"
)
// AuditServiceClient is the client API for AuditService 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.
//
// AuditService provides audit logging operations.
type AuditServiceClient interface {
// Record records an audit log entry.
Record(ctx context.Context, in *RecordRequest, opts ...grpc.CallOption) (*RecordResponse, error)
// Query queries audit logs based on filters.
Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error)
}
type auditServiceClient struct {
cc grpc.ClientConnInterface
}
func NewAuditServiceClient(cc grpc.ClientConnInterface) AuditServiceClient {
return &auditServiceClient{cc}
}
func (c *auditServiceClient) Record(ctx context.Context, in *RecordRequest, opts ...grpc.CallOption) (*RecordResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RecordResponse)
err := c.cc.Invoke(ctx, AuditService_Record_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *auditServiceClient) Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(QueryResponse)
err := c.cc.Invoke(ctx, AuditService_Query_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// AuditServiceServer is the server API for AuditService service.
// All implementations must embed UnimplementedAuditServiceServer
// for forward compatibility.
//
// AuditService provides audit logging operations.
type AuditServiceServer interface {
// Record records an audit log entry.
Record(context.Context, *RecordRequest) (*RecordResponse, error)
// Query queries audit logs based on filters.
Query(context.Context, *QueryRequest) (*QueryResponse, error)
mustEmbedUnimplementedAuditServiceServer()
}
// UnimplementedAuditServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedAuditServiceServer struct{}
func (UnimplementedAuditServiceServer) Record(context.Context, *RecordRequest) (*RecordResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Record not implemented")
}
func (UnimplementedAuditServiceServer) Query(context.Context, *QueryRequest) (*QueryResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Query not implemented")
}
func (UnimplementedAuditServiceServer) mustEmbedUnimplementedAuditServiceServer() {}
func (UnimplementedAuditServiceServer) testEmbeddedByValue() {}
// UnsafeAuditServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AuditServiceServer will
// result in compilation errors.
type UnsafeAuditServiceServer interface {
mustEmbedUnimplementedAuditServiceServer()
}
func RegisterAuditServiceServer(s grpc.ServiceRegistrar, srv AuditServiceServer) {
// If the following call pancis, it indicates UnimplementedAuditServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&AuditService_ServiceDesc, srv)
}
func _AuditService_Record_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RecordRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuditServiceServer).Record(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuditService_Record_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuditServiceServer).Record(ctx, req.(*RecordRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AuditService_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(QueryRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuditServiceServer).Query(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuditService_Query_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuditServiceServer).Query(ctx, req.(*QueryRequest))
}
return interceptor(ctx, in, info, handler)
}
// AuditService_ServiceDesc is the grpc.ServiceDesc for AuditService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var AuditService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "audit.v1.AuditService",
HandlerType: (*AuditServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Record",
Handler: _AuditService_Record_Handler,
},
{
MethodName: "Query",
Handler: _AuditService_Query_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "audit.proto",
}

View File

@@ -0,0 +1,568 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.10
// protoc v6.30.2
// source: auth.proto
package authv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
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)
)
// LoginRequest contains login credentials.
type LoginRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *LoginRequest) Reset() {
*x = LoginRequest{}
mi := &file_auth_proto_msgTypes[0]
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_auth_proto_msgTypes[0]
if 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_auth_proto_rawDescGZIP(), []int{0}
}
func (x *LoginRequest) GetEmail() string {
if x != nil {
return x.Email
}
return ""
}
func (x *LoginRequest) GetPassword() string {
if x != nil {
return x.Password
}
return ""
}
// LoginResponse contains authentication tokens.
type LoginResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`
ExpiresIn int64 `protobuf:"varint,3,opt,name=expires_in,json=expiresIn,proto3" json:"expires_in,omitempty"` // seconds
TokenType string `protobuf:"bytes,4,opt,name=token_type,json=tokenType,proto3" json:"token_type,omitempty"` // "Bearer"
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *LoginResponse) Reset() {
*x = LoginResponse{}
mi := &file_auth_proto_msgTypes[1]
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_auth_proto_msgTypes[1]
if 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_auth_proto_rawDescGZIP(), []int{1}
}
func (x *LoginResponse) GetAccessToken() string {
if x != nil {
return x.AccessToken
}
return ""
}
func (x *LoginResponse) GetRefreshToken() string {
if x != nil {
return x.RefreshToken
}
return ""
}
func (x *LoginResponse) GetExpiresIn() int64 {
if x != nil {
return x.ExpiresIn
}
return 0
}
func (x *LoginResponse) GetTokenType() string {
if x != nil {
return x.TokenType
}
return ""
}
// RefreshTokenRequest contains a refresh token.
type RefreshTokenRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RefreshTokenRequest) Reset() {
*x = RefreshTokenRequest{}
mi := &file_auth_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RefreshTokenRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RefreshTokenRequest) ProtoMessage() {}
func (x *RefreshTokenRequest) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RefreshTokenRequest.ProtoReflect.Descriptor instead.
func (*RefreshTokenRequest) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{2}
}
func (x *RefreshTokenRequest) GetRefreshToken() string {
if x != nil {
return x.RefreshToken
}
return ""
}
// RefreshTokenResponse contains new authentication tokens.
type RefreshTokenResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
RefreshToken string `protobuf:"bytes,2,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`
ExpiresIn int64 `protobuf:"varint,3,opt,name=expires_in,json=expiresIn,proto3" json:"expires_in,omitempty"` // seconds
TokenType string `protobuf:"bytes,4,opt,name=token_type,json=tokenType,proto3" json:"token_type,omitempty"` // "Bearer"
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RefreshTokenResponse) Reset() {
*x = RefreshTokenResponse{}
mi := &file_auth_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RefreshTokenResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RefreshTokenResponse) ProtoMessage() {}
func (x *RefreshTokenResponse) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RefreshTokenResponse.ProtoReflect.Descriptor instead.
func (*RefreshTokenResponse) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{3}
}
func (x *RefreshTokenResponse) GetAccessToken() string {
if x != nil {
return x.AccessToken
}
return ""
}
func (x *RefreshTokenResponse) GetRefreshToken() string {
if x != nil {
return x.RefreshToken
}
return ""
}
func (x *RefreshTokenResponse) GetExpiresIn() int64 {
if x != nil {
return x.ExpiresIn
}
return 0
}
func (x *RefreshTokenResponse) GetTokenType() string {
if x != nil {
return x.TokenType
}
return ""
}
// ValidateTokenRequest contains a JWT token to validate.
type ValidateTokenRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ValidateTokenRequest) Reset() {
*x = ValidateTokenRequest{}
mi := &file_auth_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ValidateTokenRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ValidateTokenRequest) ProtoMessage() {}
func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ValidateTokenRequest.ProtoReflect.Descriptor instead.
func (*ValidateTokenRequest) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{4}
}
func (x *ValidateTokenRequest) GetToken() string {
if x != nil {
return x.Token
}
return ""
}
// ValidateTokenResponse contains token claims.
type ValidateTokenResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
Roles []string `protobuf:"bytes,3,rep,name=roles,proto3" json:"roles,omitempty"`
ExpiresAt int64 `protobuf:"varint,4,opt,name=expires_at,json=expiresAt,proto3" json:"expires_at,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ValidateTokenResponse) Reset() {
*x = ValidateTokenResponse{}
mi := &file_auth_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ValidateTokenResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ValidateTokenResponse) ProtoMessage() {}
func (x *ValidateTokenResponse) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ValidateTokenResponse.ProtoReflect.Descriptor instead.
func (*ValidateTokenResponse) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{5}
}
func (x *ValidateTokenResponse) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *ValidateTokenResponse) GetEmail() string {
if x != nil {
return x.Email
}
return ""
}
func (x *ValidateTokenResponse) GetRoles() []string {
if x != nil {
return x.Roles
}
return nil
}
func (x *ValidateTokenResponse) GetExpiresAt() int64 {
if x != nil {
return x.ExpiresAt
}
return 0
}
// LogoutRequest contains a refresh token to invalidate.
type LogoutRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
RefreshToken string `protobuf:"bytes,1,opt,name=refresh_token,json=refreshToken,proto3" json:"refresh_token,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *LogoutRequest) Reset() {
*x = LogoutRequest{}
mi := &file_auth_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *LogoutRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LogoutRequest) ProtoMessage() {}
func (x *LogoutRequest) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LogoutRequest.ProtoReflect.Descriptor instead.
func (*LogoutRequest) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{6}
}
func (x *LogoutRequest) GetRefreshToken() string {
if x != nil {
return x.RefreshToken
}
return ""
}
// LogoutResponse indicates success.
type LogoutResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *LogoutResponse) Reset() {
*x = LogoutResponse{}
mi := &file_auth_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *LogoutResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*LogoutResponse) ProtoMessage() {}
func (x *LogoutResponse) ProtoReflect() protoreflect.Message {
mi := &file_auth_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use LogoutResponse.ProtoReflect.Descriptor instead.
func (*LogoutResponse) Descriptor() ([]byte, []int) {
return file_auth_proto_rawDescGZIP(), []int{7}
}
func (x *LogoutResponse) GetSuccess() bool {
if x != nil {
return x.Success
}
return false
}
var File_auth_proto protoreflect.FileDescriptor
const file_auth_proto_rawDesc = "" +
"\n" +
"\n" +
"auth.proto\x12\aauth.v1\"@\n" +
"\fLoginRequest\x12\x14\n" +
"\x05email\x18\x01 \x01(\tR\x05email\x12\x1a\n" +
"\bpassword\x18\x02 \x01(\tR\bpassword\"\x95\x01\n" +
"\rLoginResponse\x12!\n" +
"\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12#\n" +
"\rrefresh_token\x18\x02 \x01(\tR\frefreshToken\x12\x1d\n" +
"\n" +
"expires_in\x18\x03 \x01(\x03R\texpiresIn\x12\x1d\n" +
"\n" +
"token_type\x18\x04 \x01(\tR\ttokenType\":\n" +
"\x13RefreshTokenRequest\x12#\n" +
"\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\"\x9c\x01\n" +
"\x14RefreshTokenResponse\x12!\n" +
"\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12#\n" +
"\rrefresh_token\x18\x02 \x01(\tR\frefreshToken\x12\x1d\n" +
"\n" +
"expires_in\x18\x03 \x01(\x03R\texpiresIn\x12\x1d\n" +
"\n" +
"token_type\x18\x04 \x01(\tR\ttokenType\",\n" +
"\x14ValidateTokenRequest\x12\x14\n" +
"\x05token\x18\x01 \x01(\tR\x05token\"{\n" +
"\x15ValidateTokenResponse\x12\x17\n" +
"\auser_id\x18\x01 \x01(\tR\x06userId\x12\x14\n" +
"\x05email\x18\x02 \x01(\tR\x05email\x12\x14\n" +
"\x05roles\x18\x03 \x03(\tR\x05roles\x12\x1d\n" +
"\n" +
"expires_at\x18\x04 \x01(\x03R\texpiresAt\"4\n" +
"\rLogoutRequest\x12#\n" +
"\rrefresh_token\x18\x01 \x01(\tR\frefreshToken\"*\n" +
"\x0eLogoutResponse\x12\x18\n" +
"\asuccess\x18\x01 \x01(\bR\asuccess2\x9d\x02\n" +
"\vAuthService\x126\n" +
"\x05Login\x12\x15.auth.v1.LoginRequest\x1a\x16.auth.v1.LoginResponse\x12K\n" +
"\fRefreshToken\x12\x1c.auth.v1.RefreshTokenRequest\x1a\x1d.auth.v1.RefreshTokenResponse\x12N\n" +
"\rValidateToken\x12\x1d.auth.v1.ValidateTokenRequest\x1a\x1e.auth.v1.ValidateTokenResponse\x129\n" +
"\x06Logout\x12\x16.auth.v1.LogoutRequest\x1a\x17.auth.v1.LogoutResponseBEZCgit.dcentral.systems/toolz/goplt/api/proto/generated/auth/v1;authv1b\x06proto3"
var (
file_auth_proto_rawDescOnce sync.Once
file_auth_proto_rawDescData []byte
)
func file_auth_proto_rawDescGZIP() []byte {
file_auth_proto_rawDescOnce.Do(func() {
file_auth_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_auth_proto_rawDesc), len(file_auth_proto_rawDesc)))
})
return file_auth_proto_rawDescData
}
var file_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
var file_auth_proto_goTypes = []any{
(*LoginRequest)(nil), // 0: auth.v1.LoginRequest
(*LoginResponse)(nil), // 1: auth.v1.LoginResponse
(*RefreshTokenRequest)(nil), // 2: auth.v1.RefreshTokenRequest
(*RefreshTokenResponse)(nil), // 3: auth.v1.RefreshTokenResponse
(*ValidateTokenRequest)(nil), // 4: auth.v1.ValidateTokenRequest
(*ValidateTokenResponse)(nil), // 5: auth.v1.ValidateTokenResponse
(*LogoutRequest)(nil), // 6: auth.v1.LogoutRequest
(*LogoutResponse)(nil), // 7: auth.v1.LogoutResponse
}
var file_auth_proto_depIdxs = []int32{
0, // 0: auth.v1.AuthService.Login:input_type -> auth.v1.LoginRequest
2, // 1: auth.v1.AuthService.RefreshToken:input_type -> auth.v1.RefreshTokenRequest
4, // 2: auth.v1.AuthService.ValidateToken:input_type -> auth.v1.ValidateTokenRequest
6, // 3: auth.v1.AuthService.Logout:input_type -> auth.v1.LogoutRequest
1, // 4: auth.v1.AuthService.Login:output_type -> auth.v1.LoginResponse
3, // 5: auth.v1.AuthService.RefreshToken:output_type -> auth.v1.RefreshTokenResponse
5, // 6: auth.v1.AuthService.ValidateToken:output_type -> auth.v1.ValidateTokenResponse
7, // 7: auth.v1.AuthService.Logout:output_type -> auth.v1.LogoutResponse
4, // [4:8] is the sub-list for method output_type
0, // [0:4] 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_auth_proto_init() }
func file_auth_proto_init() {
if File_auth_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_auth_proto_rawDesc), len(file_auth_proto_rawDesc)),
NumEnums: 0,
NumMessages: 8,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_auth_proto_goTypes,
DependencyIndexes: file_auth_proto_depIdxs,
MessageInfos: file_auth_proto_msgTypes,
}.Build()
File_auth_proto = out.File
file_auth_proto_goTypes = nil
file_auth_proto_depIdxs = nil
}

View File

@@ -0,0 +1,247 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.2
// source: auth.proto
package authv1
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
AuthService_Login_FullMethodName = "/auth.v1.AuthService/Login"
AuthService_RefreshToken_FullMethodName = "/auth.v1.AuthService/RefreshToken"
AuthService_ValidateToken_FullMethodName = "/auth.v1.AuthService/ValidateToken"
AuthService_Logout_FullMethodName = "/auth.v1.AuthService/Logout"
)
// AuthServiceClient is the client API for AuthService 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.
//
// AuthService provides authentication operations.
type AuthServiceClient interface {
// Login authenticates a user and returns access and refresh tokens.
Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error)
// RefreshToken refreshes an access token using a refresh token.
RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error)
// ValidateToken validates a JWT token and returns the token claims.
ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*ValidateTokenResponse, error)
// Logout invalidates a refresh token.
Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error)
}
type authServiceClient struct {
cc grpc.ClientConnInterface
}
func NewAuthServiceClient(cc grpc.ClientConnInterface) AuthServiceClient {
return &authServiceClient{cc}
}
func (c *authServiceClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(LoginResponse)
err := c.cc.Invoke(ctx, AuthService_Login_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authServiceClient) RefreshToken(ctx context.Context, in *RefreshTokenRequest, opts ...grpc.CallOption) (*RefreshTokenResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RefreshTokenResponse)
err := c.cc.Invoke(ctx, AuthService_RefreshToken_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authServiceClient) ValidateToken(ctx context.Context, in *ValidateTokenRequest, opts ...grpc.CallOption) (*ValidateTokenResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ValidateTokenResponse)
err := c.cc.Invoke(ctx, AuthService_ValidateToken_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authServiceClient) Logout(ctx context.Context, in *LogoutRequest, opts ...grpc.CallOption) (*LogoutResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(LogoutResponse)
err := c.cc.Invoke(ctx, AuthService_Logout_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// AuthServiceServer is the server API for AuthService service.
// All implementations must embed UnimplementedAuthServiceServer
// for forward compatibility.
//
// AuthService provides authentication operations.
type AuthServiceServer interface {
// Login authenticates a user and returns access and refresh tokens.
Login(context.Context, *LoginRequest) (*LoginResponse, error)
// RefreshToken refreshes an access token using a refresh token.
RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error)
// ValidateToken validates a JWT token and returns the token claims.
ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error)
// Logout invalidates a refresh token.
Logout(context.Context, *LogoutRequest) (*LogoutResponse, error)
mustEmbedUnimplementedAuthServiceServer()
}
// UnimplementedAuthServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedAuthServiceServer struct{}
func (UnimplementedAuthServiceServer) Login(context.Context, *LoginRequest) (*LoginResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Login not implemented")
}
func (UnimplementedAuthServiceServer) RefreshToken(context.Context, *RefreshTokenRequest) (*RefreshTokenResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RefreshToken not implemented")
}
func (UnimplementedAuthServiceServer) ValidateToken(context.Context, *ValidateTokenRequest) (*ValidateTokenResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ValidateToken not implemented")
}
func (UnimplementedAuthServiceServer) Logout(context.Context, *LogoutRequest) (*LogoutResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Logout not implemented")
}
func (UnimplementedAuthServiceServer) mustEmbedUnimplementedAuthServiceServer() {}
func (UnimplementedAuthServiceServer) testEmbeddedByValue() {}
// UnsafeAuthServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AuthServiceServer will
// result in compilation errors.
type UnsafeAuthServiceServer interface {
mustEmbedUnimplementedAuthServiceServer()
}
func RegisterAuthServiceServer(s grpc.ServiceRegistrar, srv AuthServiceServer) {
// If the following call pancis, it indicates UnimplementedAuthServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&AuthService_ServiceDesc, srv)
}
func _AuthService_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.(AuthServiceServer).Login(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthService_Login_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).Login(ctx, req.(*LoginRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AuthService_RefreshToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RefreshTokenRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthServiceServer).RefreshToken(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthService_RefreshToken_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).RefreshToken(ctx, req.(*RefreshTokenRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AuthService_ValidateToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ValidateTokenRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthServiceServer).ValidateToken(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthService_ValidateToken_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).ValidateToken(ctx, req.(*ValidateTokenRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AuthService_Logout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(LogoutRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthServiceServer).Logout(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthService_Logout_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthServiceServer).Logout(ctx, req.(*LogoutRequest))
}
return interceptor(ctx, in, info, handler)
}
// AuthService_ServiceDesc is the grpc.ServiceDesc for AuthService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var AuthService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "auth.v1.AuthService",
HandlerType: (*AuthServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Login",
Handler: _AuthService_Login_Handler,
},
{
MethodName: "RefreshToken",
Handler: _AuthService_RefreshToken_Handler,
},
{
MethodName: "ValidateToken",
Handler: _AuthService_ValidateToken_Handler,
},
{
MethodName: "Logout",
Handler: _AuthService_Logout_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "auth.proto",
}

View File

@@ -0,0 +1,658 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.36.10
// protoc v6.30.2
// source: authz.proto
package authzv1
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
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)
)
// Permission represents a permission in the system.
type Permission struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"`
Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Permission) Reset() {
*x = Permission{}
mi := &file_authz_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Permission) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Permission) ProtoMessage() {}
func (x *Permission) ProtoReflect() protoreflect.Message {
mi := &file_authz_proto_msgTypes[0]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Permission.ProtoReflect.Descriptor instead.
func (*Permission) Descriptor() ([]byte, []int) {
return file_authz_proto_rawDescGZIP(), []int{0}
}
func (x *Permission) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Permission) GetCode() string {
if x != nil {
return x.Code
}
return ""
}
func (x *Permission) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Permission) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
// Role represents a role in the system.
type Role struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
Permissions []string `protobuf:"bytes,4,rep,name=permissions,proto3" json:"permissions,omitempty"` // Permission codes
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *Role) Reset() {
*x = Role{}
mi := &file_authz_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *Role) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Role) ProtoMessage() {}
func (x *Role) ProtoReflect() protoreflect.Message {
mi := &file_authz_proto_msgTypes[1]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Role.ProtoReflect.Descriptor instead.
func (*Role) Descriptor() ([]byte, []int) {
return file_authz_proto_rawDescGZIP(), []int{1}
}
func (x *Role) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Role) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Role) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
func (x *Role) GetPermissions() []string {
if x != nil {
return x.Permissions
}
return nil
}
// AuthorizeRequest contains user ID and permission to check.
type AuthorizeRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Permission string `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AuthorizeRequest) Reset() {
*x = AuthorizeRequest{}
mi := &file_authz_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AuthorizeRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AuthorizeRequest) ProtoMessage() {}
func (x *AuthorizeRequest) ProtoReflect() protoreflect.Message {
mi := &file_authz_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AuthorizeRequest.ProtoReflect.Descriptor instead.
func (*AuthorizeRequest) Descriptor() ([]byte, []int) {
return file_authz_proto_rawDescGZIP(), []int{2}
}
func (x *AuthorizeRequest) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *AuthorizeRequest) GetPermission() string {
if x != nil {
return x.Permission
}
return ""
}
// AuthorizeResponse indicates authorization result.
type AuthorizeResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Authorized bool `protobuf:"varint,1,opt,name=authorized,proto3" json:"authorized,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AuthorizeResponse) Reset() {
*x = AuthorizeResponse{}
mi := &file_authz_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AuthorizeResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AuthorizeResponse) ProtoMessage() {}
func (x *AuthorizeResponse) ProtoReflect() protoreflect.Message {
mi := &file_authz_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AuthorizeResponse.ProtoReflect.Descriptor instead.
func (*AuthorizeResponse) Descriptor() ([]byte, []int) {
return file_authz_proto_rawDescGZIP(), []int{3}
}
func (x *AuthorizeResponse) GetAuthorized() bool {
if x != nil {
return x.Authorized
}
return false
}
func (x *AuthorizeResponse) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
// HasPermissionRequest contains user ID and permission to check.
type HasPermissionRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Permission string `protobuf:"bytes,2,opt,name=permission,proto3" json:"permission,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *HasPermissionRequest) Reset() {
*x = HasPermissionRequest{}
mi := &file_authz_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *HasPermissionRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HasPermissionRequest) ProtoMessage() {}
func (x *HasPermissionRequest) ProtoReflect() protoreflect.Message {
mi := &file_authz_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HasPermissionRequest.ProtoReflect.Descriptor instead.
func (*HasPermissionRequest) Descriptor() ([]byte, []int) {
return file_authz_proto_rawDescGZIP(), []int{4}
}
func (x *HasPermissionRequest) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *HasPermissionRequest) GetPermission() string {
if x != nil {
return x.Permission
}
return ""
}
// HasPermissionResponse indicates if the user has the permission.
type HasPermissionResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
HasPermission bool `protobuf:"varint,1,opt,name=has_permission,json=hasPermission,proto3" json:"has_permission,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *HasPermissionResponse) Reset() {
*x = HasPermissionResponse{}
mi := &file_authz_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *HasPermissionResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*HasPermissionResponse) ProtoMessage() {}
func (x *HasPermissionResponse) ProtoReflect() protoreflect.Message {
mi := &file_authz_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use HasPermissionResponse.ProtoReflect.Descriptor instead.
func (*HasPermissionResponse) Descriptor() ([]byte, []int) {
return file_authz_proto_rawDescGZIP(), []int{5}
}
func (x *HasPermissionResponse) GetHasPermission() bool {
if x != nil {
return x.HasPermission
}
return false
}
// GetUserPermissionsRequest contains a user ID.
type GetUserPermissionsRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserPermissionsRequest) Reset() {
*x = GetUserPermissionsRequest{}
mi := &file_authz_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserPermissionsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserPermissionsRequest) ProtoMessage() {}
func (x *GetUserPermissionsRequest) ProtoReflect() protoreflect.Message {
mi := &file_authz_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserPermissionsRequest.ProtoReflect.Descriptor instead.
func (*GetUserPermissionsRequest) Descriptor() ([]byte, []int) {
return file_authz_proto_rawDescGZIP(), []int{6}
}
func (x *GetUserPermissionsRequest) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
// GetUserPermissionsResponse contains all permissions for the user.
type GetUserPermissionsResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Permissions []*Permission `protobuf:"bytes,1,rep,name=permissions,proto3" json:"permissions,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserPermissionsResponse) Reset() {
*x = GetUserPermissionsResponse{}
mi := &file_authz_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserPermissionsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserPermissionsResponse) ProtoMessage() {}
func (x *GetUserPermissionsResponse) ProtoReflect() protoreflect.Message {
mi := &file_authz_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserPermissionsResponse.ProtoReflect.Descriptor instead.
func (*GetUserPermissionsResponse) Descriptor() ([]byte, []int) {
return file_authz_proto_rawDescGZIP(), []int{7}
}
func (x *GetUserPermissionsResponse) GetPermissions() []*Permission {
if x != nil {
return x.Permissions
}
return nil
}
// GetUserRolesRequest contains a user ID.
type GetUserRolesRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
UserId string `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserRolesRequest) Reset() {
*x = GetUserRolesRequest{}
mi := &file_authz_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserRolesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserRolesRequest) ProtoMessage() {}
func (x *GetUserRolesRequest) ProtoReflect() protoreflect.Message {
mi := &file_authz_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserRolesRequest.ProtoReflect.Descriptor instead.
func (*GetUserRolesRequest) Descriptor() ([]byte, []int) {
return file_authz_proto_rawDescGZIP(), []int{8}
}
func (x *GetUserRolesRequest) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
// GetUserRolesResponse contains all roles for the user.
type GetUserRolesResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Roles []*Role `protobuf:"bytes,1,rep,name=roles,proto3" json:"roles,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *GetUserRolesResponse) Reset() {
*x = GetUserRolesResponse{}
mi := &file_authz_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *GetUserRolesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetUserRolesResponse) ProtoMessage() {}
func (x *GetUserRolesResponse) ProtoReflect() protoreflect.Message {
mi := &file_authz_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetUserRolesResponse.ProtoReflect.Descriptor instead.
func (*GetUserRolesResponse) Descriptor() ([]byte, []int) {
return file_authz_proto_rawDescGZIP(), []int{9}
}
func (x *GetUserRolesResponse) GetRoles() []*Role {
if x != nil {
return x.Roles
}
return nil
}
var File_authz_proto protoreflect.FileDescriptor
const file_authz_proto_rawDesc = "" +
"\n" +
"\vauthz.proto\x12\bauthz.v1\"f\n" +
"\n" +
"Permission\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
"\x04code\x18\x02 \x01(\tR\x04code\x12\x12\n" +
"\x04name\x18\x03 \x01(\tR\x04name\x12 \n" +
"\vdescription\x18\x04 \x01(\tR\vdescription\"n\n" +
"\x04Role\x12\x0e\n" +
"\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" +
"\x04name\x18\x02 \x01(\tR\x04name\x12 \n" +
"\vdescription\x18\x03 \x01(\tR\vdescription\x12 \n" +
"\vpermissions\x18\x04 \x03(\tR\vpermissions\"K\n" +
"\x10AuthorizeRequest\x12\x17\n" +
"\auser_id\x18\x01 \x01(\tR\x06userId\x12\x1e\n" +
"\n" +
"permission\x18\x02 \x01(\tR\n" +
"permission\"M\n" +
"\x11AuthorizeResponse\x12\x1e\n" +
"\n" +
"authorized\x18\x01 \x01(\bR\n" +
"authorized\x12\x18\n" +
"\amessage\x18\x02 \x01(\tR\amessage\"O\n" +
"\x14HasPermissionRequest\x12\x17\n" +
"\auser_id\x18\x01 \x01(\tR\x06userId\x12\x1e\n" +
"\n" +
"permission\x18\x02 \x01(\tR\n" +
"permission\">\n" +
"\x15HasPermissionResponse\x12%\n" +
"\x0ehas_permission\x18\x01 \x01(\bR\rhasPermission\"4\n" +
"\x19GetUserPermissionsRequest\x12\x17\n" +
"\auser_id\x18\x01 \x01(\tR\x06userId\"T\n" +
"\x1aGetUserPermissionsResponse\x126\n" +
"\vpermissions\x18\x01 \x03(\v2\x14.authz.v1.PermissionR\vpermissions\".\n" +
"\x13GetUserRolesRequest\x12\x17\n" +
"\auser_id\x18\x01 \x01(\tR\x06userId\"<\n" +
"\x14GetUserRolesResponse\x12$\n" +
"\x05roles\x18\x01 \x03(\v2\x0e.authz.v1.RoleR\x05roles2\xd6\x02\n" +
"\fAuthzService\x12D\n" +
"\tAuthorize\x12\x1a.authz.v1.AuthorizeRequest\x1a\x1b.authz.v1.AuthorizeResponse\x12P\n" +
"\rHasPermission\x12\x1e.authz.v1.HasPermissionRequest\x1a\x1f.authz.v1.HasPermissionResponse\x12_\n" +
"\x12GetUserPermissions\x12#.authz.v1.GetUserPermissionsRequest\x1a$.authz.v1.GetUserPermissionsResponse\x12M\n" +
"\fGetUserRoles\x12\x1d.authz.v1.GetUserRolesRequest\x1a\x1e.authz.v1.GetUserRolesResponseBGZEgit.dcentral.systems/toolz/goplt/api/proto/generated/authz/v1;authzv1b\x06proto3"
var (
file_authz_proto_rawDescOnce sync.Once
file_authz_proto_rawDescData []byte
)
func file_authz_proto_rawDescGZIP() []byte {
file_authz_proto_rawDescOnce.Do(func() {
file_authz_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_authz_proto_rawDesc), len(file_authz_proto_rawDesc)))
})
return file_authz_proto_rawDescData
}
var file_authz_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
var file_authz_proto_goTypes = []any{
(*Permission)(nil), // 0: authz.v1.Permission
(*Role)(nil), // 1: authz.v1.Role
(*AuthorizeRequest)(nil), // 2: authz.v1.AuthorizeRequest
(*AuthorizeResponse)(nil), // 3: authz.v1.AuthorizeResponse
(*HasPermissionRequest)(nil), // 4: authz.v1.HasPermissionRequest
(*HasPermissionResponse)(nil), // 5: authz.v1.HasPermissionResponse
(*GetUserPermissionsRequest)(nil), // 6: authz.v1.GetUserPermissionsRequest
(*GetUserPermissionsResponse)(nil), // 7: authz.v1.GetUserPermissionsResponse
(*GetUserRolesRequest)(nil), // 8: authz.v1.GetUserRolesRequest
(*GetUserRolesResponse)(nil), // 9: authz.v1.GetUserRolesResponse
}
var file_authz_proto_depIdxs = []int32{
0, // 0: authz.v1.GetUserPermissionsResponse.permissions:type_name -> authz.v1.Permission
1, // 1: authz.v1.GetUserRolesResponse.roles:type_name -> authz.v1.Role
2, // 2: authz.v1.AuthzService.Authorize:input_type -> authz.v1.AuthorizeRequest
4, // 3: authz.v1.AuthzService.HasPermission:input_type -> authz.v1.HasPermissionRequest
6, // 4: authz.v1.AuthzService.GetUserPermissions:input_type -> authz.v1.GetUserPermissionsRequest
8, // 5: authz.v1.AuthzService.GetUserRoles:input_type -> authz.v1.GetUserRolesRequest
3, // 6: authz.v1.AuthzService.Authorize:output_type -> authz.v1.AuthorizeResponse
5, // 7: authz.v1.AuthzService.HasPermission:output_type -> authz.v1.HasPermissionResponse
7, // 8: authz.v1.AuthzService.GetUserPermissions:output_type -> authz.v1.GetUserPermissionsResponse
9, // 9: authz.v1.AuthzService.GetUserRoles:output_type -> authz.v1.GetUserRolesResponse
6, // [6:10] is the sub-list for method output_type
2, // [2:6] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_authz_proto_init() }
func file_authz_proto_init() {
if File_authz_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_authz_proto_rawDesc), len(file_authz_proto_rawDesc)),
NumEnums: 0,
NumMessages: 10,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_authz_proto_goTypes,
DependencyIndexes: file_authz_proto_depIdxs,
MessageInfos: file_authz_proto_msgTypes,
}.Build()
File_authz_proto = out.File
file_authz_proto_goTypes = nil
file_authz_proto_depIdxs = nil
}

View File

@@ -0,0 +1,247 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.2
// source: authz.proto
package authzv1
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
AuthzService_Authorize_FullMethodName = "/authz.v1.AuthzService/Authorize"
AuthzService_HasPermission_FullMethodName = "/authz.v1.AuthzService/HasPermission"
AuthzService_GetUserPermissions_FullMethodName = "/authz.v1.AuthzService/GetUserPermissions"
AuthzService_GetUserRoles_FullMethodName = "/authz.v1.AuthzService/GetUserRoles"
)
// AuthzServiceClient is the client API for AuthzService 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.
//
// AuthzService provides authorization operations.
type AuthzServiceClient interface {
// Authorize checks if a user has a specific permission and returns an error if not.
Authorize(ctx context.Context, in *AuthorizeRequest, opts ...grpc.CallOption) (*AuthorizeResponse, error)
// HasPermission checks if a user has a specific permission.
HasPermission(ctx context.Context, in *HasPermissionRequest, opts ...grpc.CallOption) (*HasPermissionResponse, error)
// GetUserPermissions returns all permissions for a user.
GetUserPermissions(ctx context.Context, in *GetUserPermissionsRequest, opts ...grpc.CallOption) (*GetUserPermissionsResponse, error)
// GetUserRoles returns all roles for a user.
GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...grpc.CallOption) (*GetUserRolesResponse, error)
}
type authzServiceClient struct {
cc grpc.ClientConnInterface
}
func NewAuthzServiceClient(cc grpc.ClientConnInterface) AuthzServiceClient {
return &authzServiceClient{cc}
}
func (c *authzServiceClient) Authorize(ctx context.Context, in *AuthorizeRequest, opts ...grpc.CallOption) (*AuthorizeResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AuthorizeResponse)
err := c.cc.Invoke(ctx, AuthzService_Authorize_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authzServiceClient) HasPermission(ctx context.Context, in *HasPermissionRequest, opts ...grpc.CallOption) (*HasPermissionResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(HasPermissionResponse)
err := c.cc.Invoke(ctx, AuthzService_HasPermission_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authzServiceClient) GetUserPermissions(ctx context.Context, in *GetUserPermissionsRequest, opts ...grpc.CallOption) (*GetUserPermissionsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserPermissionsResponse)
err := c.cc.Invoke(ctx, AuthzService_GetUserPermissions_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *authzServiceClient) GetUserRoles(ctx context.Context, in *GetUserRolesRequest, opts ...grpc.CallOption) (*GetUserRolesResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserRolesResponse)
err := c.cc.Invoke(ctx, AuthzService_GetUserRoles_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// AuthzServiceServer is the server API for AuthzService service.
// All implementations must embed UnimplementedAuthzServiceServer
// for forward compatibility.
//
// AuthzService provides authorization operations.
type AuthzServiceServer interface {
// Authorize checks if a user has a specific permission and returns an error if not.
Authorize(context.Context, *AuthorizeRequest) (*AuthorizeResponse, error)
// HasPermission checks if a user has a specific permission.
HasPermission(context.Context, *HasPermissionRequest) (*HasPermissionResponse, error)
// GetUserPermissions returns all permissions for a user.
GetUserPermissions(context.Context, *GetUserPermissionsRequest) (*GetUserPermissionsResponse, error)
// GetUserRoles returns all roles for a user.
GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error)
mustEmbedUnimplementedAuthzServiceServer()
}
// UnimplementedAuthzServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedAuthzServiceServer struct{}
func (UnimplementedAuthzServiceServer) Authorize(context.Context, *AuthorizeRequest) (*AuthorizeResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Authorize not implemented")
}
func (UnimplementedAuthzServiceServer) HasPermission(context.Context, *HasPermissionRequest) (*HasPermissionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HasPermission not implemented")
}
func (UnimplementedAuthzServiceServer) GetUserPermissions(context.Context, *GetUserPermissionsRequest) (*GetUserPermissionsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUserPermissions not implemented")
}
func (UnimplementedAuthzServiceServer) GetUserRoles(context.Context, *GetUserRolesRequest) (*GetUserRolesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUserRoles not implemented")
}
func (UnimplementedAuthzServiceServer) mustEmbedUnimplementedAuthzServiceServer() {}
func (UnimplementedAuthzServiceServer) testEmbeddedByValue() {}
// UnsafeAuthzServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to AuthzServiceServer will
// result in compilation errors.
type UnsafeAuthzServiceServer interface {
mustEmbedUnimplementedAuthzServiceServer()
}
func RegisterAuthzServiceServer(s grpc.ServiceRegistrar, srv AuthzServiceServer) {
// If the following call pancis, it indicates UnimplementedAuthzServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&AuthzService_ServiceDesc, srv)
}
func _AuthzService_Authorize_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AuthorizeRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthzServiceServer).Authorize(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthzService_Authorize_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthzServiceServer).Authorize(ctx, req.(*AuthorizeRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AuthzService_HasPermission_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HasPermissionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthzServiceServer).HasPermission(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthzService_HasPermission_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthzServiceServer).HasPermission(ctx, req.(*HasPermissionRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AuthzService_GetUserPermissions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserPermissionsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthzServiceServer).GetUserPermissions(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthzService_GetUserPermissions_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthzServiceServer).GetUserPermissions(ctx, req.(*GetUserPermissionsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _AuthzService_GetUserRoles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserRolesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(AuthzServiceServer).GetUserRoles(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: AuthzService_GetUserRoles_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(AuthzServiceServer).GetUserRoles(ctx, req.(*GetUserRolesRequest))
}
return interceptor(ctx, in, info, handler)
}
// AuthzService_ServiceDesc is the grpc.ServiceDesc for AuthzService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var AuthzService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "authz.v1.AuthzService",
HandlerType: (*AuthzServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Authorize",
Handler: _AuthzService_Authorize_Handler,
},
{
MethodName: "HasPermission",
Handler: _AuthzService_HasPermission_Handler,
},
{
MethodName: "GetUserPermissions",
Handler: _AuthzService_GetUserPermissions_Handler,
},
{
MethodName: "GetUserRoles",
Handler: _AuthzService_GetUserRoles_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "authz.proto",
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,407 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.30.2
// source: identity.proto
package identityv1
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.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
IdentityService_GetUser_FullMethodName = "/identity.v1.IdentityService/GetUser"
IdentityService_GetUserByEmail_FullMethodName = "/identity.v1.IdentityService/GetUserByEmail"
IdentityService_CreateUser_FullMethodName = "/identity.v1.IdentityService/CreateUser"
IdentityService_UpdateUser_FullMethodName = "/identity.v1.IdentityService/UpdateUser"
IdentityService_DeleteUser_FullMethodName = "/identity.v1.IdentityService/DeleteUser"
IdentityService_VerifyEmail_FullMethodName = "/identity.v1.IdentityService/VerifyEmail"
IdentityService_RequestPasswordReset_FullMethodName = "/identity.v1.IdentityService/RequestPasswordReset"
IdentityService_ResetPassword_FullMethodName = "/identity.v1.IdentityService/ResetPassword"
)
// IdentityServiceClient is the client API for IdentityService 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.
//
// IdentityService provides user management operations.
type IdentityServiceClient interface {
// GetUser retrieves a user by ID.
GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error)
// GetUserByEmail retrieves a user by email address.
GetUserByEmail(ctx context.Context, in *GetUserByEmailRequest, opts ...grpc.CallOption) (*GetUserByEmailResponse, error)
// CreateUser creates a new user.
CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error)
// UpdateUser updates an existing user.
UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error)
// DeleteUser deletes a user.
DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*DeleteUserResponse, error)
// VerifyEmail verifies a user's email address using a verification token.
VerifyEmail(ctx context.Context, in *VerifyEmailRequest, opts ...grpc.CallOption) (*VerifyEmailResponse, error)
// RequestPasswordReset requests a password reset token.
RequestPasswordReset(ctx context.Context, in *RequestPasswordResetRequest, opts ...grpc.CallOption) (*RequestPasswordResetResponse, error)
// ResetPassword resets a user's password using a reset token.
ResetPassword(ctx context.Context, in *ResetPasswordRequest, opts ...grpc.CallOption) (*ResetPasswordResponse, error)
}
type identityServiceClient struct {
cc grpc.ClientConnInterface
}
func NewIdentityServiceClient(cc grpc.ClientConnInterface) IdentityServiceClient {
return &identityServiceClient{cc}
}
func (c *identityServiceClient) GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserResponse)
err := c.cc.Invoke(ctx, IdentityService_GetUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *identityServiceClient) GetUserByEmail(ctx context.Context, in *GetUserByEmailRequest, opts ...grpc.CallOption) (*GetUserByEmailResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetUserByEmailResponse)
err := c.cc.Invoke(ctx, IdentityService_GetUserByEmail_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *identityServiceClient) CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CreateUserResponse)
err := c.cc.Invoke(ctx, IdentityService_CreateUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *identityServiceClient) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*UpdateUserResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(UpdateUserResponse)
err := c.cc.Invoke(ctx, IdentityService_UpdateUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *identityServiceClient) DeleteUser(ctx context.Context, in *DeleteUserRequest, opts ...grpc.CallOption) (*DeleteUserResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(DeleteUserResponse)
err := c.cc.Invoke(ctx, IdentityService_DeleteUser_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *identityServiceClient) VerifyEmail(ctx context.Context, in *VerifyEmailRequest, opts ...grpc.CallOption) (*VerifyEmailResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(VerifyEmailResponse)
err := c.cc.Invoke(ctx, IdentityService_VerifyEmail_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *identityServiceClient) RequestPasswordReset(ctx context.Context, in *RequestPasswordResetRequest, opts ...grpc.CallOption) (*RequestPasswordResetResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RequestPasswordResetResponse)
err := c.cc.Invoke(ctx, IdentityService_RequestPasswordReset_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *identityServiceClient) ResetPassword(ctx context.Context, in *ResetPasswordRequest, opts ...grpc.CallOption) (*ResetPasswordResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ResetPasswordResponse)
err := c.cc.Invoke(ctx, IdentityService_ResetPassword_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// IdentityServiceServer is the server API for IdentityService service.
// All implementations must embed UnimplementedIdentityServiceServer
// for forward compatibility.
//
// IdentityService provides user management operations.
type IdentityServiceServer interface {
// GetUser retrieves a user by ID.
GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error)
// GetUserByEmail retrieves a user by email address.
GetUserByEmail(context.Context, *GetUserByEmailRequest) (*GetUserByEmailResponse, error)
// CreateUser creates a new user.
CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error)
// UpdateUser updates an existing user.
UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error)
// DeleteUser deletes a user.
DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error)
// VerifyEmail verifies a user's email address using a verification token.
VerifyEmail(context.Context, *VerifyEmailRequest) (*VerifyEmailResponse, error)
// RequestPasswordReset requests a password reset token.
RequestPasswordReset(context.Context, *RequestPasswordResetRequest) (*RequestPasswordResetResponse, error)
// ResetPassword resets a user's password using a reset token.
ResetPassword(context.Context, *ResetPasswordRequest) (*ResetPasswordResponse, error)
mustEmbedUnimplementedIdentityServiceServer()
}
// UnimplementedIdentityServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedIdentityServiceServer struct{}
func (UnimplementedIdentityServiceServer) GetUser(context.Context, *GetUserRequest) (*GetUserResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUser not implemented")
}
func (UnimplementedIdentityServiceServer) GetUserByEmail(context.Context, *GetUserByEmailRequest) (*GetUserByEmailResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUserByEmail not implemented")
}
func (UnimplementedIdentityServiceServer) CreateUser(context.Context, *CreateUserRequest) (*CreateUserResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateUser not implemented")
}
func (UnimplementedIdentityServiceServer) UpdateUser(context.Context, *UpdateUserRequest) (*UpdateUserResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateUser not implemented")
}
func (UnimplementedIdentityServiceServer) DeleteUser(context.Context, *DeleteUserRequest) (*DeleteUserResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteUser not implemented")
}
func (UnimplementedIdentityServiceServer) VerifyEmail(context.Context, *VerifyEmailRequest) (*VerifyEmailResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method VerifyEmail not implemented")
}
func (UnimplementedIdentityServiceServer) RequestPasswordReset(context.Context, *RequestPasswordResetRequest) (*RequestPasswordResetResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RequestPasswordReset not implemented")
}
func (UnimplementedIdentityServiceServer) ResetPassword(context.Context, *ResetPasswordRequest) (*ResetPasswordResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ResetPassword not implemented")
}
func (UnimplementedIdentityServiceServer) mustEmbedUnimplementedIdentityServiceServer() {}
func (UnimplementedIdentityServiceServer) testEmbeddedByValue() {}
// UnsafeIdentityServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to IdentityServiceServer will
// result in compilation errors.
type UnsafeIdentityServiceServer interface {
mustEmbedUnimplementedIdentityServiceServer()
}
func RegisterIdentityServiceServer(s grpc.ServiceRegistrar, srv IdentityServiceServer) {
// If the following call pancis, it indicates UnimplementedIdentityServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&IdentityService_ServiceDesc, srv)
}
func _IdentityService_GetUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(IdentityServiceServer).GetUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: IdentityService_GetUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(IdentityServiceServer).GetUser(ctx, req.(*GetUserRequest))
}
return interceptor(ctx, in, info, handler)
}
func _IdentityService_GetUserByEmail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUserByEmailRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(IdentityServiceServer).GetUserByEmail(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: IdentityService_GetUserByEmail_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(IdentityServiceServer).GetUserByEmail(ctx, req.(*GetUserByEmailRequest))
}
return interceptor(ctx, in, info, handler)
}
func _IdentityService_CreateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CreateUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(IdentityServiceServer).CreateUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: IdentityService_CreateUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(IdentityServiceServer).CreateUser(ctx, req.(*CreateUserRequest))
}
return interceptor(ctx, in, info, handler)
}
func _IdentityService_UpdateUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(IdentityServiceServer).UpdateUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: IdentityService_UpdateUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(IdentityServiceServer).UpdateUser(ctx, req.(*UpdateUserRequest))
}
return interceptor(ctx, in, info, handler)
}
func _IdentityService_DeleteUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteUserRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(IdentityServiceServer).DeleteUser(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: IdentityService_DeleteUser_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(IdentityServiceServer).DeleteUser(ctx, req.(*DeleteUserRequest))
}
return interceptor(ctx, in, info, handler)
}
func _IdentityService_VerifyEmail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(VerifyEmailRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(IdentityServiceServer).VerifyEmail(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: IdentityService_VerifyEmail_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(IdentityServiceServer).VerifyEmail(ctx, req.(*VerifyEmailRequest))
}
return interceptor(ctx, in, info, handler)
}
func _IdentityService_RequestPasswordReset_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RequestPasswordResetRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(IdentityServiceServer).RequestPasswordReset(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: IdentityService_RequestPasswordReset_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(IdentityServiceServer).RequestPasswordReset(ctx, req.(*RequestPasswordResetRequest))
}
return interceptor(ctx, in, info, handler)
}
func _IdentityService_ResetPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ResetPasswordRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(IdentityServiceServer).ResetPassword(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: IdentityService_ResetPassword_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(IdentityServiceServer).ResetPassword(ctx, req.(*ResetPasswordRequest))
}
return interceptor(ctx, in, info, handler)
}
// IdentityService_ServiceDesc is the grpc.ServiceDesc for IdentityService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var IdentityService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "identity.v1.IdentityService",
HandlerType: (*IdentityServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetUser",
Handler: _IdentityService_GetUser_Handler,
},
{
MethodName: "GetUserByEmail",
Handler: _IdentityService_GetUserByEmail_Handler,
},
{
MethodName: "CreateUser",
Handler: _IdentityService_CreateUser_Handler,
},
{
MethodName: "UpdateUser",
Handler: _IdentityService_UpdateUser_Handler,
},
{
MethodName: "DeleteUser",
Handler: _IdentityService_DeleteUser_Handler,
},
{
MethodName: "VerifyEmail",
Handler: _IdentityService_VerifyEmail_Handler,
},
{
MethodName: "RequestPasswordReset",
Handler: _IdentityService_RequestPasswordReset_Handler,
},
{
MethodName: "ResetPassword",
Handler: _IdentityService_ResetPassword_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "identity.proto",
}