SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix(authn): include base path in SSO callback and error-redirect URLs (#11588)
Vikrant Gupta7844fc1fe12a
diff --git a/.github/workflows/integrationci.yaml b/.github/workflows/integrationci.yamlindex d27e80a1e7..46f6dd587f 100644--- a/.github/workflows/integrationci.yaml+++ b/.github/workflows/integrationci.yaml@@ -39,6 +39,7 @@ jobs:matrix:suite:- alerts+ - basepath- callbackauthn- cloudintegrations- dashboard@@ -83,7 +84,7 @@ jobs:run: |cd tests && uv sync- name: webdriver- if: matrix.suite == 'callbackauthn'+ if: matrix.suite == 'callbackauthn' || matrix.suite == 'basepath'run: |wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list.d/google-chrome.listdiff --git a/cmd/community/server.go b/cmd/community/server.goindex 6006a48e75..256baf62bf 100644--- a/cmd/community/server.go+++ b/cmd/community/server.go@@ -91,7 +91,7 @@ func runServer(ctx context.Context, config signoz.Config, logger *slog.Logger) esqlstoreProviderFactories(),signoz.NewTelemetryStoreProviderFactories(),func(ctx context.Context, providerSettings factory.ProviderSettings, store authtypes.AuthNStore, licensing licensing.Licensing) (map[authtypes.AuthNProvider]authn.AuthN, error) {- return signoz.NewAuthNs(ctx, providerSettings, store, licensing)+ return signoz.NewAuthNs(ctx, providerSettings, store, licensing, config.Global)},func(ctx context.Context, sqlstore sqlstore.SQLStore, config authz.Config, _ licensing.Licensing, _ []authz.OnBeforeRoleDelete) (factory.ProviderFactory[authz.AuthZ, authz.Config], error) {openfgaDataStore, err := openfgaserver.NewSQLStore(sqlstore, config)diff --git a/cmd/enterprise/server.go b/cmd/enterprise/server.goindex 0e1266f8a4..acbda0aba5 100644--- a/cmd/enterprise/server.go+++ b/cmd/enterprise/server.go@@ -107,17 +107,17 @@ func runServer(ctx context.Context, config signoz.Config, logger *slog.Logger) esqlstoreProviderFactories(),signoz.NewTelemetryStoreProviderFactories(),func(ctx context.Context, providerSettings factory.ProviderSettings, store authtypes.AuthNStore, licensing licensing.Licensing) (map[authtypes.AuthNProvider]authn.AuthN, error) {- samlCallbackAuthN, err := samlcallbackauthn.New(ctx, store, licensing)+ samlCallbackAuthN, err := samlcallbackauthn.New(ctx, store, licensing, config.Global)if err != nil {return nil, err}- oidcCallbackAuthN, err := oidccallbackauthn.New(store, licensing, providerSettings)+ oidcCallbackAuthN, err := oidccallbackauthn.New(store, licensing, providerSettings, config.Global)if err != nil {return nil, err}- authNs, err := signoz.NewAuthNs(ctx, providerSettings, store, licensing)+ authNs, err := signoz.NewAuthNs(ctx, providerSettings, store, licensing, config.Global)if err != nil {return nil, err}diff --git a/ee/authn/callbackauthn/oidccallbackauthn/authn.go b/ee/authn/callbackauthn/oidccallbackauthn/authn.goindex b46690001a..a607c2c5ac 100644--- a/ee/authn/callbackauthn/oidccallbackauthn/authn.go+++ b/ee/authn/callbackauthn/oidccallbackauthn/authn.go@@ -5,10 +5,12 @@ import ("fmt""log/slog""net/url"+ "path""github.com/SigNoz/signoz/pkg/authn""github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/factory"+ "github.com/SigNoz/signoz/pkg/global""github.com/SigNoz/signoz/pkg/http/client""github.com/SigNoz/signoz/pkg/licensing""github.com/SigNoz/signoz/pkg/types/authtypes"@@ -26,13 +28,14 @@ var defaultScopes []string = []string{"email", "profile", oidc.ScopeOpenID}var _ authn.CallbackAuthN = (*AuthN)(nil)type AuthN struct {- settings factory.ScopedProviderSettings- store authtypes.AuthNStore- licensing licensing.Licensing- httpClient *client.Client+ settings factory.ScopedProviderSettings+ store authtypes.AuthNStore+ licensing licensing.Licensing+ httpClient *client.Client+ globalConfig global.Config}-func New(store authtypes.AuthNStore, licensing licensing.Licensing, providerSettings factory.ProviderSettings) (*AuthN, error) {+func New(store authtypes.AuthNStore, licensing licensing.Licensing, providerSettings factory.ProviderSettings, globalConfig global.Config) (*AuthN, error) {settings := factory.NewScopedProviderSettings(providerSettings, "github.com/SigNoz/signoz/ee/authn/callbackauthn/oidccallbackauthn")httpClient, err := client.New(providerSettings.Logger, providerSettings.TracerProvider, providerSettings.MeterProvider)@@ -41,10 +44,11 @@ func New(store authtypes.AuthNStore, licensing licensing.Licensing, providerSett}return &AuthN{- settings: settings,- store: store,- licensing: licensing,- httpClient: httpClient,+ settings: settings,+ store: store,+ licensing: licensing,+ httpClient: httpClient,+ globalConfig: globalConfig,}, nil}@@ -197,7 +201,7 @@ func (a *AuthN) oidcProviderAndoauth2Config(ctx context.Context, siteURL *url.URRedirectURL: (&url.URL{Scheme: siteURL.Scheme,Host: siteURL.Host,- Path: redirectPath,+ Path: path.Join(a.globalConfig.ExternalPath(), redirectPath),}).String(),}, nil}diff --git a/ee/authn/callbackauthn/samlcallbackauthn/authn.go b/ee/authn/callbackauthn/samlcallbackauthn/authn.goindex 28d6f4efa4..0233472320 100644--- a/ee/authn/callbackauthn/samlcallbackauthn/authn.go+++ b/ee/authn/callbackauthn/samlcallbackauthn/authn.go@@ -6,10 +6,12 @@ import ("encoding/base64""encoding/pem""net/url"+ "path""strings""github.com/SigNoz/signoz/pkg/authn""github.com/SigNoz/signoz/pkg/errors"+ "github.com/SigNoz/signoz/pkg/global""github.com/SigNoz/signoz/pkg/licensing""github.com/SigNoz/signoz/pkg/types/authtypes""github.com/SigNoz/signoz/pkg/valuer"@@ -24,14 +26,16 @@ const (var _ authn.CallbackAuthN = (*AuthN)(nil)type AuthN struct {- store authtypes.AuthNStore- licensing licensing.Licensing+ store authtypes.AuthNStore+ licensing licensing.Licensing+ globalConfig global.Config}-func New(ctx context.Context, store authtypes.AuthNStore, licensing licensing.Licensing) (*AuthN, error) {+func New(ctx context.Context, store authtypes.AuthNStore, licensing licensing.Licensing, globalConfig global.Config) (*AuthN, error) {return &AuthN{- store: store,- licensing: licensing,+ store: store,+ licensing: licensing,+ globalConfig: globalConfig,}, nil}@@ -132,7 +136,7 @@ func (a *AuthN) serviceProvider(siteURL *url.URL, authDomain *authtypes.AuthDomareturn nil, err}- acsURL := &url.URL{Scheme: siteURL.Scheme, Host: siteURL.Host, Path: redirectPath}+ acsURL := &url.URL{Scheme: siteURL.Scheme, Host: siteURL.Host, Path: path.Join(a.globalConfig.ExternalPath(), redirectPath)}// Note:// The ServiceProviderIssuer is the client id in case of keycloak. Since we set it to the host here, we need to set the client id == host in keycloak.diff --git a/pkg/authn/callbackauthn/googlecallbackauthn/authn.go b/pkg/authn/callbackauthn/googlecallbackauthn/authn.goindex f7c3cd7150..e76fcdbff2 100644--- a/pkg/authn/callbackauthn/googlecallbackauthn/authn.go+++ b/pkg/authn/callbackauthn/googlecallbackauthn/authn.go@@ -4,6 +4,7 @@ import ("context""log/slog""net/url"+ "path""github.com/coreos/go-oidc/v3/oidc""golang.org/x/oauth2"@@ -14,6 +15,7 @@ import ("github.com/SigNoz/signoz/pkg/authn""github.com/SigNoz/signoz/pkg/errors""github.com/SigNoz/signoz/pkg/factory"+ "github.com/SigNoz/signoz/pkg/global""github.com/SigNoz/signoz/pkg/http/client""github.com/SigNoz/signoz/pkg/types/authtypes""github.com/SigNoz/signoz/pkg/valuer"@@ -29,12 +31,13 @@ var scopes []string = []string{"email", "profile"}var _ authn.CallbackAuthN = (*AuthN)(nil)type AuthN struct {- store authtypes.AuthNStore- settings factory.ScopedProviderSettings- httpClient *client.Client+ store authtypes.AuthNStore+ settings factory.ScopedProviderSettings+ httpClient *client.Client+ globalConfig global.Config}-func New(ctx context.Context, store authtypes.AuthNStore, providerSettings factory.ProviderSettings) (*AuthN, error) {+func New(ctx context.Context, store authtypes.AuthNStore, providerSettings factory.ProviderSettings, globalConfig global.Config) (*AuthN, error) {settings := factory.NewScopedProviderSettings(providerSettings, "github.com/SigNoz/signoz/pkg/authn/callbackauthn/googlecallbackauthn")httpClient, err := client.New(settings.Logger(), providerSettings.TracerProvider, providerSettings.MeterProvider)@@ -43,9 +46,10 @@ func New(ctx context.Context, store authtypes.AuthNStore, providerSettings facto}return &AuthN{- store: store,- settings: settings,- httpClient: httpClient,+ store: store,+ settings: settings,+ httpClient: httpClient,+ globalConfig: globalConfig,}, nil}@@ -178,7 +182,7 @@ func (a *AuthN) oauth2Config(siteURL *url.URL, authDomain *authtypes.AuthDomain,RedirectURL: (&url.URL{Scheme: siteURL.Scheme,Host: siteURL.Host,- Path: redirectPath,+ Path: path.Join(a.globalConfig.ExternalPath(), redirectPath),}).String(),}}diff --git a/pkg/modules/session/implsession/handler.go b/pkg/modules/session/implsession/handler.goindex 86ad71e0e3..1e771061b5 100644--- a/pkg/modules/session/implsession/handler.go+++ b/pkg/modules/session/implsession/handler.go@@ -4,9 +4,11 @@ import ("context""net/http""net/url"+ "path""time""github.com/SigNoz/signoz/pkg/errors"+ "github.com/SigNoz/signoz/pkg/global""github.com/SigNoz/signoz/pkg/http/binding""github.com/SigNoz/signoz/pkg/http/render""github.com/SigNoz/signoz/pkg/modules/session"@@ -15,11 +17,12 @@ import ()type handler struct {- module session.Module+ module session.Module+ globalConfig global.Config}-func NewHandler(module session.Module) session.Handler {- return &handler{module: module}+func NewHandler(module session.Module, globalConfig global.Config) session.Handler {+ return &handler{module: module, globalConfig: globalConfig}}func (handler *handler) GetSessionContext(rw http.ResponseWriter, req *http.Request) {@@ -158,13 +161,13 @@ func (handler *handler) DeleteSession(rw http.ResponseWriter, req *http.Request)render.Success(rw, http.StatusNoContent, nil)}-func (*handler) getRedirectURLFromErr(err error) string {+func (handler *handler) getRedirectURLFromErr(err error) string {values := errors.AsURLValues(err)values.Add("callbackauthnerr", "true")return (&url.URL{// When UI is being served on a prefix, we need to redirect to the login page on the prefix.- Path: "/login",+ Path: path.Join(handler.globalConfig.ExternalPath(), "/login"),RawQuery: values.Encode(),}).String()}diff --git a/pkg/signoz/authn.go b/pkg/signoz/authn.goindex e30e5aad71..9e89b58e4a 100644--- a/pkg/signoz/authn.go+++ b/pkg/signoz/authn.go@@ -7,14 +7,15 @@ import ("github.com/SigNoz/signoz/pkg/authn/callbackauthn/googlecallbackauthn""github.com/SigNoz/signoz/pkg/authn/passwordauthn/emailpasswordauthn""github.com/SigNoz/signoz/pkg/factory"+ "github.com/SigNoz/signoz/pkg/global""github.com/SigNoz/signoz/pkg/licensing""github.com/SigNoz/signoz/pkg/types/authtypes")-func NewAuthNs(ctx context.Context, providerSettings factory.ProviderSettings, store authtypes.AuthNStore, licensing licensing.Licensing) (map[authtypes.AuthNProvider]authn.AuthN, error) {+func NewAuthNs(ctx context.Context, providerSettings factory.ProviderSettings, store authtypes.AuthNStore, licensing licensing.Licensing, globalConfig global.Config) (map[authtypes.AuthNProvider]authn.AuthN, error) {emailPasswordAuthN := emailpasswordauthn.New(store)- googleCallbackAuthN, err := googlecallbackauthn.New(ctx, store, providerSettings)+ googleCallbackAuthN, err := googlecallbackauthn.New(ctx, store, providerSettings, globalConfig)if err != nil {return nil, err}diff --git a/pkg/signoz/provider.go b/pkg/signoz/provider.goindex e9e6fd9569..b188912fa8 100644--- a/pkg/signoz/provider.go+++ b/pkg/signoz/provider.go@@ -275,14 +275,14 @@ func NewQuerierProviderFactories(telemetryStore telemetrystore.TelemetryStore, p)}-func NewAPIServerProviderFactories(orgGetter organization.Getter, authz authz.AuthZ, modules Modules, handlers Handlers) factory.NamedMap[factory.ProviderFactory[apiserver.APIServer, apiserver.Config]] {+func NewAPIServerProviderFactories(orgGetter organization.Getter, authz authz.AuthZ, modules Modules, handlers Handlers, globalConfig global.Config) factory.NamedMap[factory.ProviderFactory[apiserver.APIServer, apiserver.Config]] {return factory.MustNewNamedMap(signozapiserver.NewFactory(orgGetter,authz,implorganization.NewHandler(modules.OrgGetter, modules.OrgSetter),impluser.NewHandler(modules.UserSetter, modules.UserGetter),- implsession.NewHandler(modules.Session),+ implsession.NewHandler(modules.Session, globalConfig),implauthdomain.NewHandler(modules.AuthDomain),implpreference.NewHandler(modules.Preference),handlers.Global,diff --git a/pkg/signoz/provider_test.go b/pkg/signoz/provider_test.goindex 9ace61e795..23f1019509 100644--- a/pkg/signoz/provider_test.go+++ b/pkg/signoz/provider_test.go@@ -95,6 +95,7 @@ func TestNewProviderFactories(t *testing.T) {nil,Modules{},Handlers{},+ global.Config{},)})}diff --git a/pkg/signoz/signoz.go b/pkg/signoz/signoz.goindex 0781050829..01cb582719 100644--- a/pkg/signoz/signoz.go+++ b/pkg/signoz/signoz.go@@ -542,7 +542,7 @@ func New(ctx,providerSettings,config.APIServer,- NewAPIServerProviderFactories(orgGetter, authz, modules, handlers),+ NewAPIServerProviderFactories(orgGetter, authz, modules, handlers, config.Global),"signoz",)if err != nil {diff --git a/tests/fixtures/auth.py b/tests/fixtures/auth.pyindex fee5e15c4d..c99595069f 100644--- a/tests/fixtures/auth.py+++ b/tests/fixtures/auth.py@@ -56,11 +56,18 @@ def _login(signoz: types.SigNoz, email: str, password: str) -> str:return login.json()["data"]["accessToken"][email protected](name="create_user_admin", scope="package")-def create_user_admin(signoz: types.SigNoz, request: pytest.FixtureRequest, pytestconfig: pytest.Config) -> types.Operation:- def create() -> None:+def register_admin(+ signoz: types.SigNoz,+ request: pytest.FixtureRequest,+ pytestconfig: pytest.Config,+ cache_key: str = "create_user_admin",+ base_path: str = "",+) -> types.Operation:+ """Register the first admin (creates the org), under base_path. Reuse-wrapped."""++ def create() -> types.Operation:response = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/register"),+ signoz.self.host_configs["8080"].get(f"{base_path}/api/v1/register"),json={"name": USER_ADMIN_NAME,"orgName": "",@@ -83,7 +90,7 @@ def create_user_admin(signoz: types.SigNoz, request: pytest.FixtureRequest, pytereturn reuse.wrap(request,pytestconfig,- "create_user_admin",+ cache_key,lambda: types.Operation(name=""),create,delete,@@ -91,86 +98,86 @@ def create_user_admin(signoz: types.SigNoz, request: pytest.FixtureRequest, pyte)[email protected](name="get_session_context", scope="function")-def get_session_context(signoz: types.SigNoz) -> Callable[[str, str], str]:- def _get_session_context(email: str) -> str:[email protected](name="create_user_admin", scope="package")+def create_user_admin(signoz: types.SigNoz, request: pytest.FixtureRequest, pytestconfig: pytest.Config) -> types.Operation:+ return register_admin(signoz, request, pytestconfig)+++def session_context_getter(signoz: types.SigNoz, base_path: str = "") -> Callable[[str], dict]:+ """Build a callable that fetches the session context for an email (under base_path)."""++ def fetch_session_context(email: str) -> dict:response = requests.get(- signoz.self.host_configs["8080"].get("/api/v2/sessions/context"),- params={- "email": email,- "ref": f"{signoz.self.host_configs['8080'].base()}",- },+ signoz.self.host_configs["8080"].get(f"{base_path}/api/v2/sessions/context"),+ params={"email": email, "ref": f"{signoz.self.host_configs['8080'].base()}"},timeout=5,)-assert response.status_code == HTTPStatus.OKreturn response.json()["data"]- return _get_session_context+ return fetch_session_context[email protected](name="get_token", scope="function")-def get_token(signoz: types.SigNoz) -> Callable[[str, str], str]:- def _get_token(email: str, password: str) -> str:- response = requests.get(- signoz.self.host_configs["8080"].get("/api/v2/sessions/context"),- params={- "email": email,- "ref": f"{signoz.self.host_configs['8080'].base()}",- },[email protected](name="get_session_context", scope="function")+def get_session_context(signoz: types.SigNoz) -> Callable[[str], dict]:+ return session_context_getter(signoz)+++def token_getter(signoz: types.SigNoz, base_path: str = "") -> Callable[[str, str], str]:+ """Build a callable that logs in (email/password) and returns the access token (under base_path)."""++ def fetch_token(email: str, password: str) -> str:+ context = requests.get(+ signoz.self.host_configs["8080"].get(f"{base_path}/api/v2/sessions/context"),+ params={"email": email, "ref": f"{signoz.self.host_configs['8080'].base()}"},timeout=5,)+ assert context.status_code == HTTPStatus.OK+ org_id = context.json()["data"]["orgs"][0]["id"]- assert response.status_code == HTTPStatus.OK- org_id = response.json()["data"]["orgs"][0]["id"]-- response = requests.post(- signoz.self.host_configs["8080"].get("/api/v2/sessions/email_password"),- json={- "email": email,- "password": password,- "orgId": org_id,- },+ login = requests.post(+ signoz.self.host_configs["8080"].get(f"{base_path}/api/v2/sessions/email_password"),+ json={"email": email, "password": password, "orgId": org_id},timeout=5,)+ assert login.status_code == HTTPStatus.OK+ return login.json()["data"]["accessToken"]- assert response.status_code == HTTPStatus.OK- return response.json()["data"]["accessToken"]+ return fetch_token- return _get_token[email protected](name="get_token", scope="function")+def get_token(signoz: types.SigNoz) -> Callable[[str, str], str]:+ return token_getter(signoz)[email protected](name="get_tokens", scope="function")-def get_tokens(signoz: types.SigNoz) -> Callable[[str, str], tuple[str, str]]:- def _get_tokens(email: str, password: str) -> str:- response = requests.get(- signoz.self.host_configs["8080"].get("/api/v2/sessions/context"),- params={- "email": email,- "ref": f"{signoz.self.host_configs['8080'].base()}",- },++def tokens_getter(signoz: types.SigNoz, base_path: str = "") -> Callable[[str, str], tuple[str, str]]:+ """Build a callable that logs in and returns the (access, refresh) token pair (under base_path)."""++ def fetch_tokens(email: str, password: str) -> tuple[str, str]:+ context = requests.get(+ signoz.self.host_configs["8080"].get(f"{base_path}/api/v2/sessions/context"),+ params={"email": email, "ref": f"{signoz.self.host_configs['8080'].base()}"},timeout=5,)+ assert context.status_code == HTTPStatus.OK+ org_id = context.json()["data"]["orgs"][0]["id"]- assert response.status_code == HTTPStatus.OK- org_id = response.json()["data"]["orgs"][0]["id"]-- response = requests.post(- signoz.self.host_configs["8080"].get("/api/v2/sessions/email_password"),- json={- "email": email,- "password": password,- "orgId": org_id,- },+ login = requests.post(+ signoz.self.host_configs["8080"].get(f"{base_path}/api/v2/sessions/email_password"),+ json={"email": email, "password": password, "orgId": org_id},timeout=5,)+ assert login.status_code == HTTPStatus.OK+ data = login.json()["data"]+ return data["accessToken"], data["refreshToken"]++ return fetch_tokens- assert response.status_code == HTTPStatus.OK- access_token = response.json()["data"]["accessToken"]- refresh_token = response.json()["data"]["refreshToken"]- return access_token, refresh_token- return _get_tokens[email protected](name="get_tokens", scope="function")+def get_tokens(signoz: types.SigNoz) -> Callable[[str, str], tuple[str, str]]:+ return tokens_getter(signoz)@pytest.fixture(name="apply_license", scope="package")@@ -270,6 +277,7 @@ def add_license(signoz: types.SigNoz,make_http_mocks: Callable[[types.TestContainerDocker, list[Mapping]], None],get_token: Callable[[str, str], str], # pylint: disable=redefined-outer-name+ base_path: str = "",) -> None:make_http_mocks(signoz.zeus,@@ -308,7 +316,7 @@ def add_license(access_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)response = requests.post(- url=signoz.self.host_configs["8080"].get("/api/v3/licenses"),+ url=signoz.self.host_configs["8080"].get(f"{base_path}/api/v3/licenses"),json={"key": "secret-key"},headers={"Authorization": "Bearer " + access_token},timeout=5,diff --git a/tests/integration/tests/basepath/01_oidc.py b/tests/integration/tests/basepath/01_oidc.pynew file mode 100644index 0000000000..29ff50bab7--- /dev/null+++ b/tests/integration/tests/basepath/01_oidc.py@@ -0,0 +1,126 @@+from collections.abc import Callable+from http import HTTPStatus+from urllib.parse import urlparse++import requests+from selenium import webdriver+from wiremock.resources.mappings import Mapping++from fixtures.auth import USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD, add_license, assert_user_has_role+from fixtures.types import Operation, SigNoz, TestContainerDocker, TestContainerIDP++# SigNoz is served under /signoz, so the OIDC callback registered with the IdP+# must include the prefix to match the backend-generated redirect URI.+BASE_PATH = "/signoz"+OIDC_CALLBACK_PATH = f"{BASE_PATH}/api/v1/complete/oidc"+++def test_apply_license(+ signoz: SigNoz,+ create_user_admin: Operation, # pylint: disable=unused-argument+ make_http_mocks: Callable[[TestContainerDocker, list[Mapping]], None],+ get_token: Callable[[str, str], str],+) -> None:+ """+ Applies a license to the signoz instance. add_license is a plain function+ called from the test (function scope), so the function-scoped make_http_mocks+ fixture is safe to use; base_path prefixes the licensing API call.+ """+ add_license(signoz, make_http_mocks, get_token, base_path=BASE_PATH)+++def test_create_auth_domain(+ signoz: SigNoz,+ idp: TestContainerIDP, # pylint: disable=unused-argument+ create_oidc_client: Callable[[str, str], None],+ get_oidc_settings: Callable[[str], dict],+ get_token: Callable[[str, str], str],+) -> None:+ """+ Creates an OIDC auth domain in SigNoz served under a base path. The callback+ registered with the IdP carries the /signoz prefix.+ """+ client_id = f"oidc.basepath.test.{signoz.self.host_configs['8080'].address}:{signoz.self.host_configs['8080'].port}"+ # Create an oidc client in the idp with the prefixed callback.+ create_oidc_client(client_id, OIDC_CALLBACK_PATH)++ # Get the oidc settings from keycloak.+ settings = get_oidc_settings(client_id)++ admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)++ response = requests.post(+ signoz.self.host_configs["8080"].get("/signoz/api/v1/domains"),+ json={+ "name": "oidc.basepath.test",+ "config": {+ "ssoEnabled": True,+ "ssoType": "oidc",+ "oidcConfig": {+ "clientId": settings["client_id"],+ "clientSecret": settings["client_secret"],+ # Change the hostname of the issuer to the internal resolvable hostname of the idp+ "issuer": f"{idp.container.container_configs['6060'].get(urlparse(settings['issuer']).path)}",+ "issuerAlias": settings["issuer"],+ "getUserInfo": True,+ },+ },+ },+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )++ assert response.status_code == HTTPStatus.CREATED+++def test_oidc_authn(+ signoz: SigNoz,+ idp: TestContainerIDP,+ driver: webdriver.Chrome,+ create_user_idp: Callable[[str, str, bool, str, str], None],+ idp_login: Callable[[str, str], None],+ get_token: Callable[[str, str], str],+ get_session_context: Callable[[str], dict],+) -> None:+ """+ Tests the OIDC authn flow when SigNoz is served under a base path. The login+ URL the backend produces (and thus the IdP callback) carries the /signoz+ prefix; the e2e browser login must complete and create the user.+ """+ # Create a user in the idp.+ create_user_idp("[email protected]", "password123", True)++ # Get the session context from signoz which will give the OIDC login URL.+ session_context = get_session_context("[email protected]")++ assert len(session_context["orgs"]) == 1+ assert len(session_context["orgs"][0]["authNSupport"]["callback"]) == 1++ url = session_context["orgs"][0]["authNSupport"]["callback"][0]["url"]++ # change the url to the external resolvable hostname of the idp+ parsed_url = urlparse(url)+ actual_url = f"{idp.container.host_configs['6060'].get(parsed_url.path)}?{parsed_url.query}"++ driver.get(actual_url)+ idp_login("[email protected]", "password123")++ # Assert that the user was created in signoz (lookup under the base path).+ admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)++ users = requests.get(+ signoz.self.host_configs["8080"].get("/signoz/api/v2/users"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=5,+ )+ assert users.status_code == HTTPStatus.OK, users.text+ user = next((u for u in users.json()["data"] if u["email"] == "[email protected]"), None)+ assert user is not None, "User with email '[email protected]' not found"++ user_with_roles = requests.get(+ signoz.self.host_configs["8080"].get(f"/signoz/api/v2/users/{user['id']}"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=5,+ )+ assert user_with_roles.status_code == HTTPStatus.OK, user_with_roles.text+ assert_user_has_role(user_with_roles.json()["data"], "signoz-viewer")diff --git a/tests/integration/tests/basepath/02_saml.py b/tests/integration/tests/basepath/02_saml.pynew file mode 100644index 0000000000..e34f504598--- /dev/null+++ b/tests/integration/tests/basepath/02_saml.py@@ -0,0 +1,117 @@+from collections.abc import Callable+from http import HTTPStatus++import requests+from selenium import webdriver+from wiremock.resources.mappings import Mapping++from fixtures.auth import USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD, add_license, assert_user_has_role+from fixtures.types import Operation, SigNoz, TestContainerDocker, TestContainerIDP++# SigNoz is served under /signoz, so the SAML ACS registered with the IdP must+# include the prefix to match the backend-generated AssertionConsumerServiceURL.+BASE_PATH = "/signoz"+SAML_CALLBACK_PATH = f"{BASE_PATH}/api/v1/complete/saml"+++def test_apply_license(+ signoz: SigNoz,+ create_user_admin: Operation, # pylint: disable=unused-argument+ make_http_mocks: Callable[[TestContainerDocker, list[Mapping]], None],+ get_token: Callable[[str, str], str],+) -> None:+ """+ Applies a license to the signoz instance. add_license is a plain function+ called from the test (function scope), so the function-scoped make_http_mocks+ fixture is safe to use; base_path prefixes the licensing API call.+ """+ add_license(signoz, make_http_mocks, get_token, base_path=BASE_PATH)+++def test_create_auth_domain(+ signoz: SigNoz,+ idp: TestContainerIDP, # pylint: disable=unused-argument+ create_saml_client: Callable[[str, str], None],+ get_saml_settings: Callable[[], dict],+ get_token: Callable[[str, str], str],+) -> None:+ """+ Creates a SAML auth domain in SigNoz served under a base path. The ACS+ registered with the IdP carries the /signoz prefix.+ """+ # Create a saml client in the idp with the prefixed ACS.+ create_saml_client("saml.basepath.test", SAML_CALLBACK_PATH)++ # Get the saml settings from keycloak.+ settings = get_saml_settings()++ admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)++ response = requests.post(+ signoz.self.host_configs["8080"].get("/signoz/api/v1/domains"),+ json={+ "name": "saml.basepath.test",+ "config": {+ "ssoEnabled": True,+ "ssoType": "saml",+ "samlConfig": {+ "samlEntity": settings["entityID"],+ "samlIdp": settings["singleSignOnServiceLocation"],+ "samlCert": settings["certificate"],+ },+ },+ },+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )++ assert response.status_code == HTTPStatus.CREATED+++def test_saml_authn(+ signoz: SigNoz,+ idp: TestContainerIDP, # pylint: disable=unused-argument+ driver: webdriver.Chrome,+ create_user_idp: Callable[[str, str, bool, str, str], None],+ idp_login: Callable[[str, str], None],+ get_token: Callable[[str, str], str],+ get_session_context: Callable[[str], dict],+) -> None:+ """+ Tests the SAML authn flow when SigNoz is served under a base path. The+ AssertionConsumerServiceURL in the AuthnRequest carries the /signoz prefix;+ the e2e browser login must complete and create the user.+ """+ # Create a user in the idp.+ create_user_idp("[email protected]", "password", True)++ # Get the session context from signoz which will give the SAML login URL.+ session_context = get_session_context("[email protected]")++ assert len(session_context["orgs"]) == 1+ assert len(session_context["orgs"][0]["authNSupport"]["callback"]) == 1++ url = session_context["orgs"][0]["authNSupport"]["callback"][0]["url"]++ driver.get(url)+ idp_login("[email protected]", "password")++ # Assert that the user was created in signoz (lookup under the base path).+ admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)++ users = requests.get(+ signoz.self.host_configs["8080"].get("/signoz/api/v2/users"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=5,+ )+ assert users.status_code == HTTPStatus.OK, users.text+ user = next((u for u in users.json()["data"] if u["email"] == "[email protected]"), None)+ assert user is not None, "User with email '[email protected]' not found"++ user_with_roles = requests.get(+ signoz.self.host_configs["8080"].get(f"/signoz/api/v2/users/{user['id']}"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=5,+ )+ assert user_with_roles.status_code == HTTPStatus.OK, user_with_roles.text+ assert_user_has_role(user_with_roles.json()["data"], "signoz-viewer")diff --git a/tests/integration/tests/basepath/__init__.py b/tests/integration/tests/basepath/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/tests/integration/tests/basepath/conftest.py b/tests/integration/tests/basepath/conftest.pynew file mode 100644index 0000000000..3a4ae3df7b--- /dev/null+++ b/tests/integration/tests/basepath/conftest.py@@ -0,0 +1,57 @@+from collections.abc import Callable++import pytest+from testcontainers.core.container import Network++from fixtures import types+from fixtures.auth import register_admin, session_context_getter, token_getter+from fixtures.signoz import create_signoz++# SigNoz is served under this URL path prefix for the base-path suite. The auth+# helpers from fixtures/auth.py are reused via their factories with this prefix,+# so these fixtures shadow the same-named root ones without duplicating logic.+# Only the path component is read by global.ExternalPath(), which derives the+# http.StripPrefix route prefix.+BASE_PATH = "/signoz"++[email protected](name="signoz", scope="package")+def signoz_base_path( # pylint: disable=too-many-arguments,too-many-positional-arguments+ network: Network,+ zeus: types.TestContainerDocker,+ gateway: types.TestContainerDocker,+ sqlstore: types.TestContainerSQL,+ clickhouse: types.TestContainerClickhouse,+ request: pytest.FixtureRequest,+ pytestconfig: pytest.Config,+) -> types.SigNoz:+ """+ Package-scoped SigNoz served under BASE_PATH. Sets SIGNOZ_GLOBAL_EXTERNAL__URL+ with the prefix so the backend derives the http.StripPrefix route prefix.+ """+ return create_signoz(+ network=network,+ zeus=zeus,+ gateway=gateway,+ sqlstore=sqlstore,+ clickhouse=clickhouse,+ request=request,+ pytestconfig=pytestconfig,+ cache_key="signoz_base_path",+ env_overrides={"SIGNOZ_GLOBAL_EXTERNAL__URL": f"http://localhost:8080{BASE_PATH}"},+ )++[email protected](name="create_user_admin", scope="package")+def create_user_admin_base_path(signoz: types.SigNoz, request: pytest.FixtureRequest, pytestconfig: pytest.Config) -> types.Operation:+ return register_admin(signoz, request, pytestconfig, cache_key="create_user_admin_base_path", base_path=BASE_PATH)++[email protected](name="get_token", scope="function")+def get_token(signoz: types.SigNoz) -> Callable[[str, str], str]:+ return token_getter(signoz, BASE_PATH)++[email protected](name="get_session_context", scope="function")+def get_session_context(signoz: types.SigNoz) -> Callable[[str], dict]:+ return session_context_getter(signoz, BASE_PATH)diff --git a/tests/integration/tests/cloudintegrations/05_services.py b/tests/integration/tests/cloudintegrations/05_services.pyindex a70da87d45..b43e568803 100644--- a/tests/integration/tests/cloudintegrations/05_services.py+++ b/tests/integration/tests/cloudintegrations/05_services.py@@ -483,7 +483,7 @@ def test_enable_metrics_provisions_dashboards(assert isinstance(dashboards_in_service, list) and len(dashboards_in_service) > 0, "assets.dashboards should be non-empty after enabling metrics"provisioned_ids = set()for dash in dashboards_in_service:- assert "integrationDashboard" in dash, f"Integration dashboard entry missing"+ assert "integrationDashboard" in dash, "Integration dashboard entry missing"try:uuid.UUID(dash["integrationDashboard"]["id"])except ValueError as err: