Add JWT auth and .env support for admin login
This commit is contained in:
@@ -3,21 +3,28 @@ package config
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
AdminPassword string
|
||||
Instance string
|
||||
Tag string
|
||||
Instance string
|
||||
Tag string
|
||||
|
||||
JwtSecret string
|
||||
JwtIssuer string
|
||||
JwtSecret string
|
||||
JwtIssuer string
|
||||
JwtAudience string
|
||||
}
|
||||
|
||||
var Config *config
|
||||
|
||||
func Load() *config {
|
||||
err := godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatal("Error loading .env file")
|
||||
}
|
||||
|
||||
// Get mastodon instance
|
||||
instance := os.Getenv("CAOM_INSTANCE")
|
||||
if instance == "" {
|
||||
@@ -51,15 +58,14 @@ func Load() *config {
|
||||
audience = "CatsOfMastodonBotGo"
|
||||
}
|
||||
|
||||
|
||||
// Inititlize AppContext
|
||||
var appContext = &config{
|
||||
AdminPassword: adminPassword,
|
||||
Instance: instance,
|
||||
Tag: tag,
|
||||
Instance: instance,
|
||||
Tag: tag,
|
||||
|
||||
JwtSecret: secret,
|
||||
JwtIssuer: issuer,
|
||||
JwtSecret: secret,
|
||||
JwtIssuer: issuer,
|
||||
JwtAudience: audience,
|
||||
}
|
||||
return appContext
|
||||
|
Reference in New Issue
Block a user