Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sec(acl): convert x.Sensitive to string type for authn hash #8931

Merged
merged 1 commit into from Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion edgraph/server.go
Expand Up @@ -1587,7 +1587,7 @@ func authorizeRequest(ctx context.Context, qc *queryContext) error {

func getHash(ns, startTs uint64) string {
h := sha256.New()
h.Write([]byte(fmt.Sprintf("%#x%#x%s", ns, startTs, x.WorkerConfig.HmacSecret)))
h.Write([]byte(fmt.Sprintf("%#x%#x%s", ns, startTs, string(x.WorkerConfig.HmacSecret))))
return hex.EncodeToString(h.Sum(nil))
}

Expand Down
11 changes: 11 additions & 0 deletions edgraph/server_test.go
Expand Up @@ -18,6 +18,8 @@ package edgraph

import (
"context"
"crypto/sha256"
"encoding/hex"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -205,3 +207,12 @@ func TestParseSchemaFromAlterOperation(t *testing.T) {
}

}

func TestGetHash(t *testing.T) {
h := sha256.New()
_, err := h.Write([]byte("0xa0x14123456789"))
require.NoError(t, err)

x.WorkerConfig.HmacSecret = []byte("123456789")
require.Equal(t, hex.EncodeToString(h.Sum(nil)), getHash(10, 20))
}