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

Feature Request #7

Open
ICTServ opened this issue Feb 1, 2024 · 2 comments
Open

Feature Request #7

ICTServ opened this issue Feb 1, 2024 · 2 comments

Comments

@ICTServ
Copy link

ICTServ commented Feb 1, 2024

  • Add PostgresQL - It is industry standard open source database
  • Add phone as auth. Placeholder="Login with email or phone"
  • Profile image upload
  • Since go project can be built as binary focus more configuration for binary
  • Integrate Let's encrypt certificate and add env variable to use fully qualified domain name. Example:
    When starting the executable binary file specifying a domain name will issue a Let's encrypt certificate for it
    [root@dev ~]$ /root/goiabada/goiabada serve yourdomain.com
@leodip
Copy link
Owner

leodip commented Feb 1, 2024

@ICTServ Thanks for your suggestions! I'll consider each of the points you're bringing. Postgresql support should come very soon.

@ICTServ
Copy link
Author

ICTServ commented Feb 1, 2024

Let's encrypt certificate Integration could be done by using cobra for cmd and autocert for Let's encrypt certificates

package cmd

import (
"crypto/tls"
"fmt"
"log"
"net/http"
"github.com/spf13/cobra"
"golang.org/x/crypto/acme/autocert"
)

var domain string
var port string

var serveCmd = &cobra.Command{
Use: "serve",
Short: "Serve the goiabada Auth service",
Long: Serve starts the goiabada Auth service with automatic TLS certificate management.,
Run: func(cmd *cobra.Command, args []string) {
serve()
},
}

func init() {
rootCmd.AddCommand(serveCmd)

serveCmd.Flags().StringVarP(&domain, "domain", "d", "", "Domain name for the TLS certificate")
serveCmd.Flags().StringVarP(&port, "port", "p", "8443", "Port to serve HTTPS on")
serveCmd.MarkFlagRequired("domain")

}

func serve() {

initialization.InitViper()
initialization.InitTimeZones()

manager := autocert.Manager{
    Prompt: autocert.AcceptTOS,
    Cache:  autocert.DirCache("certs"),
    HostPolicy: autocert.HostWhitelist(domain),
}

server := &http.Server{
    Addr: fmt.Sprintf(":%s", port),
    TLSConfig: &tls.Config{
        GetCertificate: manager.GetCertificate,
    },
}

// Redirect HTTP to HTTPS
go func() {
    log.Fatal(http.ListenAndServe(":http", manager.HTTPHandler(nil)))
}()

log.Printf("Serving %s on HTTPS port %s\n", domain, port)
log.Fatal(server.ListenAndServeTLS("", "")) // Let autocert manage the cert and key

}

// go build -o goiabada
// ./goiabada serve -d example.com -p 8443

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants