Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #40:http protocol is hardcoded in the URL #41

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ _Feel free to suggest any other ways to make the process safer._
- MAX_EXPIRE - maximum lifetime period, default 24h
- PIN_SIZE - size (in characters) of the pin, default 5
- PIN_ATTEMPTS - maximum number of failed attempts to enter pin, default 3
- PROTOCOL - http or https
1. Setup SSL:
- The system can make valid certificates for you automatically with integrated [nginx-le](https://github.com/umputun/nginx-le). Just set:
- LETSENCRYPT=true
Expand Down
2 changes: 2 additions & 0 deletions app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var opts struct {
WebRoot string `long:"web" env:"WEB" default:"./ui/static/" description:"web ui location"`
Dbg bool `long:"dbg" description:"debug mode"`
Domain string `short:"d" long:"domain" env:"DOMAIN" description:"site domain" required:"true"`
Protocol string `short:"p" long:"protocol" env:"PROTOCOL" description:"site protocol" choice:"http" choice:"https" default:"https" required:"true"` // nolint
}

var revision string
Expand All @@ -42,6 +43,7 @@ func main() {

srv, err := server.New(messager.New(dataStore, crypter, params), revision, server.Config{
Domain: opts.Domain,
Protocol: opts.Protocol,
PinSize: opts.PinSize,
MaxPinAttempts: opts.MaxPinAttempts,
MaxExpire: opts.MaxExpire,
Expand Down
1 change: 1 addition & 0 deletions app/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
type Config struct {
Domain string
WebRoot string
Protocol string
// Validation parameters
PinSize int
MaxPinAttempts int
Expand Down
2 changes: 1 addition & 1 deletion app/server/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (s Server) generateLinkCtrl(w http.ResponseWriter, r *http.Request) {
return
}

msgURL := fmt.Sprintf("http://%s/message/%s", s.cfg.Domain, msg.Key)
msgURL := fmt.Sprintf("%s://%s/message/%s", s.cfg.Protocol, s.cfg.Domain, msg.Key)

s.render(w, http.StatusOK, "secure-link.tmpl.html", "secure-link", msgURL)
}
Expand Down
1 change: 1 addition & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ services:
- PIN_ATTEMPTS=3
- MAX_EXPIRE=24h
- DOMAIN=localhost:8080
- PROTOCOL=http
ports:
- "8080:8080"
Loading