@@ -28,13 +28,13 @@ func (dba *dbAccount) clone() *dbAccount {
28
28
}
29
29
30
30
type dbExternalAccountKey struct {
31
- ID string `json:"id"`
32
- ProvisionerName string `json:"provisioner_name "`
33
- Name string `json:"name "`
34
- AccountID string `json:"accountID,omitempty"`
35
- KeyBytes []byte `json:"key"`
36
- CreatedAt time.Time `json:"createdAt"`
37
- BoundAt time.Time `json:"boundAt"`
31
+ ID string `json:"id"`
32
+ Provisioner string `json:"provisioner "`
33
+ Reference string `json:"reference "`
34
+ AccountID string `json:"accountID,omitempty"`
35
+ KeyBytes []byte `json:"key"`
36
+ CreatedAt time.Time `json:"createdAt"`
37
+ BoundAt time.Time `json:"boundAt"`
38
38
}
39
39
40
40
func (db * DB ) getAccountIDByKeyID (ctx context.Context , kid string ) (string , error ) {
@@ -165,7 +165,7 @@ func (db *DB) UpdateAccount(ctx context.Context, acc *acme.Account) error {
165
165
}
166
166
167
167
// CreateExternalAccountKey creates a new External Account Binding key with a name
168
- func (db * DB ) CreateExternalAccountKey (ctx context.Context , provisionerName string , name string ) (* acme.ExternalAccountKey , error ) {
168
+ func (db * DB ) CreateExternalAccountKey (ctx context.Context , provisionerName string , reference string ) (* acme.ExternalAccountKey , error ) {
169
169
keyID , err := randID ()
170
170
if err != nil {
171
171
return nil , err
@@ -178,24 +178,24 @@ func (db *DB) CreateExternalAccountKey(ctx context.Context, provisionerName stri
178
178
}
179
179
180
180
dbeak := & dbExternalAccountKey {
181
- ID : keyID ,
182
- ProvisionerName : provisionerName ,
183
- Name : name ,
184
- KeyBytes : random ,
185
- CreatedAt : clock .Now (),
181
+ ID : keyID ,
182
+ Provisioner : provisionerName ,
183
+ Reference : reference ,
184
+ KeyBytes : random ,
185
+ CreatedAt : clock .Now (),
186
186
}
187
187
188
188
if err = db .save (ctx , keyID , dbeak , nil , "external_account_key" , externalAccountKeyTable ); err != nil {
189
189
return nil , err
190
190
}
191
191
return & acme.ExternalAccountKey {
192
- ID : dbeak .ID ,
193
- ProvisionerName : dbeak .ProvisionerName ,
194
- Name : dbeak .Name ,
195
- AccountID : dbeak .AccountID ,
196
- KeyBytes : dbeak .KeyBytes ,
197
- CreatedAt : dbeak .CreatedAt ,
198
- BoundAt : dbeak .BoundAt ,
192
+ ID : dbeak .ID ,
193
+ Provisioner : dbeak .Provisioner ,
194
+ Reference : dbeak .Reference ,
195
+ AccountID : dbeak .AccountID ,
196
+ KeyBytes : dbeak .KeyBytes ,
197
+ CreatedAt : dbeak .CreatedAt ,
198
+ BoundAt : dbeak .BoundAt ,
199
199
}, nil
200
200
}
201
201
@@ -206,18 +206,18 @@ func (db *DB) GetExternalAccountKey(ctx context.Context, provisionerName string,
206
206
return nil , err
207
207
}
208
208
209
- if dbeak .ProvisionerName != provisionerName {
209
+ if dbeak .Provisioner != provisionerName {
210
210
return nil , acme .NewError (acme .ErrorUnauthorizedType , "name of provisioner does not match provisioner for which the EAB key was created" )
211
211
}
212
212
213
213
return & acme.ExternalAccountKey {
214
- ID : dbeak .ID ,
215
- ProvisionerName : dbeak .ProvisionerName ,
216
- Name : dbeak .Name ,
217
- AccountID : dbeak .AccountID ,
218
- KeyBytes : dbeak .KeyBytes ,
219
- CreatedAt : dbeak .CreatedAt ,
220
- BoundAt : dbeak .BoundAt ,
214
+ ID : dbeak .ID ,
215
+ Provisioner : dbeak .Provisioner ,
216
+ Reference : dbeak .Reference ,
217
+ AccountID : dbeak .AccountID ,
218
+ KeyBytes : dbeak .KeyBytes ,
219
+ CreatedAt : dbeak .CreatedAt ,
220
+ BoundAt : dbeak .BoundAt ,
221
221
}, nil
222
222
}
223
223
@@ -240,21 +240,24 @@ func (db *DB) GetExternalAccountKeys(ctx context.Context, provisionerName string
240
240
return nil , err
241
241
}
242
242
243
- keys := make ( []* acme.ExternalAccountKey , len ( entries ))
244
- for i , entry := range entries {
243
+ keys := []* acme.ExternalAccountKey {}
244
+ for _ , entry := range entries {
245
245
dbeak := new (dbExternalAccountKey )
246
246
if err = json .Unmarshal (entry .Value , dbeak ); err != nil {
247
247
return nil , errors .Wrapf (err , "error unmarshaling external account key %s into dbExternalAccountKey" , string (entry .Key ))
248
248
}
249
- keys [i ] = & acme.ExternalAccountKey {
250
- ID : dbeak .ID ,
251
- KeyBytes : dbeak .KeyBytes ,
252
- ProvisionerName : dbeak .ProvisionerName ,
253
- Name : dbeak .Name ,
254
- AccountID : dbeak .AccountID ,
255
- CreatedAt : dbeak .CreatedAt ,
256
- BoundAt : dbeak .BoundAt ,
249
+ if dbeak .Provisioner != provisionerName {
250
+ continue
257
251
}
252
+ keys = append (keys , & acme.ExternalAccountKey {
253
+ ID : dbeak .ID ,
254
+ KeyBytes : dbeak .KeyBytes ,
255
+ Provisioner : dbeak .Provisioner ,
256
+ Reference : dbeak .Reference ,
257
+ AccountID : dbeak .AccountID ,
258
+ CreatedAt : dbeak .CreatedAt ,
259
+ BoundAt : dbeak .BoundAt ,
260
+ })
258
261
}
259
262
260
263
return keys , nil
@@ -266,18 +269,18 @@ func (db *DB) UpdateExternalAccountKey(ctx context.Context, provisionerName stri
266
269
return err
267
270
}
268
271
269
- if old .ProvisionerName != provisionerName {
272
+ if old .Provisioner != provisionerName {
270
273
return acme .NewError (acme .ErrorUnauthorizedType , "name of provisioner does not match provisioner for which the EAB key was created" )
271
274
}
272
275
273
276
nu := dbExternalAccountKey {
274
- ID : eak .ID ,
275
- ProvisionerName : eak .ProvisionerName ,
276
- Name : eak .Name ,
277
- AccountID : eak .AccountID ,
278
- KeyBytes : eak .KeyBytes ,
279
- CreatedAt : eak .CreatedAt ,
280
- BoundAt : eak .BoundAt ,
277
+ ID : eak .ID ,
278
+ Provisioner : eak .Provisioner ,
279
+ Reference : eak .Reference ,
280
+ AccountID : eak .AccountID ,
281
+ KeyBytes : eak .KeyBytes ,
282
+ CreatedAt : eak .CreatedAt ,
283
+ BoundAt : eak .BoundAt ,
281
284
}
282
285
283
286
return db .save (ctx , nu .ID , nu , old , "external_account_key" , externalAccountKeyTable )
0 commit comments