forked from TrueCloudLab/frostfs-rest-gw
[#11] Receive hex encoded bearer token signature
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
70e25e6caf
commit
61bc5af44b
4 changed files with 7 additions and 5 deletions
|
@ -741,7 +741,7 @@ func signToken(t *testing.T, key *keys.PrivateKey, data []byte) *handlers.Bearer
|
||||||
|
|
||||||
return &handlers.BearerToken{
|
return &handlers.BearerToken{
|
||||||
Token: base64.StdEncoding.EncodeToString(data),
|
Token: base64.StdEncoding.EncodeToString(data),
|
||||||
Signature: base64.StdEncoding.EncodeToString(sign),
|
Signature: hex.EncodeToString(sign),
|
||||||
Key: hex.EncodeToString(key.PublicKey().Bytes()),
|
Key: hex.EncodeToString(key.PublicKey().Bytes()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -752,7 +752,7 @@ func signTokenWalletConnect(t *testing.T, key *keys.PrivateKey, data []byte) *ha
|
||||||
|
|
||||||
return &handlers.BearerToken{
|
return &handlers.BearerToken{
|
||||||
Token: base64.StdEncoding.EncodeToString(data),
|
Token: base64.StdEncoding.EncodeToString(data),
|
||||||
Signature: base64.StdEncoding.EncodeToString(append(sm.Data, sm.Salt...)),
|
Signature: hex.EncodeToString(append(sm.Data, sm.Salt...)),
|
||||||
Key: hex.EncodeToString(key.PublicKey().Bytes()),
|
Key: hex.EncodeToString(key.PublicKey().Bytes()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ func TestSign(t *testing.T) {
|
||||||
|
|
||||||
bt := &BearerToken{
|
bt := &BearerToken{
|
||||||
Token: bearerBase64,
|
Token: bearerBase64,
|
||||||
Signature: base64.StdEncoding.EncodeToString(signatureData),
|
Signature: hex.EncodeToString(signatureData),
|
||||||
Key: pubKeyHex,
|
Key: pubKeyHex,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -359,7 +360,7 @@ func prepareSessionToken(bt *BearerToken, isWalletConnect bool) (*session.Token,
|
||||||
return nil, fmt.Errorf("can't base64-decode bearer token: %w", err)
|
return nil, fmt.Errorf("can't base64-decode bearer token: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
signature, err := base64.StdEncoding.DecodeString(bt.Signature)
|
signature, err := hex.DecodeString(bt.Signature)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("couldn't decode bearer signature: %w", err)
|
return nil, fmt.Errorf("couldn't decode bearer signature: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -337,7 +338,7 @@ func prepareBearerToken(bt *BearerToken, isWalletConnect bool) (*token.BearerTok
|
||||||
return nil, fmt.Errorf("can't base64-decode bearer token: %w", err)
|
return nil, fmt.Errorf("can't base64-decode bearer token: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
signature, err := base64.StdEncoding.DecodeString(bt.Signature)
|
signature, err := hex.DecodeString(bt.Signature)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("couldn't decode bearer signature: %w", err)
|
return nil, fmt.Errorf("couldn't decode bearer signature: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue