Working auth system

This commit is contained in:
2022-06-11 16:56:39 +02:00
parent b0f4eb069e
commit 6a692fdf5f
20 changed files with 474 additions and 76 deletions
+10 -1
View File
@@ -18,6 +18,8 @@ var Email string
var UserPagesBaseUrl string
var AuthServiceHost string
func loadEnv(target *string, name, defaultValue string) {
value := os.Getenv(name)
if len(strings.TrimSpace(value)) == 0 {
@@ -30,17 +32,22 @@ func loadEnv(target *string, name, defaultValue string) {
func Load() {
godotenv.Load()
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
// Production
loadEnv(&Mode, "MODE", "production")
loadEnv(&Host, "HOST", "localhost:8080")
// Services
loadEnv(&GitUrl, "GIT_URL", "https://git.example.org")
loadEnv(&ChatUrl, "CHAT_URL", "https://chat.example.org")
loadEnv(&Email, "EMAIL", "mail@example.org")
// Poisson
loadEnv(&UserPagesBaseUrl, "USER_PAGES_BASE_URL", "https://poisson.phc.dm.unipi.it/~")
// AuthService
loadEnv(&AuthServiceHost, "AUTH_SERVICE_HOST", "http://localhost:3535")
}
func Object() util.H {
@@ -53,5 +60,7 @@ func Object() util.H {
"Email": Email,
"UserPagesBaseUrl": UserPagesBaseUrl,
"AuthServiceHost": AuthServiceHost,
}
}