From 9e029804152925d861c1c81e42fb8850da33603a Mon Sep 17 00:00:00 2001 From: echpochmak31 Date: Mon, 15 Jan 2024 20:19:23 +0300 Subject: [PATCH] modify html --- auth-server/config.json | 6 ++-- auth-server/server.go | 46 +++++------------------- auth-server/static/login.html | 60 ++++++++++++++++++++++++-------- auth-server/static/redirect.html | 11 ++++++ 4 files changed, 67 insertions(+), 56 deletions(-) create mode 100644 auth-server/static/redirect.html diff --git a/auth-server/config.json b/auth-server/config.json index 886ad96..74ad87c 100644 --- a/auth-server/config.json +++ b/auth-server/config.json @@ -1,7 +1,7 @@ { - "ContractCheckSum": "none", + "ContractCheckSum": "5e4375b9e8214ed4183659114735a94ac26033d7", "AuthServerPort": 9096, - "WalletFile": "none", - "EndpointUrl": "url", + "WalletFile": "../../frostfs-aio/morph/node-wallet.json", + "EndpointUrl": "http://localhost:30333", "AccountSecret": "one" } \ No newline at end of file diff --git a/auth-server/server.go b/auth-server/server.go index f456527..373c911 100644 --- a/auth-server/server.go +++ b/auth-server/server.go @@ -3,10 +3,6 @@ package main import ( "auth-server/logic" "context" - "net/url" - "os" - "strconv" - "github.com/go-oauth2/oauth2/v4/errors" "github.com/go-oauth2/oauth2/v4/manage" "github.com/go-oauth2/oauth2/v4/server" @@ -16,10 +12,12 @@ import ( "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" - "log" "log/slog" "net/http" + "net/url" + "os" + "strconv" ) func main() { @@ -98,12 +96,12 @@ func main() { r.Form.Add("grant_type", r.URL.Query().Get("grant_type")) r.Form.Add("scope", r.URL.Query().Get("scope")) - srv.HandleTokenRequest(w, r) // verifying secret + srv.HandleTokenRequest(w, r) // grants access token }) http.HandleFunc("/register", func(writer http.ResponseWriter, request *http.Request) { - id := request.Header.Get("client_id") - secret := request.Header.Get("client_secret") + id := request.URL.Query().Get("client_id") + secret := request.URL.Query().Get("client_secret") // check whether client exists _, err := blockchainStorage.GetByID(context.Background(), id) @@ -115,16 +113,6 @@ func main() { return } - /* redundant - // add client's credentials to in memory storage - err = logic.AddInMemoryClient(id, "", "", false) - if err != nil { - slog.Error("Fault during setting client credentials", err) - writer.WriteHeader(http.StatusInternalServerError) - return - } - */ - // add client's credentials to blockchain err = blockchainStorage.Set(&logic.StorageClientInfo{ Id: id, @@ -137,7 +125,8 @@ func main() { return } - writer.WriteHeader(http.StatusOK) + redirectURL := "/login.html" + http.Redirect(writer, request, redirectURL, http.StatusSeeOther) }) // for tests, can access only with valid token (when logged in) @@ -167,10 +156,6 @@ func main() { w.Write([]byte(errorMessage)) } - /* redundant - logic.DeleteInMemoryClient(id) - */ - }, srv)) // can access only with valid token (when logged in), deletes client and creates new one with another secret @@ -196,21 +181,6 @@ func main() { w.Write([]byte(errorMessage)) } - /* redundant - logic.DeleteInMemoryClient(id) - */ - - /* - // add client with new credentials to in memory storage - err = logic.AddInMemoryClient(id, "", "", false) - if err != nil { - slog.Error(errorMessage+" (caused by in memory storage) for client with id: "+id, err) - w.WriteHeader(http.StatusInternalServerError) - w.Write([]byte(errorMessage)) - return - } - */ - // add client with new credentials to blockchain err = blockchainStorage.Set(&logic.StorageClientInfo{ Id: id, diff --git a/auth-server/static/login.html b/auth-server/static/login.html index b46c5a0..52f58bf 100644 --- a/auth-server/static/login.html +++ b/auth-server/static/login.html @@ -10,20 +10,50 @@ -
-

Sign In

-
-
- - -
-
- - -
- -
-
+
+

Sign In

+
+ + +
+ + +
+
+ + +
+ +
+
+ +
+
+ + - \ No newline at end of file + + + diff --git a/auth-server/static/redirect.html b/auth-server/static/redirect.html new file mode 100644 index 0000000..8238d91 --- /dev/null +++ b/auth-server/static/redirect.html @@ -0,0 +1,11 @@ + + + + + Redirect + + + +

If you are not redirected, click here.

+ +