@@ -23,7 +23,10 @@ import (
2323 yamlUtils "gitlab.com/postgres-ai/database-lab/v3/pkg/util/yaml"
2424)
2525
26- const connectionCheckTimeout = 10 * time .Second
26+ const (
27+ connectionCheckTimeout = 10 * time .Second
28+ configManagementDenied = "configuration management via UI/API disabled by admin"
29+ )
2730
2831func (s * Server ) getProjectedAdminConfig (w http.ResponseWriter , r * http.Request ) {
2932 cfg , err := s .projectedAdminConfig ()
@@ -57,6 +60,11 @@ func (s *Server) getAdminConfigYaml(w http.ResponseWriter, r *http.Request) {
5760}
5861
5962func (s * Server ) setProjectedAdminConfig (w http.ResponseWriter , r * http.Request ) {
63+ if ! s .Config .AllowModifyingConfig {
64+ api .SendBadRequestError (w , r , configManagementDenied )
65+ return
66+ }
67+
6068 var cfg interface {}
6169 if err := api .ReadJSON (r , & cfg ); err != nil {
6270 api .SendBadRequestError (w , r , err .Error ())
@@ -91,6 +99,11 @@ func (s *Server) setProjectedAdminConfig(w http.ResponseWriter, r *http.Request)
9199}
92100
93101func (s * Server ) testDBSource (w http.ResponseWriter , r * http.Request ) {
102+ if ! s .Config .AllowModifyingConfig {
103+ api .SendBadRequestError (w , r , configManagementDenied )
104+ return
105+ }
106+
94107 if s .Retrieval .State .Mode != models .Logical {
95108 api .SendBadRequestError (w , r , "the endpoint is only available in the Logical mode of the data retrieval" )
96109 return
0 commit comments