Skip to content

Commit

Permalink
feat(api): add explicit insecure field for api over http
Browse files Browse the repository at this point in the history
  • Loading branch information
unkn0wn-root committed Dec 21, 2024
1 parent 0689b55 commit 2087cf8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions api.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ api:
enabled: true
host: admin.domain.com
port: 8085
insecure: true # this have to be enabled if you want to run api on HTTP (NOT RECOMMENDED)

database:
path: "./auth.db"
Expand Down
1 change: 1 addition & 0 deletions internal/config/api.config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type APIConfig struct {
AdminAPI API `yaml:"api"`
AdminDatabase DatabaseConfig `yaml:"database"`
AdminAuth AuthConfig `yaml:"auth"`
Insecure bool `yaml:"insecure"`
}

type API struct {
Expand Down
4 changes: 4 additions & 0 deletions internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ func (s *Server) startAdminServer() error {
cert = &c
}

} else if !s.apiConfig.Insecure {
return errors.New(
"TLS not configured and Insecure mode is disabled. If you want to run api on HTTP, set 'insecure' to true",
)
}

adminAddr := fmt.Sprintf(":%d", s.servicePort(s.apiConfig.AdminAPI.Port))
Expand Down

0 comments on commit 2087cf8

Please sign in to comment.