fix: minor fixes

This commit is contained in:
Iamnotagenius 2024-01-15 00:35:00 +03:00
parent aa64be3c24
commit fddc67b40d
No known key found for this signature in database
GPG key ID: 8D92479E65411DFA
2 changed files with 14 additions and 5 deletions

View file

@ -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{

View file

@ -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 {