mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
update
This commit is contained in:
parent
374a2759f5
commit
dfbd928945
4 changed files with 15 additions and 13 deletions
|
|
@ -113,13 +113,13 @@ type Validator interface {
|
|||
|
||||
// SignerAPI defines the actual implementation of ExternalAPI
|
||||
type SignerAPI struct {
|
||||
chainID *big.Int
|
||||
am *accounts.Manager
|
||||
UI UIClientAPI
|
||||
validator Validator
|
||||
rejectMode bool
|
||||
chainID *big.Int
|
||||
am *accounts.Manager
|
||||
UI UIClientAPI
|
||||
validator Validator
|
||||
rejectMode bool
|
||||
validateSIWEMode bool
|
||||
credentials storage.Storage
|
||||
credentials storage.Storage
|
||||
}
|
||||
|
||||
// Metadata about a request
|
||||
|
|
|
|||
|
|
@ -1098,9 +1098,9 @@ func TestSignInWithEtheriumValidLocalhost(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSignInWithEtheriumValidMessages(t *testing.T) {
|
||||
func TestSignInWithEtheriumInValidMessages(t *testing.T) {
|
||||
t.Parallel()
|
||||
jsonFile, err := os.ReadFile(filepath.Join("testdata", "siwe", "valid_messages.json"))
|
||||
jsonFile, err := os.ReadFile(filepath.Join("testdata", "siwe", "invalid_messages.json"))
|
||||
require.NoError(t, err)
|
||||
tests := make(map[string]string)
|
||||
require.NoError(t, json.Unmarshal(jsonFile, &tests))
|
||||
|
|
@ -1122,7 +1122,7 @@ func TestSignInWithEtheriumValidMessages(t *testing.T) {
|
|||
control.inputCh <- "a_long_password"
|
||||
signature, err := api.SignData(ctx, apitypes.TextPlain.Mime, a, hexutil.Encode([]byte(message)))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 0, len(control.infoMessages))
|
||||
require.Equal(t, 1, len(control.infoMessages))
|
||||
require.Equal(t, 0, len(control.errorMessages))
|
||||
|
||||
if signature == nil || len(signature) != 65 {
|
||||
|
|
|
|||
|
|
@ -108,10 +108,12 @@ func validateSIWE(req *SignDataRequest) error {
|
|||
}
|
||||
|
||||
func validateDomain(request *SignDataRequest, scheme, domain string) error {
|
||||
siweOrigin := fmt.Sprintf("%s://%s", scheme, domain)
|
||||
requestOrigin := fmt.Sprintf("%s://%s", request.Meta.Scheme, request.Meta.Origin)
|
||||
if siweOrigin != requestOrigin {
|
||||
return fmt.Errorf("sign in request domain (%s) does not match source: %s", siweOrigin, requestOrigin)
|
||||
if request.Meta.Scheme == "http" || request.Meta.Scheme == "https" {
|
||||
siweOrigin := fmt.Sprintf("%s://%s", scheme, domain)
|
||||
requestOrigin := fmt.Sprintf("%s://%s", request.Meta.Scheme, request.Meta.Origin)
|
||||
if siweOrigin != requestOrigin {
|
||||
return fmt.Errorf("sign in request domain (%s) does not match source: %s", siweOrigin, requestOrigin)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue