certificate/certificatepb: add definitions for migration

Also fixing the timestamp in .proto which was actually int64.

Change-Id: I65e3172793a49bf8bfd946b199016204ed72f221
This commit is contained in:
Egon Elbre 2023-01-19 17:02:44 +02:00
parent e40191afd6
commit e9bc06608e
4 changed files with 315 additions and 18 deletions

View File

@ -105,26 +105,232 @@ func (m *SigningResponse) GetChain() [][]byte {
return nil
}
type AuthorizationGroup struct {
Authorizations []*Authorization `protobuf:"bytes,1,rep,name=authorizations,proto3" json:"authorizations,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *AuthorizationGroup) Reset() { *m = AuthorizationGroup{} }
func (m *AuthorizationGroup) String() string { return proto.CompactTextString(m) }
func (*AuthorizationGroup) ProtoMessage() {}
func (*AuthorizationGroup) Descriptor() ([]byte, []int) {
return fileDescriptor_c0d34c34dd33be4b, []int{2}
}
func (m *AuthorizationGroup) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_AuthorizationGroup.Unmarshal(m, b)
}
func (m *AuthorizationGroup) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_AuthorizationGroup.Marshal(b, m, deterministic)
}
func (m *AuthorizationGroup) XXX_Merge(src proto.Message) {
xxx_messageInfo_AuthorizationGroup.Merge(m, src)
}
func (m *AuthorizationGroup) XXX_Size() int {
return xxx_messageInfo_AuthorizationGroup.Size(m)
}
func (m *AuthorizationGroup) XXX_DiscardUnknown() {
xxx_messageInfo_AuthorizationGroup.DiscardUnknown(m)
}
var xxx_messageInfo_AuthorizationGroup proto.InternalMessageInfo
func (m *AuthorizationGroup) GetAuthorizations() []*Authorization {
if m != nil {
return m.Authorizations
}
return nil
}
type Authorization struct {
Token *Token `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"`
Claim *Claim `protobuf:"bytes,2,opt,name=claim,proto3" json:"claim,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Authorization) Reset() { *m = Authorization{} }
func (m *Authorization) String() string { return proto.CompactTextString(m) }
func (*Authorization) ProtoMessage() {}
func (*Authorization) Descriptor() ([]byte, []int) {
return fileDescriptor_c0d34c34dd33be4b, []int{3}
}
func (m *Authorization) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Authorization.Unmarshal(m, b)
}
func (m *Authorization) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Authorization.Marshal(b, m, deterministic)
}
func (m *Authorization) XXX_Merge(src proto.Message) {
xxx_messageInfo_Authorization.Merge(m, src)
}
func (m *Authorization) XXX_Size() int {
return xxx_messageInfo_Authorization.Size(m)
}
func (m *Authorization) XXX_DiscardUnknown() {
xxx_messageInfo_Authorization.DiscardUnknown(m)
}
var xxx_messageInfo_Authorization proto.InternalMessageInfo
func (m *Authorization) GetToken() *Token {
if m != nil {
return m.Token
}
return nil
}
func (m *Authorization) GetClaim() *Claim {
if m != nil {
return m.Claim
}
return nil
}
type Token struct {
UserId []byte `protobuf:"bytes,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Token) Reset() { *m = Token{} }
func (m *Token) String() string { return proto.CompactTextString(m) }
func (*Token) ProtoMessage() {}
func (*Token) Descriptor() ([]byte, []int) {
return fileDescriptor_c0d34c34dd33be4b, []int{4}
}
func (m *Token) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Token.Unmarshal(m, b)
}
func (m *Token) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Token.Marshal(b, m, deterministic)
}
func (m *Token) XXX_Merge(src proto.Message) {
xxx_messageInfo_Token.Merge(m, src)
}
func (m *Token) XXX_Size() int {
return xxx_messageInfo_Token.Size(m)
}
func (m *Token) XXX_DiscardUnknown() {
xxx_messageInfo_Token.DiscardUnknown(m)
}
var xxx_messageInfo_Token proto.InternalMessageInfo
func (m *Token) GetUserId() []byte {
if m != nil {
return m.UserId
}
return nil
}
func (m *Token) GetData() []byte {
if m != nil {
return m.Data
}
return nil
}
type Claim struct {
Addr []byte `protobuf:"bytes,1,opt,name=addr,proto3" json:"addr,omitempty"`
Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
Identity []byte `protobuf:"bytes,3,opt,name=identity,proto3" json:"identity,omitempty"`
SignedChainBytes [][]byte `protobuf:"bytes,4,rep,name=signed_chain_bytes,json=signedChainBytes,proto3" json:"signed_chain_bytes,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Claim) Reset() { *m = Claim{} }
func (m *Claim) String() string { return proto.CompactTextString(m) }
func (*Claim) ProtoMessage() {}
func (*Claim) Descriptor() ([]byte, []int) {
return fileDescriptor_c0d34c34dd33be4b, []int{5}
}
func (m *Claim) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Claim.Unmarshal(m, b)
}
func (m *Claim) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Claim.Marshal(b, m, deterministic)
}
func (m *Claim) XXX_Merge(src proto.Message) {
xxx_messageInfo_Claim.Merge(m, src)
}
func (m *Claim) XXX_Size() int {
return xxx_messageInfo_Claim.Size(m)
}
func (m *Claim) XXX_DiscardUnknown() {
xxx_messageInfo_Claim.DiscardUnknown(m)
}
var xxx_messageInfo_Claim proto.InternalMessageInfo
func (m *Claim) GetAddr() []byte {
if m != nil {
return m.Addr
}
return nil
}
func (m *Claim) GetTimestamp() int64 {
if m != nil {
return m.Timestamp
}
return 0
}
func (m *Claim) GetIdentity() []byte {
if m != nil {
return m.Identity
}
return nil
}
func (m *Claim) GetSignedChainBytes() [][]byte {
if m != nil {
return m.SignedChainBytes
}
return nil
}
func init() {
proto.RegisterType((*SigningRequest)(nil), "node.SigningRequest")
proto.RegisterType((*SigningResponse)(nil), "node.SigningResponse")
proto.RegisterType((*AuthorizationGroup)(nil), "node.AuthorizationGroup")
proto.RegisterType((*Authorization)(nil), "node.Authorization")
proto.RegisterType((*Token)(nil), "node.Token")
proto.RegisterType((*Claim)(nil), "node.Claim")
}
func init() { proto.RegisterFile("certificate.proto", fileDescriptor_c0d34c34dd33be4b) }
var fileDescriptor_c0d34c34dd33be4b = []byte{
// 198 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x8f, 0x41, 0x4b, 0x80, 0x40,
0x10, 0x85, 0x31, 0x2d, 0x70, 0x90, 0xa2, 0xc5, 0x40, 0xa2, 0x40, 0xbc, 0xb4, 0x74, 0x58, 0x21,
0xff, 0x41, 0x9e, 0xbb, 0x6c, 0x9d, 0xba, 0xc4, 0x6a, 0x93, 0x6e, 0xe1, 0xee, 0xe6, 0x8e, 0xff,
0x3f, 0x56, 0x21, 0xad, 0xdb, 0x9b, 0x0f, 0xe6, 0xf1, 0x3d, 0xb8, 0xec, 0x71, 0x26, 0xfd, 0xa1,
0x7b, 0x45, 0x28, 0xdc, 0x6c, 0xc9, 0xb2, 0xc4, 0xd8, 0x77, 0xac, 0x9e, 0xe0, 0xfc, 0x59, 0x0f,
0x46, 0x9b, 0x41, 0xe2, 0xf7, 0x82, 0x9e, 0xd8, 0x2d, 0x80, 0x5a, 0x68, 0x7c, 0x23, 0xfb, 0x85,
0xa6, 0x88, 0xca, 0x88, 0xa7, 0x32, 0x0d, 0xe4, 0x25, 0x00, 0x76, 0x03, 0x29, 0xe9, 0x09, 0x3d,
0xa9, 0xc9, 0x15, 0x27, 0x65, 0xc4, 0x63, 0xb9, 0x83, 0xea, 0x0e, 0x2e, 0x7e, 0xeb, 0xbc, 0xb3,
0xc6, 0x23, 0xcb, 0xe1, 0xb4, 0x1f, 0x95, 0x0e, 0x55, 0x31, 0xcf, 0xe4, 0x76, 0x3c, 0xb4, 0x90,
0xb5, 0xbb, 0x92, 0x67, 0x0d, 0x24, 0xe1, 0x91, 0xe5, 0x22, 0x68, 0x89, 0xbf, 0x4e, 0xd7, 0x57,
0xff, 0xe8, 0x56, 0xfd, 0x78, 0xff, 0xca, 0x3d, 0xd9, 0xf9, 0x53, 0x68, 0x5b, 0xaf, 0xa1, 0x3e,
0xcc, 0x3c, 0x66, 0xd7, 0x75, 0x67, 0xeb, 0xea, 0xe6, 0x27, 0x00, 0x00, 0xff, 0xff, 0x63, 0xd9,
0xed, 0xce, 0x0a, 0x01, 0x00, 0x00,
// 363 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x52, 0xbf, 0x4f, 0xf3, 0x30,
0x10, 0x55, 0xbe, 0x26, 0xfd, 0xe8, 0x35, 0x14, 0x30, 0x45, 0x44, 0x15, 0x48, 0x25, 0x0b, 0x11,
0x42, 0xa9, 0xd4, 0xb2, 0x31, 0xd1, 0x0c, 0x88, 0x81, 0x01, 0x03, 0x0b, 0x4b, 0xe4, 0xc6, 0xa6,
0x35, 0x50, 0x3b, 0xc4, 0xce, 0x50, 0x56, 0xfe, 0x71, 0x64, 0x1b, 0xf5, 0xd7, 0xc0, 0x76, 0xf7,
0xde, 0xdd, 0x93, 0xdf, 0x3d, 0xc3, 0x41, 0xc1, 0x2a, 0xcd, 0x5f, 0x79, 0x41, 0x34, 0x4b, 0xcb,
0x4a, 0x6a, 0x89, 0x7c, 0x21, 0x29, 0x8b, 0xef, 0xa1, 0xf3, 0xc8, 0xa7, 0x82, 0x8b, 0x29, 0x66,
0x9f, 0x35, 0x53, 0x1a, 0x9d, 0x02, 0x90, 0x5a, 0xcf, 0x72, 0x2d, 0xdf, 0x99, 0x88, 0xbc, 0xb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d, 0xc7, 0x64, 0x86, 0x18, 0x1b, 0x7c,
0x98, 0x41, 0x98, 0xad, 0x82, 0x57, 0x68, 0x04, 0xbe, 0x89, 0x07, 0x75, 0x9d, 0xcf, 0xcd, 0xe4,
0x7b, 0x47, 0x5b, 0xa8, 0x0b, 0x70, 0x7c, 0xf1, 0x92, 0x28, 0x2d, 0xab, 0xb7, 0x94, 0xcb, 0x81,
0x2d, 0x06, 0x6b, 0x9f, 0x69, 0xbd, 0x2e, 0x27, 0x93, 0xa6, 0xfd, 0x5b, 0xa3, 0x9f, 0x00, 0x00,
0x00, 0xff, 0xff, 0xc3, 0xd7, 0xdc, 0xe6, 0x70, 0x02, 0x00, 0x00,
}

View File

@ -12,9 +12,33 @@ service Certificates {
message SigningRequest {
string auth_token = 1;
int32 timestamp = 2;
int64 timestamp = 2;
}
message SigningResponse {
repeated bytes chain = 1;
}
// These types are used for storing authorizations in a database.
message AuthorizationGroup {
repeated Authorization authorizations = 1;
}
message Authorization {
Token token = 1;
Claim claim = 2;
}
message Token {
bytes user_id = 1;
bytes data = 2;
}
message Claim {
bytes addr = 1;
int64 timestamp = 2;
bytes identity = 3;
repeated bytes signed_chain_bytes = 4;
}

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-go-drpc. DO NOT EDIT.
// protoc-gen-go-drpc version: v0.0.20
// protoc-gen-go-drpc version: (devel)
// source: certificate.proto
package certificatepb
@ -71,7 +71,7 @@ type DRPCCertificatesServer interface {
type DRPCCertificatesUnimplementedServer struct{}
func (s *DRPCCertificatesUnimplementedServer) Sign(context.Context, *SigningRequest) (*SigningResponse, error) {
return nil, drpcerr.WithCode(errors.New("Unimplemented"), 12)
return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
}
type DRPCCertificatesDescription struct{}

View File

@ -15,7 +15,7 @@
{
"id": 2,
"name": "timestamp",
"type": "int32"
"type": "int64"
}
]
},
@ -29,6 +29,73 @@
"is_repeated": true
}
]
},
{
"name": "AuthorizationGroup",
"fields": [
{
"id": 1,
"name": "authorizations",
"type": "Authorization",
"is_repeated": true
}
]
},
{
"name": "Authorization",
"fields": [
{
"id": 1,
"name": "token",
"type": "Token"
},
{
"id": 2,
"name": "claim",
"type": "Claim"
}
]
},
{
"name": "Token",
"fields": [
{
"id": 1,
"name": "user_id",
"type": "bytes"
},
{
"id": 2,
"name": "data",
"type": "bytes"
}
]
},
{
"name": "Claim",
"fields": [
{
"id": 1,
"name": "addr",
"type": "bytes"
},
{
"id": 2,
"name": "timestamp",
"type": "int64"
},
{
"id": 3,
"name": "identity",
"type": "bytes"
},
{
"id": 4,
"name": "signed_chain_bytes",
"type": "bytes",
"is_repeated": true
}
]
}
],
"services": [