File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ package core
17
17
import (
18
18
"context"
19
19
"fmt"
20
+ "log"
20
21
"net/http"
21
22
"strings"
22
23
@@ -150,6 +151,10 @@ func (tc *ToolboxClient) newToolboxTool(
150
151
finalConfig .AuthTokenSources ,
151
152
)
152
153
154
+ if (len (remainingAuthnParams ) > 0 || len (remainingAuthzTokens ) > 0 || len (tc .clientHeaderSources ) > 0 ) && ! strings .HasPrefix (tc .baseURL , "https://" ) {
155
+ log .Println ("WARNING: Sending ID token over HTTP. User data may be exposed. Use HTTPS for secure communication." )
156
+ }
157
+
153
158
// Construct the final tool object.
154
159
tt := & ToolboxTool {
155
160
name : name ,
Original file line number Diff line number Diff line change 17
17
package core
18
18
19
19
import (
20
+ "bytes"
20
21
"context"
21
22
"encoding/json"
22
23
"errors"
24
+ "log"
23
25
"net/http"
24
26
"net/http/httptest"
25
27
"strings"
@@ -558,6 +560,28 @@ func TestLoadToolAndLoadToolset_ErrorPaths(t *testing.T) {
558
560
}))
559
561
defer server .Close ()
560
562
563
+ // Buffer to capture logs
564
+ var buf bytes.Buffer
565
+
566
+ originalOutput := log .Writer ()
567
+ log .SetOutput (& buf )
568
+ defer log .SetOutput (originalOutput )
569
+
570
+ t .Run ("logs warning for HTTP with headers" , func (t * testing.T ) {
571
+ buf .Reset ()
572
+
573
+ client , _ := NewToolboxClient (server .URL ,
574
+ WithHTTPClient (server .Client ()),
575
+ )
576
+
577
+ _ , _ = client .LoadTool ("toolA" , context .Background ())
578
+
579
+ expectedLog := "WARNING: Sending ID token over HTTP"
580
+ if ! strings .Contains (buf .String (), expectedLog ) {
581
+ t .Errorf ("expected log message '%s' not found in output: '%s'" , expectedLog , buf .String ())
582
+ }
583
+ })
584
+
561
585
t .Run ("LoadTool fails when a default option is invalid" , func (t * testing.T ) {
562
586
// Setup client with duplicate default options
563
587
client , _ := NewToolboxClient (server .URL ,
You can’t perform that action at this time.
0 commit comments