Added oauth for gitea
This commit is contained in:
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
@@ -24,6 +25,11 @@ type config struct {
|
||||
DBName string
|
||||
|
||||
ImageKitId string
|
||||
|
||||
GiteaOauthInstance string
|
||||
GiteaOauthClientID string
|
||||
GiteaOauthClientSecret string
|
||||
GiteaOauthAllowedEmails []string
|
||||
}
|
||||
|
||||
var Config *config
|
||||
@@ -74,6 +80,16 @@ func Load() *config {
|
||||
dbPassword := os.Getenv("CAOM_DB_PASSWORD")
|
||||
dbName := os.Getenv("CAOM_DB_NAME")
|
||||
|
||||
giteaOauthInstance := os.Getenv("CAOM_GITEA_OAUTH_INSTANCE")
|
||||
giteaOauthClientID := os.Getenv("CAOM_GITEA_OAUTH_CLIENT_ID")
|
||||
giteaOauthClientSecret := os.Getenv("CAOM_GITEA_OAUTH_CLIENT_SECRET")
|
||||
|
||||
giteaOauthAllowedEmails := os.Getenv("CAOM_GITEA_OAUTH_ALLOWED_EMAILS")
|
||||
var giteaOauthAllowedEmailsParsed []string
|
||||
if giteaOauthAllowedEmails != "" {
|
||||
giteaOauthAllowedEmailsParsed = strings.Split(giteaOauthAllowedEmails, ",")
|
||||
}
|
||||
|
||||
if dbEngine == "" || dbHost == "" || dbPort == "" || dbUser == "" || dbPassword == "" || dbName == "" {
|
||||
slog.Info("No database connection provided, using sqlite")
|
||||
dbEngine = "sqlite"
|
||||
@@ -106,6 +122,11 @@ func Load() *config {
|
||||
DBName: dbName,
|
||||
|
||||
ImageKitId: imageKitId,
|
||||
|
||||
GiteaOauthInstance: giteaOauthInstance,
|
||||
GiteaOauthClientID: giteaOauthClientID,
|
||||
GiteaOauthClientSecret: giteaOauthClientSecret,
|
||||
GiteaOauthAllowedEmails: giteaOauthAllowedEmailsParsed,
|
||||
}
|
||||
return appContext
|
||||
|
||||
|
||||
Reference in New Issue
Block a user