/
fs_api.go
604 lines (548 loc) · 17.6 KB
/
fs_api.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
// Structures used in Group Store
// File System
// /acct/(uuid)/fs "(uuid)" { "id": "uuid", "name": "name", "status": "active",
// "createdate": <timestamp>, "deletedate": <timestamp>
// }
//
// IP Address
// /acct/(uuid)/fs/(uuid)/addr "(uuid)" { "id": uuid, "addr": "111.111.111.111", "status": "active",
// "createdate": <timestamp>, "deletedate": <timestamp>
// }
package main
import (
"encoding/json"
"errors"
"fmt"
"log"
"reflect"
"time"
pb "github.com/creiht/formic/proto"
"github.com/gholt/brimtime"
"github.com/gholt/store"
"github.com/satori/go.uuid"
"github.com/spaolacci/murmur3"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/peer"
)
var errf = grpc.Errorf
// AcctPayLoad ...
type AcctPayLoad struct {
ID string `json:"id"`
Name string `json:"name"`
Token string `json:"token"`
Status string `json:"status"`
CreateDate int64 `json:"createdate"`
DeleteDate int64 `json:"deletedate"`
}
// TokenRef ...
type TokenRef struct {
TokenID string `json:"token"`
AcctID string `json:"acctid"`
}
// FileSysRef ...
type FileSysRef struct {
FSID string `json:"fsid"`
AcctID string `json:"acctid"`
}
// FileSysAttr ...
type FileSysAttr struct {
Attr string `json:"attr"`
Value string `json:"value"`
FSID string `json:"fsid"`
}
// AddrRef ...
type AddrRef struct {
Addr string `json:"addr"`
FSID string `json:"fsid"`
}
// FileSysMeta ...
type FileSysMeta struct {
ID string `json:"id"`
AcctID string `json:"acctid"`
Name string `json:"name"`
Status string `json:"status"`
Addr []string `json:"addrs"`
}
func clear(v interface{}) {
p := reflect.ValueOf(v).Elem()
p.Set(reflect.Zero(p.Type()))
}
// FileSystemAPIServer is used to implement oohhc
type FileSystemAPIServer struct {
gstore store.GroupStore
}
// FSAttrList ...
var FSAttrList = []string{"name"}
// NewFileSystemAPIServer ...
func NewFileSystemAPIServer(store store.GroupStore) *FileSystemAPIServer {
s := new(FileSystemAPIServer)
s.gstore = store
return s
}
// CreateFS ...
func (s *FileSystemAPIServer) CreateFS(ctx context.Context, r *pb.CreateFSRequest) (*pb.CreateFSResponse, error) {
var err error
var acctID string
srcAddr := ""
var fsRef FileSysRef
var fsRefByte []byte
var fsSysAttr FileSysAttr
var fsSysAttrByte []byte
// Get incomming ip
pr, ok := peer.FromContext(ctx)
if ok {
srcAddr = pr.Addr.String()
}
// Validate Token
acctID, err = s.validateToken(r.Token)
if err != nil {
log.Printf("%s CREATE FAILED %s\n", srcAddr, "PermissionDenied")
return nil, errf(codes.PermissionDenied, "%v", "Invalid Token")
}
fsID := uuid.NewV4().String()
timestampMicro := brimtime.TimeToUnixMicro(time.Now())
// Write file system reference entries.
// write /fs FSID FileSysRef
pKey := "/fs"
pKeyA, pKeyB := murmur3.Sum128([]byte(pKey))
cKeyA, cKeyB := murmur3.Sum128([]byte(fsID))
fsRef.AcctID = acctID
fsRef.FSID = fsID
fsRefByte, err = json.Marshal(fsRef)
if err != nil {
log.Printf("%s CREATE FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
_, err = s.gstore.Write(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, timestampMicro, fsRefByte)
if err != nil {
log.Printf("%s CREATE FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
// write /acct/acctID FSID FileSysRef
pKey = fmt.Sprintf("/acct/%s", acctID)
pKeyA, pKeyB = murmur3.Sum128([]byte(pKey))
_, err = s.gstore.Write(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, timestampMicro, fsRefByte)
if err != nil {
log.Printf("%s CREATE FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
// Write file system attributes
// write /fs/FSID name FileSysAttr
pKey = fmt.Sprintf("/fs/%s", fsID)
pKeyA, pKeyB = murmur3.Sum128([]byte(pKey))
cKeyA, cKeyB = murmur3.Sum128([]byte("name"))
fsSysAttr.Attr = "name"
fsSysAttr.Value = r.FSName
fsSysAttr.FSID = fsID
fsSysAttrByte, err = json.Marshal(fsSysAttr)
if err != nil {
log.Printf("%s CREATE FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
_, err = s.gstore.Write(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, timestampMicro, fsSysAttrByte)
if err != nil {
log.Printf("%s CREATE FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
// Return File System UUID
// Log Operation
log.Printf("%s CREATE SUCCESS %s\n", srcAddr, fsID)
return &pb.CreateFSResponse{Data: fsID}, nil
}
// ShowFS ...
func (s *FileSystemAPIServer) ShowFS(ctx context.Context, r *pb.ShowFSRequest) (*pb.ShowFSResponse, error) {
var err error
var acctID string
srcAddr := ""
// Get incomming ip
pr, ok := peer.FromContext(ctx)
if ok {
srcAddr = pr.Addr.String()
}
// Validate Token
acctID, err = s.validateToken(r.Token)
if err != nil {
log.Printf("%s SHOW FAILED %s\n", srcAddr, "PermissionDenied")
return nil, errf(codes.PermissionDenied, "%v", "Invalid Token")
}
var fs FileSysMeta
var value []byte
var fsRef FileSysRef
var addrData AddrRef
var fsAttrData FileSysAttr
var aList []string
fs.ID = r.FSid
// Read FileSysRef entry to determine if it exists
pKey := fmt.Sprintf("/fs")
pKeyA, pKeyB := murmur3.Sum128([]byte(pKey))
cKeyA, cKeyB := murmur3.Sum128([]byte(fs.ID))
_, value, err = s.gstore.Read(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, nil)
if store.IsNotFound(err) {
log.Printf("%s SHOW FAILED %s NOTFOUND", srcAddr, r.FSid)
return nil, errf(codes.NotFound, "%v", "Not Found")
}
if err != nil {
log.Printf("%s SHOW FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
err = json.Unmarshal(value, &fsRef)
if err != nil {
log.Printf("%s SHOW FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
// Validate Token/Account own the file system
if fsRef.AcctID != acctID {
log.Printf("$s SHOW FAILED %v ACCOUNT MISMATCH", fs.ID)
return nil, errf(codes.FailedPrecondition, "%v", "Account Mismatch")
}
fs.AcctID = fsRef.AcctID
// Read the file system attributes
// group-lookup /fs FSID
// Iterate over all the atributes
pKey = fmt.Sprintf("/fs/%s", fs.ID)
pKeyA, pKeyB = murmur3.Sum128([]byte(pKey))
cKeyA, cKeyB = murmur3.Sum128([]byte("name"))
_, value, err = s.gstore.Read(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, nil)
if store.IsNotFound(err) {
log.Printf("%s SHOW FAILED %s NAMENOTFOUND", srcAddr, r.FSid)
return nil, errf(codes.NotFound, "%v", "File System Name Not Found")
}
if err != nil {
log.Printf("%s SHOW FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
err = json.Unmarshal(value, &fsAttrData)
if err != nil {
log.Printf("%s SHOW FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
fs.Name = fsAttrData.Value
// Read list of granted ip addresses
// group-lookup printf("/fs/%s/addr", FSID)
pKey = fmt.Sprintf("/fs/%s/addr", fs.ID)
pKeyA, pKeyB = murmur3.Sum128([]byte(pKey))
items, err := s.gstore.ReadGroup(context.Background(), pKeyA, pKeyB)
if !store.IsNotFound(err) {
// No addr granted
aList = make([]string, len(items))
for k, v := range items {
err = json.Unmarshal(v.Value, &addrData)
if err != nil {
log.Printf("%s LIST FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
aList[k] = addrData.Addr
}
}
if err != nil {
log.Printf("%s SHOW FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
fs.Addr = aList
// Return File System
fsJSON, jerr := json.Marshal(&fs)
if jerr != nil {
return nil, errf(codes.Internal, "%s", jerr)
}
// Log Operation
log.Printf("%s SHOW SUCCESS %s\n", srcAddr, r.FSid)
return &pb.ShowFSResponse{Data: string(fsJSON)}, nil
}
// ListFS ...
func (s *FileSystemAPIServer) ListFS(ctx context.Context, r *pb.ListFSRequest) (*pb.ListFSResponse, error) {
srcAddr := ""
// Get incomming ip
pr, ok := peer.FromContext(ctx)
if ok {
srcAddr = pr.Addr.String()
}
// Validate Token
acctID, err := s.validateToken(r.Token)
if err != nil {
log.Printf("%s LIST FAILED %s\n", srcAddr, "PermissionDenied")
return nil, errf(codes.PermissionDenied, "%v", "Invalid Token")
}
var value []byte
var fsRef FileSysRef
var addrData AddrRef
var fsAttrData FileSysAttr
var aList []string
// Read Group /acct/acctID _ FileSysRef
pKey := fmt.Sprintf("/acct/%s", acctID)
pKeyA, pKeyB := murmur3.Sum128([]byte(pKey))
list, err := s.gstore.ReadGroup(context.Background(), pKeyA, pKeyB)
if err != nil {
log.Printf("%s LIST FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
fsList := make([]FileSysMeta, len(list))
for k, v := range list {
clear(&fsRef)
clear(&addrData)
clear(&fsAttrData)
clear(&aList)
err = json.Unmarshal(v.Value, &fsRef)
if err != nil {
log.Printf("%s LIST FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
fsList[k].AcctID = acctID
fsList[k].ID = fsRef.FSID
// Get File System Name
pKey = fmt.Sprintf("/fs/%s", fsList[k].ID)
pKeyA, pKeyB = murmur3.Sum128([]byte(pKey))
cKeyA, cKeyB := murmur3.Sum128([]byte("name"))
_, value, err = s.gstore.Read(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, nil)
if store.IsNotFound(err) {
log.Printf("%s LIST FAILED %s NAMENOTFOUND", srcAddr, fsList[k].ID)
return nil, errf(codes.NotFound, "%v", "File System Name Not Found")
}
if err != nil {
log.Printf("%s LIST FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
err = json.Unmarshal(value, &fsAttrData)
if err != nil {
log.Printf("%s LIST FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
fsList[k].Name = fsAttrData.Value
// Get List of addrs
pKey = fmt.Sprintf("/fs/%s/addr", fsList[k].ID)
pKeyA, pKeyB = murmur3.Sum128([]byte(pKey))
items, err := s.gstore.ReadGroup(context.Background(), pKeyA, pKeyB)
if !store.IsNotFound(err) {
// No addr granted
aList = make([]string, len(items))
for sk, sv := range items {
err = json.Unmarshal(sv.Value, &addrData)
if err != nil {
log.Printf("%s LIST FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
aList[sk] = addrData.Addr
}
}
if err != nil {
log.Printf("%s LIST FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
fsList[k].Addr = aList
}
// Return a File System List
fsListJSON, jerr := json.Marshal(&fsList)
if jerr != nil {
return nil, errf(codes.Internal, "%s", jerr)
}
// Log Operation
log.Printf("%s LIST SUCCESS %s\n", srcAddr, acctID)
return &pb.ListFSResponse{Data: string(fsListJSON)}, nil
}
// DeleteFS ...
func (s *FileSystemAPIServer) DeleteFS(ctx context.Context, r *pb.DeleteFSRequest) (*pb.DeleteFSResponse, error) {
var err error
srcAddr := ""
// Get incomming ip
pr, ok := peer.FromContext(ctx)
if ok {
srcAddr = pr.Addr.String()
}
// validate Token
_, err = s.validateToken(r.Token)
if err != nil {
log.Printf("%s DELETE FAILED %s\n", srcAddr, "PermissionDenied")
return nil, errf(codes.PermissionDenied, "%v", "Invalid Token")
}
// Validate Token/Account own this file system
// Prep things to return
// Log Operation
log.Printf("%s DELETE NOTIMPLEMENTED %s\n", srcAddr, r.FSid)
return &pb.DeleteFSResponse{Data: "Delete Operation not supported at this time"}, nil
}
// UpdateFS ...
func (s *FileSystemAPIServer) UpdateFS(ctx context.Context, r *pb.UpdateFSRequest) (*pb.UpdateFSResponse, error) {
var err error
srcAddr := ""
// Get incomming ip
pr, ok := peer.FromContext(ctx)
if ok {
srcAddr = pr.Addr.String()
}
// validate Token
_, err = s.validateToken(r.Token)
if err != nil {
log.Printf("%s UPDATE FAILED %s\n", srcAddr, "PermissionDenied")
return nil, errf(codes.PermissionDenied, "%v", "Invalid Token")
}
// validate that Token/Account own this file system
// return message
// Log Operation
log.Printf("%s UPDATE NOTIMPLEMENTED %s\n", srcAddr, r.FSid)
return &pb.UpdateFSResponse{Data: "UPDATE operation is not supported in EA"}, nil
}
// GrantAddrFS ...
func (s *FileSystemAPIServer) GrantAddrFS(ctx context.Context, r *pb.GrantAddrFSRequest) (*pb.GrantAddrFSResponse, error) {
var err error
var acctID string
var fsRef FileSysRef
var value []byte
var addrData AddrRef
var addrByte []byte
srcAddr := ""
// Get incomming ip
pr, ok := peer.FromContext(ctx)
if ok {
srcAddr = pr.Addr.String()
}
// validate token
acctID, err = s.validateToken(r.Token)
if err != nil {
log.Printf("%s GRANT FAILED %s\n", srcAddr, "PermissionDenied")
return nil, errf(codes.PermissionDenied, "%v", "Invalid Token")
}
// Validate Token/Account own the file system
// Read FileSysRef entry to determine if it exists
pKey := fmt.Sprintf("/fs")
pKeyA, pKeyB := murmur3.Sum128([]byte(pKey))
cKeyA, cKeyB := murmur3.Sum128([]byte(r.FSid))
_, value, err = s.gstore.Read(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, nil)
if store.IsNotFound(err) {
log.Printf("%s GRANT FAILED %s NOTFOUND", srcAddr, r.FSid)
return nil, errf(codes.NotFound, "%v", "Not Found")
}
if err != nil {
log.Printf("%s GRANT FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
err = json.Unmarshal(value, &fsRef)
if err != nil {
log.Printf("%s GRANT FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
if fsRef.AcctID != acctID {
log.Printf("$s GRANT FAILED %v ACCOUNT MISMATCH", r.FSid)
return nil, errf(codes.FailedPrecondition, "%v", "Account Mismatch")
}
// GRANT an file system entry for the addr
// write /fs/FSID/addr addr AddrRef
pKey = fmt.Sprintf("/fs/%s/addr", r.FSid)
pKeyA, pKeyB = murmur3.Sum128([]byte(pKey))
cKeyA, cKeyB = murmur3.Sum128([]byte(r.Addr))
timestampMicro := brimtime.TimeToUnixMicro(time.Now())
addrData.Addr = r.Addr
addrData.FSID = r.FSid
addrByte, err = json.Marshal(addrData)
if err != nil {
log.Printf("%s GRANT FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
_, err = s.gstore.Write(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, timestampMicro, addrByte)
if err != nil {
log.Printf("%s GRANT FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
// return Addr was Granted
// Log Operation
log.Printf("%s GRANT SUCCESS %s %s\n", srcAddr, r.FSid, r.Addr)
return &pb.GrantAddrFSResponse{Data: r.FSid}, nil
}
// RevokeAddrFS ...
func (s *FileSystemAPIServer) RevokeAddrFS(ctx context.Context, r *pb.RevokeAddrFSRequest) (*pb.RevokeAddrFSResponse, error) {
var err error
var acctID string
var value []byte
var fsRef FileSysRef
srcAddr := ""
// Get incomming ip
pr, ok := peer.FromContext(ctx)
if ok {
srcAddr = pr.Addr.String()
}
// Validate Token
acctID, err = s.validateToken(r.Token)
if err != nil {
log.Printf("%s REVOKE FAILED %s\n", srcAddr, "PermissionDenied")
return nil, errf(codes.PermissionDenied, "%v", "Invalid Token")
}
// Validate Token/Account owns this file system
// Read FileSysRef entry to determine if it exists
pKey := fmt.Sprintf("/fs")
pKeyA, pKeyB := murmur3.Sum128([]byte(pKey))
cKeyA, cKeyB := murmur3.Sum128([]byte(r.FSid))
_, value, err = s.gstore.Read(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, nil)
if store.IsNotFound(err) {
log.Printf("%s REVOKE FAILED %s NOTFOUND", srcAddr, r.FSid)
return nil, errf(codes.NotFound, "%v", "Not Found")
}
if err != nil {
log.Printf("%s REVOKE FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
err = json.Unmarshal(value, &fsRef)
if err != nil {
log.Printf("%s REVOKE FAILED %v\n", srcAddr, err)
return nil, errf(codes.Internal, "%v", err)
}
if fsRef.AcctID != acctID {
log.Printf("$s REVOKE FAILED %v ACCOUNT MISMATCH", r.FSid)
return nil, errf(codes.FailedPrecondition, "%v", "Account Mismatch")
}
// REVOKE an file system entry for the addr
// delete /fs/FSID/addr addr AddrRef
pKey = fmt.Sprintf("/fs/%s/addr", r.FSid)
pKeyA, pKeyB = murmur3.Sum128([]byte(pKey))
cKeyA, cKeyB = murmur3.Sum128([]byte(r.Addr))
timestampMicro := brimtime.TimeToUnixMicro(time.Now())
_, err = s.gstore.Delete(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, timestampMicro)
if store.IsNotFound(err) {
log.Printf("%s REVOKE FAILED %s %s\n", srcAddr, r.FSid, r.Addr)
return nil, errf(codes.NotFound, "%v", "Not Found")
}
// return Addr was revoked
// Log Operation
log.Printf("%s REVOKE SUCCESS %s %s\n", srcAddr, r.FSid, r.Addr)
return &pb.RevokeAddrFSResponse{Data: r.FSid}, nil
}
// validateToken ...
func (s *FileSystemAPIServer) validateToken(t string) (string, error) {
var tData TokenRef
var aData AcctPayLoad
var tDataByte []byte
var aDataByte []byte
var err error
// Read Token
pKeyA, pKeyB := murmur3.Sum128([]byte("/token"))
cKeyA, cKeyB := murmur3.Sum128([]byte(t))
_, tDataByte, err = s.gstore.Read(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, nil)
if store.IsNotFound(err) {
return "", errors.New("Not Found")
}
err = json.Unmarshal(tDataByte, &tData)
if err != nil {
log.Printf("TOKEN FAILED %v\n", err)
return "", err
}
// Read Account
pKeyA, pKeyB = murmur3.Sum128([]byte("/acct"))
cKeyA, cKeyB = murmur3.Sum128([]byte(tData.AcctID))
_, aDataByte, err = s.gstore.Read(context.Background(), pKeyA, pKeyB, cKeyA, cKeyB, nil)
if store.IsNotFound(err) {
return "", errors.New("Not Found")
}
err = json.Unmarshal(aDataByte, &aData)
if err != nil {
log.Printf("TOKEN FAILED %v\n", err)
return "", err
}
if tData.TokenID != aData.Token {
// Log Failed Operation
log.Printf("TOKEN FAIL %s\n", t)
return "", errors.New("Invalid Token")
}
// Return Account UUID
// Log Operation
log.Printf("TOKEN SUCCESS %s\n", tData.AcctID)
return tData.AcctID, nil
}