Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fb9061c
feat(router): add introspection auth skip feature
dkorittki Sep 5, 2025
dd1afd1
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Sep 8, 2025
5b7f08b
fix: respect either old or new config parameter
dkorittki Sep 8, 2025
324bccd
fix: set introspection enabled default value in testenv
dkorittki Sep 8, 2025
99d5a62
fix: resolve env var name clash
dkorittki Sep 8, 2025
e459cd9
fix: Replace example secret with better one
dkorittki Sep 8, 2025
8ce05ec
chore: simplify conditional return
dkorittki Sep 8, 2025
0f0af18
feat: use auth_mode instead of skip_auth config parameter
dkorittki Sep 10, 2025
a9e6af1
chore: simplify introspection router configuration
dkorittki Sep 10, 2025
124cf0e
fix: only start span when operation gets authenticated
dkorittki Sep 10, 2025
8bc3f46
fix: add tests for introspection config
dkorittki Sep 10, 2025
041bde8
fix: use obvious fake tokens in test
dkorittki Sep 10, 2025
ecae951
fix: handle auth on http get introspection queries
dkorittki Sep 10, 2025
d52bbb3
fix: use existing operation kit
dkorittki Sep 11, 2025
c6b07c1
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Sep 12, 2025
f715421
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Sep 12, 2025
1625830
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Sep 15, 2025
823bedd
chore: refactor and clean up code
dkorittki Sep 17, 2025
71358c1
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Sep 17, 2025
93be47b
chore: Uppercase config parameter descriptions
dkorittki Sep 19, 2025
82e18cd
chore: use better test names
dkorittki Sep 19, 2025
8f8c577
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Sep 19, 2025
5614792
chore: implement new config parameter layout
dkorittki Sep 23, 2025
2d3c46a
chore: adjust tests
dkorittki Sep 23, 2025
77a2517
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Sep 23, 2025
a25f100
chore: use better config parameter descriptions
dkorittki Sep 23, 2025
bea860b
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Sep 29, 2025
04abf5a
chore: improve warning logs
dkorittki Sep 29, 2025
22cdff9
fix: fix typo + use dot syntax on config docs
dkorittki Oct 8, 2025
cafa760
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Oct 8, 2025
e8f8a73
fix: fix what previous merge broke
dkorittki Oct 8, 2025
ef28a46
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Oct 24, 2025
732cf54
Merge branch 'main' into dominik/eng-7980-allow-to-exclude-introspect…
dkorittki Oct 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,078 changes: 995 additions & 83 deletions router-tests/authentication_test.go

Large diffs are not rendered by default.

