File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 default_ttl : 3600
55server :
66 port : " 8053"
7+ api_access :
8+ - username : " ehm"
9+ password : " f9ba61a1-a501-4e11-958b-d6b5cbf01c3f"
10+ - username : " anotheruser"
11+ password : " aNother-secure-password"
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ type Config struct {
1313 Server struct {
1414 Port string `mapstructure:"port"`
1515 } `mapstructure:"server"`
16+ ApiAccess []struct {
17+ Username string `mapstructure:"username"`
18+ Password string `mapstructure:"password"`
19+ } `mapstructure:"api_access"`
1620}
1721
1822func LoadConfig (path string ) (* Config , error ) {
Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ func main() {
1919 // Initialize Gin
2020 r := gin .Default ()
2121
22+ // Authentication
23+ accounts := gin.Accounts {}
24+ for _ , user := range cfg .ApiAccess {
25+ accounts [user .Username ] = user .Password
26+ }
27+ r .Use (gin .BasicAuth (accounts ))
28+
2229 // Initialize controller
2330 dnsController := controllers .NewDNSController (cfg )
2431
You can’t perform that action at this time.
0 commit comments