swagger:operation GET /1.0?public server server_get_untrusted Get the server environment Shows a small subset of the server environment and configuration which is required by untrusted clients to reach a server. The `?public` part of the URL isn't required, it's simply used to separate the two be
(d *Daemon, r *http.Request)
| 226 | // "500": |
| 227 | // $ref: "#/responses/InternalServerError" |
| 228 | func api10Get(d *Daemon, r *http.Request) response.Response { |
| 229 | s := d.State() |
| 230 | |
| 231 | // Pull the full server config. |
| 232 | fullSrvConfig, err := daemonConfigRender(s) |
| 233 | if err != nil { |
| 234 | return response.InternalError(err) |
| 235 | } |
| 236 | |
| 237 | // Get the authentication methods. |
| 238 | authMethods := []string{api.AuthenticationMethodTLS} |
| 239 | |
| 240 | oidcIssuer, oidcClientID, _, _, _ := s.GlobalConfig.OIDCServer() |
| 241 | if oidcIssuer != "" && oidcClientID != "" { |
| 242 | authMethods = append(authMethods, api.AuthenticationMethodOIDC) |
| 243 | } |
| 244 | |
| 245 | srv := api.ServerUntrusted{ |
| 246 | APIStatus: "stable", |
| 247 | APIVersion: version.APIVersion, |
| 248 | Public: false, |
| 249 | Auth: "untrusted", |
| 250 | AuthMethods: authMethods, |
| 251 | } |
| 252 | |
| 253 | // Populate the untrusted config (user.ui.XYZ). |
| 254 | srv.Config = map[string]string{} |
| 255 | for k, v := range fullSrvConfig { |
| 256 | if strings.HasPrefix(k, "user.ui.") { |
| 257 | srv.Config[k] = v |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | // If untrusted, return now |
| 262 | if d.checkTrustedClient(r) != nil { |
| 263 | return response.SyncResponseETag(true, srv, nil) |
| 264 | } |
| 265 | |
| 266 | // If not authorized, return now. |
| 267 | err = s.Authorizer.CheckPermission(r.Context(), r, auth.ObjectServer(), auth.EntitlementCanView) |
| 268 | if err != nil { |
| 269 | return response.SmartError(err) |
| 270 | } |
| 271 | |
| 272 | // Add the API extensions to authenticated requests. |
| 273 | srv.APIExtensions = version.APIExtensions[:d.apiExtensions] |
| 274 | |
| 275 | // If a target was specified, forward the request to the relevant node. |
| 276 | resp := forwardedResponseIfTargetIsRemote(s, r) |
| 277 | if resp != nil { |
| 278 | return resp |
| 279 | } |
| 280 | |
| 281 | srv.Auth = "trusted" |
| 282 | |
| 283 | localHTTPSAddress := s.LocalConfig.HTTPSAddress() |
| 284 | |
| 285 | addresses, err := localUtil.ListenAddresses(localHTTPSAddress) |
nothing calls this directly
no test coverage detected
searching dependent graphs…