19 changes: 17 additions & 2 deletions router-tests/batch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,18 @@ func TestBatch(t *testing.T) {
t.Parallel()

authenticators, authServer := ConfigureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t,
&testenv.Config{
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
},
BatchingConfig: config.BatchingConfig{
Enabled: true,
Expand Down Expand Up @@ -692,14 +699,22 @@ func TestBatch(t *testing.T) {
t.Parallel()

authenticators, authServer := ConfigureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
BatchingConfig: config.BatchingConfig{
Enabled: true,
MaxConcurrency: 10,
MaxEntriesPerBatch: 100,
},
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
core.WithRouterTrafficConfig(&config.RouterTrafficConfiguration{
MaxRequestBodyBytes: 5 << 20, // 5MiB
DecompressionEnabled: true,
Expand Down
28 changes: 25 additions & 3 deletions router-tests/block_operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,17 @@ func TestBlockOperations(t *testing.T) {
t.Parallel()

authenticators, authServer := ConfigureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
},
ModifySecurityConfiguration: func(securityConfiguration *config.SecurityConfiguration) {
securityConfiguration.BlockMutations = config.BlockOperationConfiguration{
Expand Down Expand Up @@ -303,10 +311,17 @@ func TestBlockOperations(t *testing.T) {
t.Parallel()

authenticators, authServer := ConfigureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
core.WithAuthorizationConfig(&config.AuthorizationConfiguration{
RejectOperationIfUnauthorized: false,
}),
Expand Down Expand Up @@ -395,14 +410,21 @@ func TestBlockOperations(t *testing.T) {
t.Parallel()

authenticators, authServer := ConfigureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
ModifyWebsocketConfiguration: func(cfg *config.WebSocketConfiguration) {
cfg.Authentication.FromInitialPayload.Enabled = true
cfg.Enabled = true
},
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
core.WithAuthorizationConfig(&config.AuthorizationConfiguration{
RejectOperationIfUnauthorized: false,
}),
Expand Down
10 changes: 9 additions & 1 deletion router-tests/header_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,21 @@ func TestHeaderSetWithExpression(t *testing.T) {
authenticator, err := authentication.NewHttpHeaderAuthenticator(authOptions)
require.NoError(t, err)

accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: []authentication.Authenticator{authenticator},
AuthenticationRequired: true,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

token, err := authServer.TokenForKID(rsa1.KID(), map[string]any{"user_id": "TestId"}, false)
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
RouterOptions: append(
global(customHeader, `request.auth.claims.user_id`),
core.WithAccessController(core.NewAccessController([]authentication.Authenticator{authenticator}, true)),
core.WithAccessController(accessController),
),
}, func(t *testing.T, xEnv *testenv.Environment) {
res := xEnv.MakeGraphQLRequestOK(testenv.GraphQLRequest{
Expand Down
15 changes: 12 additions & 3 deletions router-tests/modules/router_on_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package module_test

import (
"encoding/json"
"github.com/wundergraph/cosmo/router-tests/modules/router-on-request"
"go.uber.org/zap/zapcore"
"net/http"
"testing"

router_on_request "github.com/wundergraph/cosmo/router-tests/modules/router-on-request"
"go.uber.org/zap/zapcore"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/wundergraph/cosmo/router-tests/testenv"
Expand Down Expand Up @@ -69,9 +70,17 @@ func TestRouterOnRequestHook(t *testing.T) {
},
}

accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: true,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, true)),
core.WithAccessController(accessController),
core.WithModulesConfig(cfg.Modules),
core.WithCustomModules(&router_on_request.RouterOnRequestModule{}),
},
Expand Down
30 changes: 27 additions & 3 deletions router-tests/modules/set_authentication_scopes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,17 @@ func TestCustomModuleSetAuthenticationScopes(t *testing.T) {
},
}
authenticators, authServer := configureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
core.WithModulesConfig(cfg.Modules),
core.WithCustomModules(&setScopesModule.SetAuthenticationScopesModule{}, &verifyScopes.VerifyScopesModule{}),
},
Expand Down Expand Up @@ -73,9 +81,17 @@ func TestCustomModuleSetAuthenticationScopes(t *testing.T) {
},
}
authenticators, authServer := configureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
core.WithModulesConfig(cfg.Modules),
core.WithCustomModules(&setScopesModule.SetAuthenticationScopesModule{}, &verifyScopes.VerifyScopesModule{}),
},
Expand Down Expand Up @@ -116,9 +132,17 @@ func TestCustomModuleSetAuthenticationScopes(t *testing.T) {
},
}
authenticators, authServer := configureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
core.WithModulesConfig(cfg.Modules),
core.WithCustomModules(&setScopesModule.SetAuthenticationScopesModule{}, &verifyScopes.VerifyScopesModule{}),
},
Expand Down
20 changes: 18 additions & 2 deletions router-tests/modules/set_scopes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@ func TestCustomModuleSetScopes(t *testing.T) {
},
}
authenticators, authServer := configureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
core.WithModulesConfig(cfg.Modules),
core.WithCustomModules(&module.MyModule{}, &setScopesModule.SetScopesModule{}),
},
Expand Down Expand Up @@ -101,9 +109,17 @@ func TestCustomModuleSetScopes(t *testing.T) {
},
}
authenticators, authServer := configureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
core.WithModulesConfig(cfg.Modules),
core.WithCustomModules(&module.MyModule{}, &setScopesModule.SetScopesModule{}),
},
Expand Down
10 changes: 9 additions & 1 deletion router-tests/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4119,6 +4119,14 @@ func TestPrometheus(t *testing.T) {
const claimVal = "customClaimValue"

authenticators, authServer := ConfigureAuth(t)
accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: true,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

exporter := tracetest.NewInMemoryExporter(t)
metricReader := metric.NewManualReader()
promRegistry := prometheus.NewRegistry()
Expand All @@ -4128,7 +4136,7 @@ func TestPrometheus(t *testing.T) {
MetricReader: metricReader,
PrometheusRegistry: promRegistry,
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, true)),
core.WithAccessController(accessController),
},
CustomMetricAttributes: []config.CustomAttribute{
{
Expand Down
10 changes: 9 additions & 1 deletion router-tests/ratelimit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,17 @@ func TestRateLimit(t *testing.T) {
require.NoError(t, err)
authenticators := []authentication.Authenticator{authenticator}

accessController, err := core.NewAccessController(core.AccessControllerOptions{
Authenticators: authenticators,
AuthenticationRequired: false,
SkipIntrospectionQueries: false,
IntrospectionSkipSecret: "",
})
require.NoError(t, err)

testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithAccessController(core.NewAccessController(authenticators, false)),
core.WithAccessController(accessController),
core.WithRateLimitConfig(&config.RateLimitConfiguration{
Enabled: true,
Strategy: "simple",
Expand Down
6 changes: 4 additions & 2 deletions router-tests/security_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package integration

import (
"fmt"
"github.com/wundergraph/cosmo/router/core"
"net/http"
"testing"

"github.com/stretchr/testify/require"

"github.com/wundergraph/cosmo/router-tests/testenv"
"github.com/wundergraph/cosmo/router/core"
"github.com/wundergraph/cosmo/router/pkg/config"
)

Expand Down Expand Up @@ -341,7 +341,9 @@ func TestQueryNamingLimits(t *testing.T) {
securityConfiguration.OperationNameLengthLimit = maxLength
},
RouterOptions: []core.Option{
core.WithIntrospection(false),
core.WithIntrospection(false, config.IntrospectionConfiguration{
Enabled: false,
}),
},
}, func(t *testing.T, xEnv *testenv.Environment) {
expectedErrorMessage := fmt.Sprintf(`{"errors":[{"message":"operation name of length %d exceeds max length of %d"}]}`, len(query1Name), maxLength)
Expand Down
Loading
Loading