File tree 2 files changed +9
-0
lines changed
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -682,6 +682,12 @@ func (ts *TokenStore) create(entry *TokenEntry) error {
682
682
entry .ID = entryUUID
683
683
}
684
684
685
+ saltedId := ts .SaltID (entry .ID )
686
+ exist , _ := ts .lookupSalted (saltedId , true )
687
+ if exist != nil {
688
+ return fmt .Errorf ("cannot create a token with a duplicate ID" )
689
+ }
690
+
685
691
entry .Policies = policyutil .SanitizePolicies (entry .Policies , policyutil .DoNotAddDefaultPolicy )
686
692
687
693
err := ts .createAccessor (entry )
Original file line number Diff line number Diff line change @@ -465,6 +465,9 @@ func TestTokenStore_CreateLookup_ProvidedID(t *testing.T) {
465
465
if ent .ID != "foobarbaz" {
466
466
t .Fatalf ("bad: ent.ID: expected:\" foobarbaz\" \n actual:%s" , ent .ID )
467
467
}
468
+ if err := ts .create (ent ); err == nil {
469
+ t .Fatal ("expected error creating token with the same ID" )
470
+ }
468
471
469
472
out , err := ts .Lookup (ent .ID )
470
473
if err != nil {
You can’t perform that action at this time.
0 commit comments