From 119c68be9dc793234e268fd2b600a071bab25462 Mon Sep 17 00:00:00 2001 From: kolaente Date: Fri, 9 Feb 2024 14:41:55 +0100 Subject: [PATCH] feat: rename frontend url config to public url --- config.yml.sample | 6 +++--- pkg/cmd/testmail.go | 2 +- pkg/config/config.go | 16 ++++++++-------- pkg/models/notifications.go | 14 +++++++------- pkg/models/tasks.go | 2 +- pkg/modules/migration/handler/notifications.go | 2 +- pkg/notifications/mail_render.go | 2 +- pkg/routes/api/v1/info.go | 2 +- pkg/user/notifications.go | 14 +++++++------- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/config.yml.sample b/config.yml.sample index ffb47ae4f1..77850cfea6 100644 --- a/config.yml.sample +++ b/config.yml.sample @@ -16,8 +16,8 @@ service: unixsocket: # Permission bits for the Unix socket. Note that octal values must be prefixed by "0o", e.g. 0o660 unixsocketmode: - # The URL of the frontend, used to send password reset emails. - frontendurl: "" + # The public facing URL where your users can reach Vikunja. Used in emails and for the communication between api and frontend. + publicurl: "" # The base path on the file system where the binary and assets are. # Vikunja will also look in this path for a config file, so you could provide only this variable to point to a folder # with a config file which will then be used. @@ -132,7 +132,7 @@ cors: # Whether to enable or disable cors headers. # Note: If you want to put the frontend and the api on separate domains or ports, you will need to enable this. # Otherwise the frontend won't be able to make requests to the api through the browser. - enable: true + enable: false # A list of origins which may access the api. These need to include the protocol (`http://` or `https://`) and port, if any. origins: - "*" diff --git a/pkg/cmd/testmail.go b/pkg/cmd/testmail.go index 370d4c5f63..1b4bc4e30c 100644 --- a/pkg/cmd/testmail.go +++ b/pkg/cmd/testmail.go @@ -47,7 +47,7 @@ var testmailCmd = &cobra.Command{ Subject("Test from Vikunja"). Line("This is a test mail!"). Line("If you received this, Vikunja is correctly set up to send emails."). - Action("Go to your instance", config.ServiceFrontendurl.GetString()) + Action("Go to your instance", config.ServicePublicURL.GetString()) opts, err := notifications.RenderMail(message) if err != nil { diff --git a/pkg/config/config.go b/pkg/config/config.go index 096bf51877..0e82a6637f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -44,7 +44,7 @@ const ( ServiceInterface Key = `service.interface` ServiceUnixSocket Key = `service.unixsocket` ServiceUnixSocketMode Key = `service.unixsocketmode` - ServiceFrontendurl Key = `service.frontendurl` + ServicePublicURL Key = `service.publicurl` ServiceEnableCaldav Key = `service.enablecaldav` ServiceRootpath Key = `service.rootpath` ServiceMaxItemsPerPage Key = `service.maxitemsperpage` @@ -294,7 +294,7 @@ func InitDefaultConfig() { ServiceJWTTTLLong.setDefault(2592000) // 30 days ServiceInterface.setDefault(":3456") ServiceUnixSocket.setDefault("") - ServiceFrontendurl.setDefault("") + ServicePublicURL.setDefault("") ServiceEnableCaldav.setDefault(true) ServiceRootpath.setDefault(getBinaryDirLocation()) @@ -381,7 +381,7 @@ func InitDefaultConfig() { FilesBasePath.setDefault("files") FilesMaxSize.setDefault("20MB") // Cors - CorsEnable.setDefault(true) + CorsEnable.setDefault(false) CorsOrigins.setDefault([]string{"*"}) CorsMaxAge.setDefault(0) // Migration @@ -455,20 +455,20 @@ func InitConfig() { RateLimitStore.Set(KeyvalueType.GetString()) } - if ServiceFrontendurl.GetString() != "" && !strings.HasSuffix(ServiceFrontendurl.GetString(), "/") { - ServiceFrontendurl.Set(ServiceFrontendurl.GetString() + "/") + if ServicePublicURL.GetString() != "" && !strings.HasSuffix(ServicePublicURL.GetString(), "/") { + ServicePublicURL.Set(ServicePublicURL.GetString() + "/") } if MigrationTodoistRedirectURL.GetString() == "" { - MigrationTodoistRedirectURL.Set(ServiceFrontendurl.GetString() + "migrate/todoist") + MigrationTodoistRedirectURL.Set(ServicePublicURL.GetString() + "migrate/todoist") } if MigrationTrelloRedirectURL.GetString() == "" { - MigrationTrelloRedirectURL.Set(ServiceFrontendurl.GetString() + "migrate/trello") + MigrationTrelloRedirectURL.Set(ServicePublicURL.GetString() + "migrate/trello") } if MigrationMicrosoftTodoRedirectURL.GetString() == "" { - MigrationMicrosoftTodoRedirectURL.Set(ServiceFrontendurl.GetString() + "migrate/microsoft-todo") + MigrationMicrosoftTodoRedirectURL.Set(ServicePublicURL.GetString() + "migrate/microsoft-todo") } if DefaultSettingsTimezone.GetString() == "" { diff --git a/pkg/models/notifications.go b/pkg/models/notifications.go index bdbde921ac..d86415b9fd 100644 --- a/pkg/models/notifications.go +++ b/pkg/models/notifications.go @@ -44,7 +44,7 @@ func (n *ReminderDueNotification) ToMail() *notifications.Mail { Subject(`Reminder for "`+n.Task.Title+`" (`+n.Project.Title+`)`). Greeting("Hi "+n.User.GetName()+","). Line(`This is a friendly reminder of the task "`+n.Task.Title+`" (`+n.Project.Title+`).`). - Action("Open Task", config.ServiceFrontendurl.GetString()+"tasks/"+strconv.FormatInt(n.Task.ID, 10)). + Action("Open Task", config.ServicePublicURL.GetString()+"tasks/"+strconv.FormatInt(n.Task.ID, 10)). Line("Have a nice day!") } @@ -173,7 +173,7 @@ func (n *ProjectCreatedNotification) ToMail() *notifications.Mail { return notifications.NewMail(). Subject(n.Doer.GetName()+` created the project "`+n.Project.Title+`"`). Line(n.Doer.GetName()+` created the project "`+n.Project.Title+`"`). - Action("View Project", config.ServiceFrontendurl.GetString()+"projects/") + Action("View Project", config.ServicePublicURL.GetString()+"projects/") } // ToDB returns the ProjectCreatedNotification notification in a format which can be saved in the db @@ -200,7 +200,7 @@ func (n *TeamMemberAddedNotification) ToMail() *notifications.Mail { From(n.Doer.GetNameAndFromEmail()). Greeting("Hi "+n.Member.GetName()+","). Line(n.Doer.GetName()+" has just added you to the "+n.Team.Name+" team in Vikunja."). - Action("View Team", config.ServiceFrontendurl.GetString()+"teams/"+strconv.FormatInt(n.Team.ID, 10)+"/edit") + Action("View Team", config.ServicePublicURL.GetString()+"teams/"+strconv.FormatInt(n.Team.ID, 10)+"/edit") } // ToDB returns the TeamMemberAddedNotification notification in a format which can be saved in the db @@ -227,7 +227,7 @@ func (n *UndoneTaskOverdueNotification) ToMail() *notifications.Mail { Subject(`Task "`+n.Task.Title+`" (`+n.Project.Title+`) is overdue`). Greeting("Hi "+n.User.GetName()+","). Line(`This is a friendly reminder of the task "`+n.Task.Title+`" (`+n.Project.Title+`) which is overdue since `+utils.HumanizeDuration(until)+` and not yet done.`). - Action("Open Task", config.ServiceFrontendurl.GetString()+"tasks/"+strconv.FormatInt(n.Task.ID, 10)). + Action("Open Task", config.ServicePublicURL.GetString()+"tasks/"+strconv.FormatInt(n.Task.ID, 10)). Line("Have a nice day!") } @@ -263,7 +263,7 @@ func (n *UndoneTasksOverdueNotification) ToMail() *notifications.Mail { overdueLine := "" for _, task := range sortedTasks { until := time.Until(task.DueDate).Round(1*time.Hour) * -1 - overdueLine += `* [` + task.Title + `](` + config.ServiceFrontendurl.GetString() + "tasks/" + strconv.FormatInt(task.ID, 10) + `) (` + n.Projects[task.ProjectID].Title + `), overdue since ` + utils.HumanizeDuration(until) + "\n" + overdueLine += `* [` + task.Title + `](` + config.ServicePublicURL.GetString() + "tasks/" + strconv.FormatInt(task.ID, 10) + `) (` + n.Projects[task.ProjectID].Title + `), overdue since ` + utils.HumanizeDuration(until) + "\n" } return notifications.NewMail(). @@ -271,7 +271,7 @@ func (n *UndoneTasksOverdueNotification) ToMail() *notifications.Mail { Greeting("Hi "+n.User.GetName()+","). Line("You have the following overdue tasks:"). Line(overdueLine). - Action("Open Vikunja", config.ServiceFrontendurl.GetString()). + Action("Open Vikunja", config.ServicePublicURL.GetString()). Line("Have a nice day!") } @@ -338,7 +338,7 @@ func (n *DataExportReadyNotification) ToMail() *notifications.Mail { Subject("Your Vikunja Data Export is ready"). Greeting("Hi "+n.User.GetName()+","). Line("Your Vikunja Data Export is ready for you to download. Click the button below to download it:"). - Action("Download", config.ServiceFrontendurl.GetString()+"user/export/download"). + Action("Download", config.ServicePublicURL.GetString()+"user/export/download"). Line("The download will be available for the next 7 days."). Line("Have a nice day!") } diff --git a/pkg/models/tasks.go b/pkg/models/tasks.go index c87d88b682..28c3bf3092 100644 --- a/pkg/models/tasks.go +++ b/pkg/models/tasks.go @@ -156,7 +156,7 @@ func (t *Task) GetFullIdentifier() string { } func (t *Task) GetFrontendURL() string { - return config.ServiceFrontendurl.GetString() + "tasks/" + strconv.FormatInt(t.ID, 10) + return config.ServicePublicURL.GetString() + "tasks/" + strconv.FormatInt(t.ID, 10) } type taskFilterConcatinator string diff --git a/pkg/modules/migration/handler/notifications.go b/pkg/modules/migration/handler/notifications.go index c758e59069..4768b0ffd5 100644 --- a/pkg/modules/migration/handler/notifications.go +++ b/pkg/modules/migration/handler/notifications.go @@ -36,7 +36,7 @@ func (n *MigrationDoneNotification) ToMail() *notifications.Mail { return notifications.NewMail(). Subject("The migration from "+kind+" to Vikunja was completed"). Line("Vikunja has imported all lists/projects, tasks, notes, reminders and files from "+kind+" you have access to."). - Action("View your imported projects in Vikunja", config.ServiceFrontendurl.GetString()). + Action("View your imported projects in Vikunja", config.ServicePublicURL.GetString()). Line("Have fun with your new (old) projects!") } diff --git a/pkg/notifications/mail_render.go b/pkg/notifications/mail_render.go index e9ec62e895..410056d8be 100644 --- a/pkg/notifications/mail_render.go +++ b/pkg/notifications/mail_render.go @@ -115,7 +115,7 @@ func RenderMail(m *Mail) (mailOpts *mail.Opts, err error) { data["ActionText"] = m.actionText data["ActionURL"] = m.actionURL data["Boundary"] = boundary - data["FrontendURL"] = config.ServiceFrontendurl.GetString() + data["FrontendURL"] = config.ServicePublicURL.GetString() var introLinesHTML []templatehtml.HTML for _, line := range m.introLines { diff --git a/pkg/routes/api/v1/info.go b/pkg/routes/api/v1/info.go index 5b632b2458..59958b0dce 100644 --- a/pkg/routes/api/v1/info.go +++ b/pkg/routes/api/v1/info.go @@ -82,7 +82,7 @@ type legalInfo struct { func Info(c echo.Context) error { info := vikunjaInfos{ Version: version.Version, - FrontendURL: config.ServiceFrontendurl.GetString(), + FrontendURL: config.ServicePublicURL.GetString(), Motd: config.ServiceMotd.GetString(), LinkSharingEnabled: config.ServiceEnableLinkSharing.GetBool(), MaxFileSize: config.FilesMaxSize.GetString(), diff --git a/pkg/user/notifications.go b/pkg/user/notifications.go index 4b8c95e521..5e6b7c071b 100644 --- a/pkg/user/notifications.go +++ b/pkg/user/notifications.go @@ -48,7 +48,7 @@ func (n *EmailConfirmNotification) ToMail() *notifications.Mail { return nn. Line("To confirm your email address, click the link below:"). - Action("Confirm your email address", config.ServiceFrontendurl.GetString()+"?userEmailConfirm="+n.ConfirmToken). + Action("Confirm your email address", config.ServicePublicURL.GetString()+"?userEmailConfirm="+n.ConfirmToken). Line("Have a nice day!") } @@ -98,7 +98,7 @@ func (n *ResetPasswordNotification) ToMail() *notifications.Mail { Subject("Reset your password on Vikunja"). Greeting("Hi "+n.User.GetName()+","). Line("To reset your password, click the link below:"). - Action("Reset your password", config.ServiceFrontendurl.GetString()+"?userPasswordReset="+n.Token.Token). + Action("Reset your password", config.ServicePublicURL.GetString()+"?userPasswordReset="+n.Token.Token). Line("This link will be valid for 24 hours."). Line("Have a nice day!") } @@ -125,7 +125,7 @@ func (n *InvalidTOTPNotification) ToMail() *notifications.Mail { Greeting("Hi "+n.User.GetName()+","). Line("Someone just tried to log in into your account with correct username and password but a wrong TOTP passcode."). Line("**If this was not you, someone else knows your password. You should set a new one immediately!**"). - Action("Reset your password", config.ServiceFrontendurl.GetString()+"get-password-reset") + Action("Reset your password", config.ServicePublicURL.GetString()+"get-password-reset") } // ToDB returns the InvalidTOTPNotification notification in a format which can be saved in the db @@ -150,7 +150,7 @@ func (n *PasswordAccountLockedAfterInvalidTOTOPNotification) ToMail() *notificat Greeting("Hi " + n.User.GetName() + ","). Line("Someone tried to log in with your credentials but failed to provide a valid TOTP passcode."). Line("After 10 failed attempts, we've disabled your account and reset your password. To set a new one, follow the instructions in the reset email we just sent you."). - Line("If you did not receive an email with reset instructions, you can always request a new one at [" + config.ServiceFrontendurl.GetString() + "get-password-reset](" + config.ServiceFrontendurl.GetString() + "get-password-reset).") + Line("If you did not receive an email with reset instructions, you can always request a new one at [" + config.ServicePublicURL.GetString() + "get-password-reset](" + config.ServicePublicURL.GetString() + "get-password-reset).") } // ToDB returns the PasswordAccountLockedAfterInvalidTOTOPNotification notification in a format which can be saved in the db @@ -176,7 +176,7 @@ func (n *FailedLoginAttemptNotification) ToMail() *notifications.Mail { Line("Someone just tried to log in into your account with a wrong password three times in a row."). Line("If this was not you, this could be someone else trying to break into your account."). Line("To enhance the security of you account you may want to set a stronger password or enable TOTP authentication in the settings:"). - Action("Go to settings", config.ServiceFrontendurl.GetString()+"user/settings") + Action("Go to settings", config.ServicePublicURL.GetString()+"user/settings") } // ToDB returns the FailedLoginAttemptNotification notification in a format which can be saved in the db @@ -201,7 +201,7 @@ func (n *AccountDeletionConfirmNotification) ToMail() *notifications.Mail { Subject("Please confirm the deletion of your Vikunja account"). Greeting("Hi "+n.User.GetName()+","). Line("You have requested the deletion of your account. To confirm this, please click the link below:"). - Action("Confirm the deletion of my account", config.ServiceFrontendurl.GetString()+"?accountDeletionConfirm="+n.ConfirmToken). + Action("Confirm the deletion of my account", config.ServicePublicURL.GetString()+"?accountDeletionConfirm="+n.ConfirmToken). Line("This link will be valid for 24 hours."). Line("Once you confirm the deletion we will schedule the deletion of your account in three days and send you another email until then."). Line("If you proceed with the deletion of your account, we will remove all of your projects and tasks you created. Everything you shared with another user or team will transfer ownership to them."). @@ -239,7 +239,7 @@ func (n *AccountDeletionNotification) ToMail() *notifications.Mail { Line("You recently requested the deletion of your Vikunja account."). Line("We will delete your account "+durationString+"."). Line("If you changed your mind, simply click the link below to cancel the deletion and follow the instructions there:"). - Action("Abort the deletion", config.ServiceFrontendurl.GetString()). + Action("Abort the deletion", config.ServicePublicURL.GetString()). Line("Have a nice day!") }