Skip to content

Commit

Permalink
feat: add option to disable magic links (#1756)
Browse files Browse the repository at this point in the history
Adds an option to disable magic links, as they are more prone to email
sending abuse than other email authentication methods.
  • Loading branch information
hf committed Sep 2, 2024
1 parent c5480ef commit 2ad0737
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/api/magic_link.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ func (a *API) MagicLink(w http.ResponseWriter, r *http.Request) error {
return unprocessableEntityError(ErrorCodeEmailProviderDisabled, "Email logins are disabled")
}

if !config.External.Email.MagicLinkEnabled {
return unprocessableEntityError(ErrorCodeEmailProviderDisabled, "Login with magic link is disabled")
}

params := &MagicLinkParams{}
jsonDecoder := json.NewDecoder(r.Body)
err := jsonDecoder.Decode(params)
Expand Down
2 changes: 2 additions & 0 deletions internal/conf/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type AnonymousProviderConfiguration struct {

type EmailProviderConfiguration struct {
Enabled bool `json:"enabled" default:"true"`

MagicLinkEnabled bool `json:"magic_link_enabled" default:"true" split_words:"true"`
}

// DBConfiguration holds all the database related configuration.
Expand Down

0 comments on commit 2ad0737

Please sign in to comment.