satellite/console: Added support URLs and other fields to config file (#3090)
This commit is contained in:
parent
29b96a666b
commit
423d35fb3f
@ -12,12 +12,20 @@ const (
|
||||
CancelPasswordRecoveryPath = "cancelPasswordRecoveryPath"
|
||||
// SignInPath is key for sign in server route
|
||||
SignInPath = "signInPath"
|
||||
// LetUsKnowURL is key to store let us know URL
|
||||
LetUsKnowURL = "letUsKnowURL"
|
||||
// ContactInfoURL is a key to store contact info URL
|
||||
ContactInfoURL = "contactInfoURL"
|
||||
// TermsAndConditionsURL is a key to store terms and conditions URL
|
||||
TermsAndConditionsURL = "termsAndConditionsURL"
|
||||
)
|
||||
|
||||
// AccountActivationEmail is mailservice template with activation data
|
||||
type AccountActivationEmail struct {
|
||||
Origin string
|
||||
ActivationLink string
|
||||
Origin string
|
||||
ActivationLink string
|
||||
ContactInfoURL string
|
||||
TermsAndConditionsURL string
|
||||
}
|
||||
|
||||
// Template returns email template name
|
||||
@ -32,6 +40,9 @@ type ForgotPasswordEmail struct {
|
||||
UserName string
|
||||
ResetLink string
|
||||
CancelPasswordRecoveryLink string
|
||||
LetUsKnowURL string
|
||||
ContactInfoURL string
|
||||
TermsAndConditionsURL string
|
||||
}
|
||||
|
||||
// Template returns email template name
|
||||
@ -42,10 +53,13 @@ func (*ForgotPasswordEmail) Subject() string { return "Password recovery request
|
||||
|
||||
// ProjectInvitationEmail is mailservice template for project invitation email
|
||||
type ProjectInvitationEmail struct {
|
||||
Origin string
|
||||
UserName string
|
||||
ProjectName string
|
||||
SignInLink string
|
||||
Origin string
|
||||
UserName string
|
||||
ProjectName string
|
||||
SignInLink string
|
||||
LetUsKnowURL string
|
||||
ContactInfoURL string
|
||||
TermsAndConditionsURL string
|
||||
}
|
||||
|
||||
// Template returns email template name
|
||||
|
@ -329,14 +329,21 @@ func rootMutation(log *zap.Logger, service *console.Service, mailService *mailse
|
||||
userName = user.FullName
|
||||
}
|
||||
|
||||
contactInfoURL := rootObject[ContactInfoURL].(string)
|
||||
letUsKnowURL := rootObject[LetUsKnowURL].(string)
|
||||
termsAndConditionsURL := rootObject[TermsAndConditionsURL].(string)
|
||||
|
||||
mailService.SendRenderedAsync(
|
||||
p.Context,
|
||||
[]post.Address{{Address: user.Email, Name: userName}},
|
||||
&ProjectInvitationEmail{
|
||||
Origin: origin,
|
||||
UserName: userName,
|
||||
ProjectName: project.Name,
|
||||
SignInLink: signIn,
|
||||
Origin: origin,
|
||||
UserName: userName,
|
||||
ProjectName: project.Name,
|
||||
SignInLink: signIn,
|
||||
LetUsKnowURL: letUsKnowURL,
|
||||
TermsAndConditionsURL: termsAndConditionsURL,
|
||||
ContactInfoURL: contactInfoURL,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -66,6 +66,9 @@ func TestGrapqhlMutation(t *testing.T) {
|
||||
rootObject["origin"] = "http://doesntmatter.com/"
|
||||
rootObject[consoleql.ActivationPath] = "?activationToken="
|
||||
rootObject[consoleql.SignInPath] = "login"
|
||||
rootObject[consoleql.LetUsKnowURL] = "letUsKnowURL"
|
||||
rootObject[consoleql.ContactInfoURL] = "contactInfoURL"
|
||||
rootObject[consoleql.TermsAndConditionsURL] = "termsAndConditionsURL"
|
||||
|
||||
schema, err := consoleql.CreateSchema(log, service, mailService)
|
||||
require.NoError(t, err)
|
||||
|
@ -181,6 +181,10 @@ func rootQuery(service *console.Service, mailService *mailservice.Service, types
|
||||
userName = user.FullName
|
||||
}
|
||||
|
||||
contactInfoURL := rootObject[ContactInfoURL].(string)
|
||||
letUsKnowURL := rootObject[LetUsKnowURL].(string)
|
||||
termsAndConditionsURL := rootObject[TermsAndConditionsURL].(string)
|
||||
|
||||
mailService.SendRenderedAsync(
|
||||
p.Context,
|
||||
[]post.Address{{Address: user.Email, Name: userName}},
|
||||
@ -189,6 +193,9 @@ func rootQuery(service *console.Service, mailService *mailservice.Service, types
|
||||
ResetLink: passwordRecoveryLink,
|
||||
CancelPasswordRecoveryLink: cancelPasswordRecoveryLink,
|
||||
UserName: userName,
|
||||
LetUsKnowURL: letUsKnowURL,
|
||||
TermsAndConditionsURL: termsAndConditionsURL,
|
||||
ContactInfoURL: contactInfoURL,
|
||||
},
|
||||
)
|
||||
|
||||
@ -228,13 +235,18 @@ func rootQuery(service *console.Service, mailService *mailservice.Service, types
|
||||
userName = user.FullName
|
||||
}
|
||||
|
||||
contactInfoURL := rootObject[ContactInfoURL].(string)
|
||||
termsAndConditionsURL := rootObject[TermsAndConditionsURL].(string)
|
||||
|
||||
// TODO: think of a better solution
|
||||
mailService.SendRenderedAsync(
|
||||
p.Context,
|
||||
[]post.Address{{Address: user.Email, Name: userName}},
|
||||
&AccountActivationEmail{
|
||||
Origin: origin,
|
||||
ActivationLink: link,
|
||||
Origin: origin,
|
||||
ActivationLink: link,
|
||||
TermsAndConditionsURL: termsAndConditionsURL,
|
||||
ContactInfoURL: contactInfoURL,
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -46,6 +46,9 @@ func TestGraphqlQuery(t *testing.T) {
|
||||
rootObject := make(map[string]interface{})
|
||||
rootObject["origin"] = "http://doesntmatter.com/"
|
||||
rootObject[consoleql.ActivationPath] = "?activationToken="
|
||||
rootObject[consoleql.LetUsKnowURL] = "letUsKnowURL"
|
||||
rootObject[consoleql.ContactInfoURL] = "contactInfoURL"
|
||||
rootObject[consoleql.TermsAndConditionsURL] = "termsAndConditionsURL"
|
||||
|
||||
creator := consoleql.TypeCreator{}
|
||||
err = creator.Create(log, service, mailService)
|
||||
|
@ -59,6 +59,13 @@ type Config struct {
|
||||
AuthTokenSecret string `help:"secret used to sign auth tokens" releaseDefault:"" devDefault:"my-suppa-secret-key"`
|
||||
|
||||
PasswordCost int `internal:"true" help:"password hashing cost (0=automatic)" default:"0"`
|
||||
|
||||
SatelliteName string `help:"used to display at web satellite console" default:"Storj"`
|
||||
SatelliteOperator string `help:"name of organization which set up satellite" default:"Storj Labs" `
|
||||
LetUsKnowURL string `help:"url link to let us know page" default:"https://storjlabs.atlassian.net/servicedesk/customer/portals"`
|
||||
ContactInfoURL string `help:"url link to contacts page" default:"https://forum.storj.io"`
|
||||
TermsAndConditionsURL string `help:"url link to terms and conditions page" default:"https://storj.io/storage-sla/"`
|
||||
SEO string `help:"used to communicate with web crawlers and other web robots" default:"User-agent: *\nDisallow: \nDisallow: /cgi-bin/"`
|
||||
}
|
||||
|
||||
// Server represents console web server
|
||||
@ -415,6 +422,9 @@ func (server *Server) grapqlHandler(w http.ResponseWriter, r *http.Request) {
|
||||
rootObject[consoleql.PasswordRecoveryPath] = "password-recovery/?token="
|
||||
rootObject[consoleql.CancelPasswordRecoveryPath] = "cancel-password-recovery/?token="
|
||||
rootObject[consoleql.SignInPath] = "login"
|
||||
rootObject[consoleql.LetUsKnowURL] = server.config.LetUsKnowURL
|
||||
rootObject[consoleql.ContactInfoURL] = server.config.ContactInfoURL
|
||||
rootObject[consoleql.TermsAndConditionsURL] = server.config.TermsAndConditionsURL
|
||||
|
||||
result := graphql.Do(graphql.Params{
|
||||
Schema: server.schema,
|
||||
@ -442,7 +452,7 @@ func (server *Server) seoHandler(w http.ResponseWriter, req *http.Request) {
|
||||
header.Set(contentType, mime.TypeByExtension(".txt"))
|
||||
header.Set("X-Content-Type-Options", "nosniff")
|
||||
|
||||
_, err := w.Write([]byte("User-agent: *\nDisallow: \nDisallow: /cgi-bin/)"))
|
||||
_, err := w.Write([]byte(server.config.SEO))
|
||||
if err != nil {
|
||||
server.log.Error(err.Error())
|
||||
}
|
||||
|
18
scripts/testdata/satellite-config.yaml.lock
vendored
18
scripts/testdata/satellite-config.yaml.lock
vendored
@ -40,15 +40,33 @@
|
||||
# secret used to sign auth tokens
|
||||
# console.auth-token-secret: ""
|
||||
|
||||
# url link to contacts page
|
||||
# console.contact-info-url: https://forum.storj.io
|
||||
|
||||
# external endpoint of the satellite if hosted
|
||||
# console.external-address: ""
|
||||
|
||||
# url link to let us know page
|
||||
# console.let-us-know-url: https://storjlabs.atlassian.net/servicedesk/customer/portals
|
||||
|
||||
# used to display at web satellite console
|
||||
# console.satellite-name: Storj
|
||||
|
||||
# name of organization which set up satellite
|
||||
# console.satellite-operator: Storj Labs
|
||||
|
||||
# used to communicate with web crawlers and other web robots
|
||||
# console.seo: "User-agent: *\nDisallow: \nDisallow: /cgi-bin/"
|
||||
|
||||
# path to static resources
|
||||
# console.static-dir: ""
|
||||
|
||||
# stripe api key
|
||||
# console.stripe-key: ""
|
||||
|
||||
# url link to terms and conditions page
|
||||
# console.terms-and-conditions-url: https://storj.io/storage-sla/
|
||||
|
||||
# the public address of the node, useful for nodes behind NAT
|
||||
contact.external-address: ""
|
||||
|
||||
|
@ -586,8 +586,8 @@ To reset your password, click the following link and follow the instructions. &#
|
||||
|
||||
<div style="Margin-left: 20px;Margin-right: 20px;Margin-top: 0px;Margin-bottom: 0px;">
|
||||
<div style="mso-line-height-rule: exactly;mso-text-raise: 4px;">
|
||||
<a href="{{ .Origin }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .Origin }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Help</strong></span></p>
|
||||
<a href="{{ .ContactInfoURL }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .ContactInfoURL }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Help</strong></span></p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -598,8 +598,8 @@ To reset your password, click the following link and follow the instructions. &#
|
||||
|
||||
<div style="Margin-left: 20px;Margin-right: 20px;Margin-top: 0px;Margin-bottom: 0px;">
|
||||
<div style="mso-line-height-rule: exactly;mso-text-raise: 4px;">
|
||||
<a href="{{ .Origin }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .Origin }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Contact Info</strong></span></p>
|
||||
<a href="{{ .ContactInfoURL }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .ContactInfoURL }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Contact Info</strong></span></p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -610,7 +610,7 @@ To reset your password, click the following link and follow the instructions. &#
|
||||
|
||||
<div style="Margin-left: 20px;Margin-right: 20px;Margin-top: 0px;Margin-bottom: 0px;">
|
||||
<div style="mso-line-height-rule: exactly;mso-text-raise: 4px;">
|
||||
<a href="{{ .Origin }}" style="text-decoration: none; color: #66686C;">
|
||||
<a href="{{ .TermsAndConditionsURL }}" style="text-decoration: none; color: #66686C;">
|
||||
<p class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Terms & Conditions</strong><br />
|
||||
</span></p>
|
||||
</a>
|
||||
|
@ -564,8 +564,8 @@
|
||||
|
||||
<div style="Margin-left: 20px;Margin-right: 20px;Margin-top: 0px;Margin-bottom: 0px;">
|
||||
<div style="mso-line-height-rule: exactly;mso-text-raise: 4px;">
|
||||
<a href="{{ .Origin }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .Origin }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Help</strong></span></p>
|
||||
<a href="{{ .ContactInfoURL }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .ContactInfoURL }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Help</strong></span></p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -576,8 +576,8 @@
|
||||
|
||||
<div style="Margin-left: 20px;Margin-right: 20px;Margin-top: 0px;Margin-bottom: 0px;">
|
||||
<div style="mso-line-height-rule: exactly;mso-text-raise: 4px;">
|
||||
<a href="{{ .Origin }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .Origin }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Contact Info</strong></span></p>
|
||||
<a href="{{ .ContactInfoURL }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .ContactInfoURL }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Contact Info</strong></span></p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -588,7 +588,7 @@
|
||||
|
||||
<div style="Margin-left: 20px;Margin-right: 20px;Margin-top: 0px;Margin-bottom: 0px;">
|
||||
<div style="mso-line-height-rule: exactly;mso-text-raise: 4px;">
|
||||
<a href="{{ .Origin }}" style="text-decoration: none; color: #66686C;">
|
||||
<a href="{{ .TermsAndConditionsURL }}" style="text-decoration: none; color: #66686C;">
|
||||
<p class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Terms & Conditions</strong><br />
|
||||
</span></p>
|
||||
</a>
|
||||
|
@ -583,8 +583,8 @@ and setup your API keys within a team and project</span></p>
|
||||
|
||||
<div style="Margin-left: 20px;Margin-right: 20px;Margin-top: 0px;Margin-bottom: 0px;">
|
||||
<div style="mso-line-height-rule: exactly;mso-text-raise: 4px;">
|
||||
<a href="{{ .Origin }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .Origin }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Help</strong></span></p>
|
||||
<a href="{{ .ContactInfoURL }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .ContactInfoURL }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Help</strong></span></p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -595,8 +595,8 @@ and setup your API keys within a team and project</span></p>
|
||||
|
||||
<div style="Margin-left: 20px;Margin-right: 20px;Margin-top: 0px;Margin-bottom: 0px;">
|
||||
<div style="mso-line-height-rule: exactly;mso-text-raise: 4px;">
|
||||
<a href="{{ .Origin }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .Origin }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Contact Info</strong></span></p>
|
||||
<a href="{{ .ContactInfoURL }}" style="text-decoration: none; color: #66686C;">
|
||||
<p href="{{ .ContactInfoURL }}" class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Contact Info</strong></span></p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@ -607,7 +607,7 @@ and setup your API keys within a team and project</span></p>
|
||||
|
||||
<div style="Margin-left: 20px;Margin-right: 20px;Margin-top: 0px;Margin-bottom: 0px;">
|
||||
<div style="mso-line-height-rule: exactly;mso-text-raise: 4px;">
|
||||
<a href="{{ .Origin }}" style="text-decoration: none; color: #66686C;">
|
||||
<a href="{{ .TermsAndConditionsURL }}" style="text-decoration: none; color: #66686C;">
|
||||
<p class="size-12" style="Margin-top: 0;Margin-bottom: 0;font-family: montserrat,dejavu sans,verdana,sans-serif;font-size: 12px;line-height: 19px;" lang="x-size-12"><span class="font-montserrat"><strong>Terms & Conditions</strong><br />
|
||||
</span></p>
|
||||
</a>
|
||||
|
Loading…
Reference in New Issue
Block a user