@@ -21,8 +21,8 @@ import (
21
21
//
22
22
// Sets req.Context(xpub) and req.Context(xpub_hash)
23
23
func (c * Client ) AuthenticateRequest (ctx context.Context , req * http.Request , adminXPubs []string ,
24
- adminRequired , requireSigning , signingDisabled bool ) ( * http. Request , error ) {
25
-
24
+ adminRequired , requireSigning , signingDisabled bool ,
25
+ ) ( * http. Request , error ) {
26
26
// Get the xPub/Access Key from the header
27
27
xPub := strings .TrimSpace (req .Header .Get (AuthHeader ))
28
28
authAccessKey := strings .TrimSpace (req .Header .Get (AuthAccessKey ))
@@ -105,7 +105,6 @@ func (c *Client) AuthenticateRequest(ctx context.Context, req *http.Request, adm
105
105
106
106
// checkSignature check the signature for the provided auth payload
107
107
func (c * Client ) checkSignature (ctx context.Context , xPubOrAccessKey string , auth * AuthPayload ) error {
108
-
109
108
// Check that we have the basic signature components
110
109
if err := checkSignatureRequirements (auth ); err != nil {
111
110
return err
@@ -120,7 +119,6 @@ func (c *Client) checkSignature(ctx context.Context, xPubOrAccessKey string, aut
120
119
121
120
// checkSignatureRequirements will check the payload for basic signature requirements
122
121
func checkSignatureRequirements (auth * AuthPayload ) error {
123
-
124
122
// Check that we have a signature
125
123
if auth == nil || auth .Signature == "" {
126
124
return ErrMissingSignature
@@ -141,7 +139,6 @@ func checkSignatureRequirements(auth *AuthPayload) error {
141
139
142
140
// verifyKeyXPub will verify the xPub key and the signature payload
143
141
func verifyKeyXPub (xPub string , auth * AuthPayload ) error {
144
-
145
142
// Validate that the xPub is an HD key (length, validation)
146
143
if _ , err := utils .ValidateXPub (xPub ); err != nil {
147
144
return err
@@ -182,7 +179,6 @@ func verifyKeyXPub(xPub string, auth *AuthPayload) error {
182
179
183
180
// verifyAccessKey will verify the access key and the signature payload
184
181
func verifyAccessKey (ctx context.Context , key string , auth * AuthPayload , opts ... ModelOps ) error {
185
-
186
182
// Get access key from DB
187
183
// todo: add caching in the future, faster than DB
188
184
accessKey , err := getAccessKey (ctx , utils .Hash (key ), opts ... )
@@ -214,7 +210,6 @@ func verifyAccessKey(ctx context.Context, key string, auth *AuthPayload, opts ..
214
210
215
211
// SetSignature will set the signature on the header for the request
216
212
func SetSignature (header * http.Header , xPriv * bip32.ExtendedKey , bodyString string ) error {
217
-
218
213
// Create the signature
219
214
authData , err := createSignature (xPriv , bodyString )
220
215
if err != nil {
@@ -229,7 +224,6 @@ func SetSignature(header *http.Header, xPriv *bip32.ExtendedKey, bodyString stri
229
224
230
225
// SetSignatureFromAccessKey will set the signature on the header for the request from an access key
231
226
func SetSignatureFromAccessKey (header * http.Header , privateKeyHex , bodyString string ) error {
232
-
233
227
// Create the signature
234
228
authData , err := createSignatureAccessKey (privateKeyHex , bodyString )
235
229
if err != nil {
@@ -243,7 +237,6 @@ func SetSignatureFromAccessKey(header *http.Header, privateKeyHex, bodyString st
243
237
}
244
238
245
239
func setSignatureHeaders (header * http.Header , authData * AuthPayload ) error {
246
-
247
240
// Create the auth header hash
248
241
header .Set (AuthHeaderHash , authData .AuthHash )
249
242
@@ -287,8 +280,3 @@ func GetXpubIDFromRequest(req *http.Request) (string, bool) {
287
280
func IsAdminRequest (req * http.Request ) (bool , bool ) {
288
281
return getBoolFromRequest (req , ParamAdminRequest )
289
282
}
290
-
291
- // GetXpubHashFromRequest gets the stored xPub hash from the request if found
292
- func GetXpubHashFromRequest (req * http.Request ) (string , bool ) {
293
- return getFromRequest (req , ParamXPubHashKey )
294
- }
0 commit comments