|
8 | 8 | "mime/multipart"
|
9 | 9 | "net/http"
|
10 | 10 | "net/url"
|
11 |
| - "os" |
12 | 11 | "strings"
|
13 | 12 |
|
14 | 13 | "github.com/getkin/kin-openapi/openapi3"
|
@@ -69,22 +68,18 @@ func Run(operationID, defaultHost, args string, t *openapi3.T, envs []string) (s
|
69 | 68 | return "", false, fmt.Errorf("failed to create request: %w", err)
|
70 | 69 | }
|
71 | 70 |
|
72 |
| - // Check for authentication (only if using HTTPS or localhost) |
73 |
| - if u.Scheme == "https" || u.Hostname() == "localhost" || u.Hostname() == "127.0.0.1" { |
74 |
| - if len(opInfo.SecurityInfos) > 0 { |
75 |
| - if err := HandleAuths(req, envMap, opInfo.SecurityInfos); err != nil { |
76 |
| - return "", false, fmt.Errorf("error setting up authentication: %w", err) |
77 |
| - } |
| 71 | + // Check for authentication |
| 72 | + if len(opInfo.SecurityInfos) > 0 { |
| 73 | + if err := HandleAuths(req, envMap, opInfo.SecurityInfos); err != nil { |
| 74 | + return "", false, fmt.Errorf("error setting up authentication: %w", err) |
78 | 75 | }
|
| 76 | + } |
79 | 77 |
|
80 |
| - // If there is a bearer token set for the whole server, and no Authorization header has been defined, use it. |
81 |
| - if token, ok := envMap["GPTSCRIPT_"+env.ToEnvLike(u.Hostname())+"_BEARER_TOKEN"]; ok { |
82 |
| - if req.Header.Get("Authorization") == "" { |
83 |
| - req.Header.Set("Authorization", "Bearer "+token) |
84 |
| - } |
| 78 | + // If there is a bearer token set for the whole server, and no Authorization header has been defined, use it. |
| 79 | + if token, ok := envMap["GPTSCRIPT_"+env.ToEnvLike(u.Hostname())+"_BEARER_TOKEN"]; ok { |
| 80 | + if req.Header.Get("Authorization") == "" { |
| 81 | + req.Header.Set("Authorization", "Bearer "+token) |
85 | 82 | }
|
86 |
| - } else { |
87 |
| - fmt.Fprintf(os.Stderr, "no auth") |
88 | 83 | }
|
89 | 84 |
|
90 | 85 | // Handle query parameters
|
|
0 commit comments