satellite/console/consoleweb: remove trailing slash from URLs

This change removes the trailing slash from the account activation and
password recovery URLs, making them consistent with the rest. The URLs'
previous forms are still supported, however, in order to not invalidate
emails containing them.

Resolves storj/customer-issues#491

Change-Id: Ie774a87698d8e9edd1836611968fc3911c6cc56f
This commit is contained in:
Jeremy Wharton 2023-02-16 14:50:15 -06:00 committed by Jeremy Wharton
parent 38f94c1c29
commit 3fa31c2077
4 changed files with 14 additions and 10 deletions

View File

@ -58,7 +58,7 @@ func (ce *consoleEndpoints) CreditCards() string {
}
func (ce *consoleEndpoints) Activation(token string) string {
return ce.appendPath("/activation/?token=" + token)
return ce.appendPath("/activation?token=" + token)
}
func (ce *consoleEndpoints) Token() string {

View File

@ -70,9 +70,9 @@ func NewAuth(log *zap.Logger, service *console.Service, accountFreezeService *co
ContactInfoURL: contactInfoURL,
GeneralRequestURL: generalRequestURL,
SatelliteName: satelliteName,
PasswordRecoveryURL: externalAddress + "password-recovery/",
CancelPasswordRecoveryURL: externalAddress + "cancel-password-recovery/",
ActivateAccountURL: externalAddress + "activation/",
PasswordRecoveryURL: externalAddress + "password-recovery",
CancelPasswordRecoveryURL: externalAddress + "cancel-password-recovery",
ActivateAccountURL: externalAddress + "activation",
service: service,
accountFreezeService: accountFreezeService,
mailService: mailService,

View File

@ -348,8 +348,12 @@ func NewServer(logger *zap.Logger, config Config, service *console.Service, oidc
fs := http.FileServer(http.Dir(server.config.StaticDir))
router.PathPrefix("/static/").Handler(server.brotliMiddleware(http.StripPrefix("/static", fs)))
router.HandleFunc("/activation/", server.accountActivationHandler)
router.HandleFunc("/cancel-password-recovery/", server.cancelPasswordRecoveryHandler)
// These paths previously required a trailing slash, so we support both forms for now
slashRouter := router.NewRoute().Subrouter()
slashRouter.StrictSlash(true)
slashRouter.HandleFunc("/activation", server.accountActivationHandler)
slashRouter.HandleFunc("/cancel-password-recovery", server.cancelPasswordRecoveryHandler)
router.HandleFunc("/usage-report", server.bucketUsageReportHandler)
router.PathPrefix("/").Handler(http.HandlerFunc(server.appHandler))
}
@ -794,9 +798,9 @@ func (server *Server) graphqlHandler(w http.ResponseWriter, r *http.Request) {
rootObject := make(map[string]interface{})
rootObject["origin"] = server.config.ExternalAddress
rootObject[consoleql.ActivationPath] = "activation/?token="
rootObject[consoleql.PasswordRecoveryPath] = "password-recovery/?token="
rootObject[consoleql.CancelPasswordRecoveryPath] = "cancel-password-recovery/?token="
rootObject[consoleql.ActivationPath] = "activation?token="
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

View File

@ -42,7 +42,7 @@ func TestActivationRouting(t *testing.T) {
client := http.Client{}
checkActivationRedirect := func(testMsg, redirectURL string, shouldHaveCookie bool) {
url := "http://" + sat.API.Console.Listener.Addr().String() + "/activation/?token=" + activationToken
url := "http://" + sat.API.Console.Listener.Addr().String() + "/activation?token=" + activationToken
req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, http.NoBody)
require.NoError(t, err, testMsg)