55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
|
|
"github.com/lib/pq"
|
|
"tomatentum.net/outfit-voting-abi26/internal/auth"
|
|
"tomatentum.net/outfit-voting-abi26/internal/database"
|
|
"tomatentum.net/outfit-voting-abi26/internal/http"
|
|
)
|
|
|
|
var config pq.Config
|
|
var (
|
|
oidcIssuer, oidcClientID, oidcClientSecret, oidcRedirectURI string
|
|
jwtSigningKey string
|
|
imprintURL string
|
|
)
|
|
|
|
func main() {
|
|
handleflag()
|
|
|
|
database.OpenDB(config)
|
|
defer database.CloseDB()
|
|
|
|
auth.SetSigningKey(jwtSigningKey)
|
|
if err := auth.InitProvider(oidcIssuer, oidcClientID, oidcClientSecret, oidcRedirectURI); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
if err := http.Start(imprintURL); err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
}
|
|
|
|
func handleflag() {
|
|
config.SSLMode = pq.SSLModePrefer
|
|
flag.StringVar(&config.Host, "dbhost", "localhost", "Postgres host")
|
|
config.Port = uint16(*flag.Uint("dbport", 5432, "Postgres port"))
|
|
flag.StringVar(&config.Database, "dbname", "postgres", "Postgres db name")
|
|
flag.StringVar(&config.User, "dbuser", "postgres", "Postgres user")
|
|
flag.StringVar(&config.Password, "dbpass", "", "Postgres password")
|
|
|
|
flag.StringVar(&oidcIssuer, "oidcIssuer", "", "The OIDC Issuer")
|
|
flag.StringVar(&oidcClientID, "oidcClientID", "", "The OIDC Client ID")
|
|
flag.StringVar(&oidcClientSecret, "oidcClientSecret", "", "The OIDC Client Secret")
|
|
flag.StringVar(&oidcRedirectURI, "oidcRedirectURI", "", "The OIDC Redirect URI")
|
|
|
|
flag.StringVar(&jwtSigningKey, "signingKey", "UNSAFE", "The JWT signingkey")
|
|
|
|
flag.StringVar(&imprintURL, "imprinturl", "", "The URL to the sites imprint")
|
|
|
|
flag.Parse()
|
|
}
|