diff --git a/auth-server/logic/storage.go b/auth-server/logic/storage.go index 287c455..44280a1 100644 --- a/auth-server/logic/storage.go +++ b/auth-server/logic/storage.go @@ -3,6 +3,7 @@ package logic import ( "context" "fmt" + "github.com/go-oauth2/oauth2/v4" "github.com/nspcc-dev/neo-go/pkg/util" ) @@ -13,7 +14,7 @@ type InMemoryClient struct { IsPublic bool } -var clients map[string]InMemoryClient +var clients map[string]InMemoryClient = make(map[string]InMemoryClient) func AddInMemoryClient(id, userId, domain string, isPublic bool) error { result := InMemoryClient{ diff --git a/auth-server/server.go b/auth-server/server.go index 496926c..a074f6a 100644 --- a/auth-server/server.go +++ b/auth-server/server.go @@ -3,15 +3,17 @@ package main import ( "auth-server/logic" "context" + "strconv" + "github.com/go-oauth2/oauth2/v4/errors" "github.com/go-oauth2/oauth2/v4/manage" "github.com/go-oauth2/oauth2/v4/server" "github.com/go-oauth2/oauth2/v4/store" + "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/rpcclient" "github.com/nspcc-dev/neo-go/pkg/rpcclient/actor" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/wallet" - "strconv" "log" "log/slog" @@ -34,13 +36,19 @@ func main() { // contract integration fileWallet, _ := wallet.NewWalletFromFile(config.WalletFile) + acc := fileWallet.Accounts[0] + // FIXME: account password should be in the config + if err := acc.Decrypt("one", keys.NEP2ScryptParams()); err != nil { + log.Fatal("Wallet decryption failed") + } defer fileWallet.Close() + // FIXME: endpoint url should be in the config rpcClient, _ := rpcclient.New(context.Background(), "url", rpcclient.Options{}) rpcActor, _ := actor.NewSimple(rpcClient, fileWallet.Accounts[0]) // smart contract check sum - var contractHash util.Uint160 + var contractHash, _ = util.Uint160DecodeStringLE(config.ContractCheckSum) // using blockchain storage blockchainStorage := logic.NewBlockchainStorage(rpcActor, contractHash) @@ -65,8 +73,8 @@ func main() { }) http.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) { - id := r.Header.Get("client_id") - secret := r.Header.Get("client_secret") + id := r.URL.Query().Get("client_id") + secret := r.URL.Query().Get("client_secret") _, err := blockchainStorage.CheckPassword(id, logic.HashSecret(secret)) if err != nil {