From d2b38c3ab7d7b2f88a20e4bbff45c4b2a70cab02 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 21 Mar 2023 22:12:39 +0300 Subject: [PATCH 1/3] *: s/send-authz/oauthz/ Use more generic name, this program is not specific to send.fs.neo.org and can be extended in future. Signed-off-by: Roman Khimov --- Dockerfile | 4 ++-- Makefile | 4 ++-- README.md | 10 +++++----- auth/authenticator.go | 2 +- cmd/{neofs-send-authz => neofs-oauthz}/app.go | 4 ++-- cmd/{neofs-send-authz => neofs-oauthz}/config.go | 4 ++-- cmd/{neofs-send-authz => neofs-oauthz}/main.go | 0 cmd/{neofs-send-authz => neofs-oauthz}/misc.go | 2 +- go.mod | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) rename cmd/{neofs-send-authz => neofs-oauthz}/app.go (98%) rename cmd/{neofs-send-authz => neofs-oauthz}/config.go (97%) rename cmd/{neofs-send-authz => neofs-oauthz}/main.go (100%) rename cmd/{neofs-send-authz => neofs-oauthz}/misc.go (84%) diff --git a/Dockerfile b/Dockerfile index dcefd2e..7a34d6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,6 @@ FROM alpine WORKDIR / COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=builder /src/bin/neofs-send-authz /bin/neofs-send-authz +COPY --from=builder /src/bin/neofs-oauthz /bin/neofs-oauthz -ENTRYPOINT ["/bin/neofs-send-authz"] +ENTRYPOINT ["/bin/neofs-oauthz"] diff --git a/Makefile b/Makefile index 7302475..8fdc18c 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ REPO ?= $(shell go list -m) VERSION ?= $(shell git describe --tags --match "v*" --dirty --always) -HUB_IMAGE ?= nspccdev/neofs-send-authz +HUB_IMAGE ?= nspccdev/neofs-oauthz HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')" # List of binaries to build. For now just one. @@ -40,7 +40,7 @@ dep: go mod tidy -v && echo OK image: - @echo "⇒ Build NeoFS Send Auth docker image " + @echo "⇒ Build NeoFS OAuthz docker image " @docker build \ --build-arg REPO=$(REPO) \ --build-arg VERSION=$(VERSION) \ diff --git a/README.md b/README.md index 20f6201..8c34b95 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# neofs-send-authz -neofs-send-authz is backend which allows to login to NeoFS network via Google or Github OAuth 2.0. +# neofs-oauthz +neofs-oauthz is backend which allows to login to NeoFS network via Google or Github OAuth 2.0. ## Installation 1. To build the binary run the following command: @@ -12,13 +12,13 @@ make image ``` ## Execution -neofs-send-authz must be run with `.yaml` config file: +neofs-oauthz must be run with `.yaml` config file: ``` -$ ./neofs-send-authz -c config.yaml +$ ./neofs-oauthz -c config.yaml ``` or environment variables ``` -SEND_AUTHZ_CONFIG=config.yaml ./neofs-send-authz +NEOFS_OAUTHZ_CONFIG=config.yaml ./neofs-oauthz ``` ## Configuration diff --git a/auth/authenticator.go b/auth/authenticator.go index b09a367..71743d6 100644 --- a/auth/authenticator.go +++ b/auth/authenticator.go @@ -9,7 +9,7 @@ import ( "net/http" "github.com/nspcc-dev/neofs-sdk-go/pool" - "github.com/nspcc-dev/neofs-send-authz/bearer" + "github.com/nspcc-dev/neofs-oauthz/bearer" "go.uber.org/zap" ) diff --git a/cmd/neofs-send-authz/app.go b/cmd/neofs-oauthz/app.go similarity index 98% rename from cmd/neofs-send-authz/app.go rename to cmd/neofs-oauthz/app.go index e959268..8698b55 100644 --- a/cmd/neofs-send-authz/app.go +++ b/cmd/neofs-oauthz/app.go @@ -14,8 +14,8 @@ import ( cid "github.com/nspcc-dev/neofs-sdk-go/container/id" "github.com/nspcc-dev/neofs-sdk-go/pool" "github.com/nspcc-dev/neofs-sdk-go/user" - "github.com/nspcc-dev/neofs-send-authz/auth" - "github.com/nspcc-dev/neofs-send-authz/bearer" + "github.com/nspcc-dev/neofs-oauthz/auth" + "github.com/nspcc-dev/neofs-oauthz/bearer" "github.com/spf13/viper" "go.uber.org/zap" "golang.org/x/oauth2" diff --git a/cmd/neofs-send-authz/config.go b/cmd/neofs-oauthz/config.go similarity index 97% rename from cmd/neofs-send-authz/config.go rename to cmd/neofs-oauthz/config.go index c58174e..4670654 100644 --- a/cmd/neofs-send-authz/config.go +++ b/cmd/neofs-oauthz/config.go @@ -89,7 +89,7 @@ func newConfig() *viper.Viper { switch { case help != nil && *help: - fmt.Printf("NeoFS Send Authz %s\n", Version) + fmt.Printf("NeoFS OAuthz %s\n", Version) flags.PrintDefaults() fmt.Println() @@ -109,7 +109,7 @@ func newConfig() *viper.Viper { os.Exit(0) case version != nil && *version: - fmt.Printf("NeoFS Send Authz %s\n", Version) + fmt.Printf("NeoFS OAuthz %s\n", Version) os.Exit(0) } diff --git a/cmd/neofs-send-authz/main.go b/cmd/neofs-oauthz/main.go similarity index 100% rename from cmd/neofs-send-authz/main.go rename to cmd/neofs-oauthz/main.go diff --git a/cmd/neofs-send-authz/misc.go b/cmd/neofs-oauthz/misc.go similarity index 84% rename from cmd/neofs-send-authz/misc.go rename to cmd/neofs-oauthz/misc.go index 915f152..12cca43 100644 --- a/cmd/neofs-send-authz/misc.go +++ b/cmd/neofs-oauthz/misc.go @@ -2,7 +2,7 @@ package main // Prefix is a prefix used for environment variables containing authz // configuration. -const Prefix = "SEND_AUTHZ" +const Prefix = "NEOFS_OAUTHZ" var ( // Version is gateway version. diff --git a/go.mod b/go.mod index 6f0341f..1d99dab 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/nspcc-dev/neofs-send-authz +module github.com/nspcc-dev/neofs-oauthz go 1.18 From d1a85d9dad47b56d0ee20d8b86ba5bbcca6fae58 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 21 Mar 2023 22:21:01 +0300 Subject: [PATCH 2/3] README: extend it a bit Signed-off-by: Roman Khimov --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c34b95..6868c40 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # neofs-oauthz -neofs-oauthz is backend which allows to login to NeoFS network via Google or Github OAuth 2.0. +neofs-oauthz is an authentication backend allowing to login to NeoFS network +via Google or Github OAuth 2.0. It checks the user and then generates a bearer +token to allow uploading files with user's e-mail specified in +attributes. There is no fancy key management there, but at the same time it +allows to identify each object's uploader which is the main purpose for it +now. This backend is currently used by https://send.fs.neo.org/ demo. ## Installation 1. To build the binary run the following command: From 57f0a08837eb3dd3330cb5b6527ae811c722f081 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Tue, 21 Mar 2023 22:24:43 +0300 Subject: [PATCH 3/3] *: gofmt -s Automated send-authz/oauthz replacements need to be adjusted a bit. Signed-off-by: Roman Khimov --- auth/authenticator.go | 2 +- cmd/neofs-oauthz/app.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/auth/authenticator.go b/auth/authenticator.go index 71743d6..67323a3 100644 --- a/auth/authenticator.go +++ b/auth/authenticator.go @@ -8,8 +8,8 @@ import ( "fmt" "net/http" - "github.com/nspcc-dev/neofs-sdk-go/pool" "github.com/nspcc-dev/neofs-oauthz/bearer" + "github.com/nspcc-dev/neofs-sdk-go/pool" "go.uber.org/zap" ) diff --git a/cmd/neofs-oauthz/app.go b/cmd/neofs-oauthz/app.go index 8698b55..15afe85 100644 --- a/cmd/neofs-oauthz/app.go +++ b/cmd/neofs-oauthz/app.go @@ -11,11 +11,11 @@ import ( "github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/wallet" + "github.com/nspcc-dev/neofs-oauthz/auth" + "github.com/nspcc-dev/neofs-oauthz/bearer" cid "github.com/nspcc-dev/neofs-sdk-go/container/id" "github.com/nspcc-dev/neofs-sdk-go/pool" "github.com/nspcc-dev/neofs-sdk-go/user" - "github.com/nspcc-dev/neofs-oauthz/auth" - "github.com/nspcc-dev/neofs-oauthz/bearer" "github.com/spf13/viper" "go.uber.org/zap" "golang.org/x/oauth2"