From 7faaeed2bf136e8fcc64a4aff310cfae3b790dba Mon Sep 17 00:00:00 2001 From: JT Olio Date: Tue, 22 Dec 2020 21:24:37 -0700 Subject: [PATCH] satellite/access grant wizard: don't hardcode the satellites Change-Id: Id9fbf68882cdb2fce846b7a2604cf965cc53ab1a --- satellite/api.go | 1 + satellite/console/consoleweb/server.go | 7 ++++++- web/satellite/index.html | 1 + .../accessGrants/steps/CreatePassphraseStep.vue | 4 ++-- .../accessGrants/steps/EnterPassphraseStep.vue | 4 ++-- web/satellite/static/wasm/accessGrant.worker.js | 16 +--------------- 6 files changed, 13 insertions(+), 20 deletions(-) diff --git a/satellite/api.go b/satellite/api.go index 6858cab37..627f3482c 100644 --- a/satellite/api.go +++ b/satellite/api.go @@ -632,6 +632,7 @@ func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB, peer.Marketing.PartnersService, peer.Console.Listener, config.Payments.StripeCoinPayments.StripePublicKey, + peer.URL(), ) peer.Servers.Add(lifecycle.Item{ diff --git a/satellite/console/consoleweb/server.go b/satellite/console/consoleweb/server.go index 45f4a305c..10d74c8b1 100644 --- a/satellite/console/consoleweb/server.go +++ b/satellite/console/consoleweb/server.go @@ -30,6 +30,7 @@ import ( "golang.org/x/sync/errgroup" "storj.io/common/errs2" + "storj.io/common/storj" "storj.io/common/uuid" "storj.io/storj/private/web" "storj.io/storj/satellite/console" @@ -103,6 +104,7 @@ type Server struct { server http.Server cookieAuth *consolewebauth.CookieAuth rateLimiter *web.IPRateLimiter + nodeURL storj.NodeURL stripePublicKey string @@ -119,7 +121,7 @@ type Server struct { } // NewServer creates new instance of console server. -func NewServer(logger *zap.Logger, config Config, service *console.Service, mailService *mailservice.Service, referralsService *referrals.Service, partners *rewards.PartnersService, listener net.Listener, stripePublicKey string) *Server { +func NewServer(logger *zap.Logger, config Config, service *console.Service, mailService *mailservice.Service, referralsService *referrals.Service, partners *rewards.PartnersService, listener net.Listener, stripePublicKey string, nodeURL storj.NodeURL) *Server { server := Server{ log: logger, config: config, @@ -130,6 +132,7 @@ func NewServer(logger *zap.Logger, config Config, service *console.Service, mail partners: partners, stripePublicKey: stripePublicKey, rateLimiter: web.NewIPRateLimiter(config.RateLimit), + nodeURL: nodeURL, } logger.Debug("Starting Satellite UI.", zap.Stringer("Address", server.listener.Addr())) @@ -281,6 +284,7 @@ func (server *Server) appHandler(w http.ResponseWriter, r *http.Request) { var data struct { SatelliteName string + SatelliteNodeURL string SegmentIOPublicKey string StripePublicKey string VerificationPageURL string @@ -293,6 +297,7 @@ func (server *Server) appHandler(w http.ResponseWriter, r *http.Request) { } data.SatelliteName = server.config.SatelliteName + data.SatelliteNodeURL = server.nodeURL.String() data.SegmentIOPublicKey = server.config.SegmentIOPublicKey data.StripePublicKey = server.stripePublicKey data.VerificationPageURL = server.config.VerificationPageURL diff --git a/web/satellite/index.html b/web/satellite/index.html index be987334b..19f13c2fb 100644 --- a/web/satellite/index.html +++ b/web/satellite/index.html @@ -4,6 +4,7 @@ + diff --git a/web/satellite/src/components/accessGrants/steps/CreatePassphraseStep.vue b/web/satellite/src/components/accessGrants/steps/CreatePassphraseStep.vue index 23e16cb7c..5275a476a 100644 --- a/web/satellite/src/components/accessGrants/steps/CreatePassphraseStep.vue +++ b/web/satellite/src/components/accessGrants/steps/CreatePassphraseStep.vue @@ -194,14 +194,14 @@ export default class CreatePassphraseStep extends Vue { this.isLoading = true; - const satelliteName = MetaUtils.getMetaContent('satellite-name'); + const satelliteNodeURL = MetaUtils.getMetaContent('satellite-nodeurl'); this.worker.postMessage({ 'type': 'GenerateAccess', 'apiKey': this.restrictedKey, 'passphrase': this.passphrase, 'projectID': this.$store.getters.selectedProject.id, - 'satelliteName': satelliteName, + 'satelliteNodeURL': satelliteNodeURL, }); // Give time for web worker to return value. diff --git a/web/satellite/src/components/accessGrants/steps/EnterPassphraseStep.vue b/web/satellite/src/components/accessGrants/steps/EnterPassphraseStep.vue index 0c48ed219..752bb1207 100644 --- a/web/satellite/src/components/accessGrants/steps/EnterPassphraseStep.vue +++ b/web/satellite/src/components/accessGrants/steps/EnterPassphraseStep.vue @@ -93,14 +93,14 @@ export default class EnterPassphraseStep extends Vue { this.isLoading = true; - const satelliteName = MetaUtils.getMetaContent('satellite-name'); + const satelliteNodeURL = MetaUtils.getMetaContent('satellite-nodeurl'); this.worker.postMessage({ 'type': 'GenerateAccess', 'apiKey': this.restrictedKey, 'passphrase': this.passphrase, 'projectID': this.$store.getters.selectedProject.id, - 'satelliteName': satelliteName, + 'satelliteNodeURL': satelliteNodeURL, }); // Give time for web worker to return value. diff --git a/web/satellite/static/wasm/accessGrant.worker.js b/web/satellite/static/wasm/accessGrant.worker.js index aabea2d31..b2c7ee905 100644 --- a/web/satellite/static/wasm/accessGrant.worker.js +++ b/web/satellite/static/wasm/accessGrant.worker.js @@ -29,8 +29,7 @@ self.onmessage = function (event) { apiKey = data.apiKey; const passphrase = data.passphrase; const projectID = data.projectID; - const satelliteName = data.satelliteName; - const nodeURL = getSatelliteNodeURL(satelliteName); + const nodeURL = data.satelliteNodeURL; result = self.generateAccessGrant(nodeURL, apiKey, passphrase, projectID); @@ -63,16 +62,3 @@ self.onmessage = function (event) { self.postMessage(new Error('provided message event type is not supported')); } }; - -function getSatelliteNodeURL(satellite) { - switch (satellite) { - case 'Asia-East-1': - return '121RTSDpyNZVcEU84Ticf2L1ntiuUimbWgfATz21tuvgk3vzoA6@asia-east-1.tardigrade.io:7777'; - case 'Europe-West-1': - return '12L9ZFwhzVpuEKMUNUqkaTLGzwY9G24tbiigLiXpmZWKwmcNDDs@europe-west-1.tardigrade.io:7777'; - case 'US-Central-1': - return '12EayRS2V1kEsWESU9QMRseFhdxYxKicsiFmxrsLZHeLUtdps3S@us-central-1.tardigrade.io:7777'; - default: - return '12jHxTS7txdGgzeaXCSMR6yomWnD7nJcpz8QB7GrqxTAgftE5Y2@127.0.0.1:10000'; - } -}