File tree 2 files changed +9
-0
lines changed
2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ type Cfg struct {
31
31
// Web
32
32
Headless bool `env:"HEADLESS" envDefault:"false" json:"headless"` // Enable website
33
33
Analytics string `env:"ANALYTICS" envDefault:"" json:"analytics"` // <script> tag for analytics (leave blank to disable)
34
+ Username string `env:"USERNAME" envDefault:"" json:"username"` // Basic Auth username. Required to enable Basic Auth
35
+ Password string `env:"PASSWORD" envDefault:"" json:"password"` // Basic Auth password. Required to enable Basic Auth
34
36
35
37
// Document
36
38
IDLength int `env:"ID_LENGTH" envDefault:"8" json:"id_length"`
Original file line number Diff line number Diff line change @@ -107,6 +107,13 @@ func (s *Server) MountMiddleware() {
107
107
AllowCredentials : false ,
108
108
MaxAge : 300 , // Maximum value not ignored by any of major browsers
109
109
}))
110
+
111
+ // Basic Auth
112
+ if s .Config .Username != "" && s .Config .Password != "" {
113
+ s .Router .Use (middleware .BasicAuth ("spacebin" , map [string ]string {
114
+ s .Config .Username : s .Config .Password ,
115
+ }))
116
+ }
110
117
}
111
118
112
119
func (s * Server ) RegisterHeaders () {
You can’t perform that action at this time.
0 commit comments