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(authtypes): restructure auth domain payload into a kind/spec envelope (#12472)
Pandey5b3b2865d15c
diff --git a/docs/api/openapi.yml b/docs/api/openapi.ymlindex 0f16cffa7e..a1524bb3d1 100644--- a/docs/api/openapi.yml+++ b/docs/api/openapi.yml@@ -464,27 +464,50 @@ components:type: stringtype: objectAuthtypesAuthDomainConfig:+ discriminator:+ mapping:+ google: '#/components/schemas/AuthtypesAuthDomainConfigGoogle'+ oidc: '#/components/schemas/AuthtypesAuthDomainConfigOIDC'+ saml: '#/components/schemas/AuthtypesAuthDomainConfigSAML'+ propertyName: kindoneOf:- - $ref: '#/components/schemas/AuthtypesSamlConfig'- - $ref: '#/components/schemas/AuthtypesGoogleConfig'- - $ref: '#/components/schemas/AuthtypesOIDCConfig'+ - $ref: '#/components/schemas/AuthtypesAuthDomainConfigSAML'+ - $ref: '#/components/schemas/AuthtypesAuthDomainConfigGoogle'+ - $ref: '#/components/schemas/AuthtypesAuthDomainConfigOIDC'+ type: object+ AuthtypesAuthDomainConfigGoogle:properties:- googleAuthConfig:+ kind:+ $ref: '#/components/schemas/AuthtypesAuthNProvider'+ spec:$ref: '#/components/schemas/AuthtypesGoogleConfig'- oidcConfig:+ required:+ - kind+ - spec+ type: object+ AuthtypesAuthDomainConfigOIDC:+ properties:+ kind:+ $ref: '#/components/schemas/AuthtypesAuthNProvider'+ spec:$ref: '#/components/schemas/AuthtypesOIDCConfig'- roleMapping:- $ref: '#/components/schemas/AuthtypesRoleMapping'- samlConfig:- $ref: '#/components/schemas/AuthtypesSamlConfig'- ssoEnabled:- type: boolean- ssoType:+ required:+ - kind+ - spec+ type: object+ AuthtypesAuthDomainConfigSAML:+ properties:+ kind:$ref: '#/components/schemas/AuthtypesAuthNProvider'+ spec:+ $ref: '#/components/schemas/AuthtypesSamlConfig'+ required:+ - kind+ - spectype: objectAuthtypesAuthNProvider:enum:- - google_auth- saml- email_password- oidc@@ -531,12 +554,16 @@ components:createdAt:format: date-timetype: string+ enabled:+ type: booleanid:type: stringname:type: stringorgId:type: string+ roleMapping:+ $ref: '#/components/schemas/AuthtypesRoleMapping'updatedAt:format: date-timetype: string@@ -601,6 +628,7 @@ components:clientId:type: stringclientSecret:+ format: passwordtype: stringdomainToAdminEmail:additionalProperties:@@ -612,10 +640,12 @@ components:type: booleaninsecureSkipEmailVerified:type: boolean- redirectURI:- type: stringserviceAccountJson:+ format: passwordtype: string+ required:+ - clientId+ - clientSecrettype: objectAuthtypesOIDCConfig:properties:@@ -624,6 +654,7 @@ components:clientId:type: stringclientSecret:+ format: passwordtype: stringgetUserInfo:type: boolean@@ -633,6 +664,10 @@ components:type: stringissuerAlias:type: string+ required:+ - issuer+ - clientId+ - clientSecrettype: objectAuthtypesOrgSessionContext:properties:@@ -654,8 +689,15 @@ components:properties:config:$ref: '#/components/schemas/AuthtypesAuthDomainConfig'+ enabled:+ type: booleanname:type: string+ roleMapping:+ $ref: '#/components/schemas/AuthtypesRoleMapping'+ required:+ - name+ - configtype: objectAuthtypesPostableEmailPasswordSession:properties:@@ -762,14 +804,18 @@ components:properties:attributeMapping:$ref: '#/components/schemas/AuthtypesAttributeMapping'- insecureSkipAuthNRequestsSigned:- type: boolean- samlCert:+ certificate:type: string- samlEntity:+ entityId:type: string- samlIdp:+ insecureSkipAuthNRequestsSigned:+ type: boolean+ location:type: string+ required:+ - entityId+ - location+ - certificatetype: objectAuthtypesSessionContext:properties:@@ -809,6 +855,12 @@ components:properties:config:$ref: '#/components/schemas/AuthtypesAuthDomainConfig'+ enabled:+ type: boolean+ roleMapping:+ $ref: '#/components/schemas/AuthtypesRoleMapping'+ required:+ - configtype: objectAuthtypesUpdatableRole:properties:@@ -10541,11 +10593,22 @@ paths:summary: Update public dashboardtags:- dashboard- /api/v1/domains:+ /api/v1/downtime_schedules:get:deprecated: false- description: This endpoint lists all auth domains- operationId: ListAuthDomains+ description: This endpoint lists all planned maintenance / downtime schedules+ operationId: ListDowntimeSchedules+ parameters:+ - in: query+ name: active+ schema:+ nullable: true+ type: boolean+ - in: query+ name: recurring+ schema:+ nullable: true+ type: booleanresponses:"200":content:@@ -10554,7 +10617,7 @@ paths:properties:data:items:- $ref: '#/components/schemas/AuthtypesGettableAuthDomain'+ $ref: '#/components/schemas/AlertmanagertypesPlannedMaintenance'type: arraystatus:type: string@@ -10583,21 +10646,21 @@ paths:description: Internal Server Errorsecurity:- api_key:- - ADMIN+ - VIEWER- tokenizer:- - ADMIN- summary: List all auth domains+ - VIEWER+ summary: List downtime schedulestags:- - authdomains+ - downtimeschedulespost:deprecated: false- description: This endpoint creates an auth domain- operationId: CreateAuthDomain+ description: This endpoint creates a new planned maintenance / downtime schedule+ operationId: CreateDowntimeSchedulerequestBody:content:application/json:schema:- $ref: '#/components/schemas/AuthtypesPostableAuthDomain'+ $ref: '#/components/schemas/AlertmanagertypesPostablePlannedMaintenance'responses:"201":content:@@ -10605,7 +10668,7 @@ paths:schema:properties:data:- $ref: '#/components/schemas/TypesIdentifiable'+ $ref: '#/components/schemas/AlertmanagertypesPlannedMaintenance'status:type: stringrequired:@@ -10631,12 +10694,6 @@ paths:schema:$ref: '#/components/schemas/RenderErrorResponse'description: Forbidden- "409":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Conflict"500":content:application/json:@@ -10645,17 +10702,17 @@ paths:description: Internal Server Errorsecurity:- api_key:- - ADMIN+ - EDITOR- tokenizer:- - ADMIN- summary: Create auth domain+ - EDITOR+ summary: Create downtime scheduletags:- - authdomains- /api/v1/domains/{id}:+ - downtimeschedules+ /api/v1/downtime_schedules/{id}:delete:deprecated: false- description: This endpoint deletes an auth domain- operationId: DeleteAuthDomain+ description: This endpoint deletes a downtime schedule by ID+ operationId: DeleteDowntimeScheduleByIDparameters:- in: pathname: id@@ -10665,12 +10722,6 @@ paths:responses:"204":description: No Content- "400":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Bad Request"401":content:application/json:@@ -10683,6 +10734,12 @@ paths:schema:$ref: '#/components/schemas/RenderErrorResponse'description: Forbidden+ "404":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Not Found"500":content:application/json:@@ -10691,16 +10748,16 @@ paths:description: Internal Server Errorsecurity:- api_key:- - ADMIN+ - EDITOR- tokenizer:- - ADMIN- summary: Delete auth domain+ - EDITOR+ summary: Delete downtime scheduletags:- - authdomains+ - downtimeschedulesget:deprecated: false- description: This endpoint returns an auth domain by ID- operationId: GetAuthDomain+ description: This endpoint returns a downtime schedule by ID+ operationId: GetDowntimeScheduleByIDparameters:- in: pathname: id@@ -10714,7 +10771,7 @@ paths:schema:properties:data:- $ref: '#/components/schemas/AuthtypesGettableAuthDomain'+ $ref: '#/components/schemas/AlertmanagertypesPlannedMaintenance'status:type: stringrequired:@@ -10748,16 +10805,16 @@ paths:description: Internal Server Errorsecurity:- api_key:- - ADMIN+ - VIEWER- tokenizer:- - ADMIN- summary: Get auth domain by ID+ - VIEWER+ summary: Get downtime schedule by IDtags:- - authdomains+ - downtimeschedulesput:deprecated: false- description: This endpoint updates an auth domain- operationId: UpdateAuthDomain+ description: This endpoint updates a downtime schedule by ID+ operationId: UpdateDowntimeScheduleByIDparameters:- in: pathname: id@@ -10768,7 +10825,7 @@ paths:content:application/json:schema:- $ref: '#/components/schemas/AuthtypesUpdatableAuthDomain'+ $ref: '#/components/schemas/AlertmanagertypesPostablePlannedMaintenance'responses:"204":description: No Content@@ -10790,71 +10847,12 @@ paths:schema:$ref: '#/components/schemas/RenderErrorResponse'description: Forbidden- "409":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Conflict- "500":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Internal Server Error- security:- - api_key:- - ADMIN- - tokenizer:- - ADMIN- summary: Update auth domain- tags:- - authdomains- /api/v1/downtime_schedules:- get:- deprecated: false- description: This endpoint lists all planned maintenance / downtime schedules- operationId: ListDowntimeSchedules- parameters:- - in: query- name: active- schema:- nullable: true- type: boolean- - in: query- name: recurring- schema:- nullable: true- type: boolean- responses:- "200":- content:- application/json:- schema:- properties:- data:- items:- $ref: '#/components/schemas/AlertmanagertypesPlannedMaintenance'- type: array- status:- type: string- required:- - status- - data- type: object- description: OK- "401":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Unauthorized- "403":+ "404":content:application/json:schema:$ref: '#/components/schemas/RenderErrorResponse'- description: Forbidden+ description: Not Found"500":content:application/json:@@ -10863,36 +10861,37 @@ paths:description: Internal Server Errorsecurity:- api_key:- - VIEWER+ - EDITOR- tokenizer:- - VIEWER- summary: List downtime schedules+ - EDITOR+ summary: Update downtime scheduletags:- downtimeschedules+ /api/v1/export_raw_data:post:deprecated: false- description: This endpoint creates a new planned maintenance / downtime schedule- operationId: CreateDowntimeSchedule+ description: This endpoints allows complex query exporting raw data for traces+ and logs+ operationId: HandleExportRawDataPOST+ parameters:+ - description: The output format for the export.+ in: query+ name: format+ schema:+ default: csv+ description: The output format for the export.+ enum:+ - csv+ - jsonl+ type: stringrequestBody:content:application/json:schema:- $ref: '#/components/schemas/AlertmanagertypesPostablePlannedMaintenance'+ $ref: '#/components/schemas/Querybuildertypesv5QueryRangeRequest'responses:- "201":- content:- application/json:- schema:- properties:- data:- $ref: '#/components/schemas/AlertmanagertypesPlannedMaintenance'- status:- type: string- required:- - status- - data- type: object- description: Created+ "200":+ description: OK"400":content:application/json:@@ -10919,223 +10918,7 @@ paths:description: Internal Server Errorsecurity:- api_key:- - EDITOR- - tokenizer:- - EDITOR- summary: Create downtime schedule- tags:- - downtimeschedules- /api/v1/downtime_schedules/{id}:- delete:- deprecated: false- description: This endpoint deletes a downtime schedule by ID- operationId: DeleteDowntimeScheduleByID- parameters:- - in: path- name: id- required: true- schema:- type: string- responses:- "204":- description: No Content- "401":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Unauthorized- "403":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Forbidden- "404":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Not Found- "500":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Internal Server Error- security:- - api_key:- - EDITOR- - tokenizer:- - EDITOR- summary: Delete downtime schedule- tags:- - downtimeschedules- get:- deprecated: false- description: This endpoint returns a downtime schedule by ID- operationId: GetDowntimeScheduleByID- parameters:- - in: path- name: id- required: true- schema:- type: string- responses:- "200":- content:- application/json:- schema:- properties:- data:- $ref: '#/components/schemas/AlertmanagertypesPlannedMaintenance'- status:- type: string- required:- - status- - data- type: object- description: OK- "401":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Unauthorized- "403":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Forbidden- "404":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Not Found- "500":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Internal Server Error- security:- - api_key:- - VIEWER- - tokenizer:- - VIEWER- summary: Get downtime schedule by ID- tags:- - downtimeschedules- put:- deprecated: false- description: This endpoint updates a downtime schedule by ID- operationId: UpdateDowntimeScheduleByID- parameters:- - in: path- name: id- required: true- schema:- type: string- requestBody:- content:- application/json:- schema:- $ref: '#/components/schemas/AlertmanagertypesPostablePlannedMaintenance'- responses:- "204":- description: No Content- "400":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Bad Request- "401":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Unauthorized- "403":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Forbidden- "404":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Not Found- "500":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Internal Server Error- security:- - api_key:- - EDITOR- - tokenizer:- - EDITOR- summary: Update downtime schedule- tags:- - downtimeschedules- /api/v1/export_raw_data:- post:- deprecated: false- description: This endpoints allows complex query exporting raw data for traces- and logs- operationId: HandleExportRawDataPOST- parameters:- - description: The output format for the export.- in: query- name: format- schema:- default: csv- description: The output format for the export.- enum:- - csv- - jsonl- type: string- requestBody:- content:- application/json:- schema:- $ref: '#/components/schemas/Querybuildertypesv5QueryRangeRequest'- responses:- "200":- description: OK- "400":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Bad Request- "401":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Unauthorized- "403":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Forbidden- "500":- content:- application/json:- schema:- $ref: '#/components/schemas/RenderErrorResponse'- description: Internal Server Error- security:- - api_key:- - VIEWER+ - VIEWER- tokenizer:- VIEWERsummary: Export raw data@@ -14398,6 +14181,275 @@ paths:summary: Update user preferencetags:- preferences+ /api/v2/auth_domains:+ get:+ deprecated: false+ description: This endpoint lists all auth domains+ operationId: ListAuthDomains+ responses:+ "200":+ content:+ application/json:+ schema:+ properties:+ data:+ items:+ $ref: '#/components/schemas/AuthtypesGettableAuthDomain'+ type: array+ status:+ type: string+ required:+ - status+ - data+ type: object+ description: OK+ "401":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Unauthorized+ "403":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Forbidden+ "500":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Internal Server Error+ security:+ - api_key:+ - ADMIN+ - tokenizer:+ - ADMIN+ summary: List all auth domains+ tags:+ - authdomains+ post:+ deprecated: false+ description: This endpoint creates an auth domain+ operationId: CreateAuthDomain+ requestBody:+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/AuthtypesPostableAuthDomain'+ responses:+ "201":+ content:+ application/json:+ schema:+ properties:+ data:+ $ref: '#/components/schemas/TypesIdentifiable'+ status:+ type: string+ required:+ - status+ - data+ type: object+ description: Created+ "400":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Bad Request+ "401":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Unauthorized+ "403":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Forbidden+ "409":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Conflict+ "500":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Internal Server Error+ security:+ - api_key:+ - ADMIN+ - tokenizer:+ - ADMIN+ summary: Create auth domain+ tags:+ - authdomains+ /api/v2/auth_domains/{id}:+ delete:+ deprecated: false+ description: This endpoint deletes an auth domain+ operationId: DeleteAuthDomain+ parameters:+ - in: path+ name: id+ required: true+ schema:+ type: string+ responses:+ "204":+ description: No Content+ "400":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Bad Request+ "401":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Unauthorized+ "403":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Forbidden+ "500":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Internal Server Error+ security:+ - api_key:+ - ADMIN+ - tokenizer:+ - ADMIN+ summary: Delete auth domain+ tags:+ - authdomains+ get:+ deprecated: false+ description: This endpoint returns an auth domain by ID+ operationId: GetAuthDomain+ parameters:+ - in: path+ name: id+ required: true+ schema:+ type: string+ responses:+ "200":+ content:+ application/json:+ schema:+ properties:+ data:+ $ref: '#/components/schemas/AuthtypesGettableAuthDomain'+ status:+ type: string+ required:+ - status+ - data+ type: object+ description: OK+ "401":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Unauthorized+ "403":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Forbidden+ "404":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Not Found+ "500":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Internal Server Error+ security:+ - api_key:+ - ADMIN+ - tokenizer:+ - ADMIN+ summary: Get auth domain by ID+ tags:+ - authdomains+ put:+ deprecated: false+ description: This endpoint updates an auth domain+ operationId: UpdateAuthDomain+ parameters:+ - in: path+ name: id+ required: true+ schema:+ type: string+ requestBody:+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/AuthtypesUpdatableAuthDomain'+ responses:+ "204":+ description: No Content+ "400":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Bad Request+ "401":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Unauthorized+ "403":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Forbidden+ "409":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Conflict+ "500":+ content:+ application/json:+ schema:+ $ref: '#/components/schemas/RenderErrorResponse'+ description: Internal Server Error+ security:+ - api_key:+ - ADMIN+ - tokenizer:+ - ADMIN+ summary: Update auth domain+ tags:+ - authdomains/api/v2/dashboard_views:get:deprecated: falsediff --git a/docs/contributing/go/handler.md b/docs/contributing/go/handler.mdindex 310fd786e3..72da350535 100644--- a/docs/contributing/go/handler.md+++ b/docs/contributing/go/handler.md@@ -349,7 +349,7 @@ func (Step) JSONSchema() (jsonschema.Schema, error) {### `oneOf` with a discriminator-For a sum type whose variants are keyed by a property (e.g. `kind`), expose the variants via `JSONSchemaOneOf()` and add a discriminator. Without it, code generators intersect the variants (`A & B & C`) instead of producing a clean discriminated union (`A | B | C`). How to model the sum type itself is covered in [types.md](types.md#sum-types-the-kindspec-envelope) — this section is only about its schema.+For a sum type whose variants are keyed by a property (e.g. `kind`), expose the variants via `JSONSchemaOneOf()` and add a discriminator. Without it, code generators intersect the variants (`A & B & C`) instead of producing a clean discriminated union (`A | B | C`).The parent keeps its `JSONSchemaOneOf()` (the `oneOf` itself) and *additionally* tags it via `PrepareJSONSchema` with the `x-signoz-discriminator` extension; `signoz.attachDiscriminators` then promotes that marker to a real OpenAPI 3 `discriminator` (and strips the duplicate parent properties) after reflection.diff --git a/docs/contributing/go/types.md b/docs/contributing/go/types.mdindex 2384904fdb..85289c984b 100644--- a/docs/contributing/go/types.md+++ b/docs/contributing/go/types.md@@ -61,31 +61,37 @@ type Channel struct {```gotype AuthDomain struct {- storableAuthDomain *StorableAuthDomain- authDomainConfig *AuthDomainConfig+ storableAuthDomain *StorableAuthDomain+ storableAuthDomainConfig *StorableAuthDomainConfig}type StorableAuthDomain struct {bun.BaseModel `bun:"table:auth_domain"`types.IdentifiableName string `bun:"name"`- Data string `bun:"data"` // AuthDomainConfig serialized as JSON+ Data string `bun:"data"` // StorableAuthDomainConfig serialized as JSONOrgID valuer.UUID `bun:"org_id"`types.TimeAuditable}type PostableAuthDomain struct {- Config AuthDomainConfig `json:"config"`- Name string `json:"name"`+ Name string `json:"name" required:"true"`+ Enabled bool `json:"enabled"`+ Config AuthDomainConfig `json:"config" required:"true"`+ RoleMapping *RoleMapping `json:"roleMapping"`}-type UpdateableAuthDomain struct {- Config AuthDomainConfig `json:"config"` // Name intentionally absent+type UpdatableAuthDomain struct {+ Enabled bool `json:"enabled"` // Name intentionally absent+ Config AuthDomainConfig `json:"config" required:"true"`+ RoleMapping *RoleMapping `json:"roleMapping"`}type GettableAuthDomain struct {- *StorableAuthDomain- *AuthDomainConfig+ StorableAuthDomain+ Enabled bool `json:"enabled"`+ Config AuthDomainConfig `json:"config"`+ RoleMapping *RoleMapping `json:"roleMapping"`AuthNProviderInfo *AuthNProviderInfo `json:"authNProviderInfo"`}```@@ -93,11 +99,11 @@ type GettableAuthDomain struct {Each flavor exists for a concrete reason:- `StorableAuthDomain` stores the typed config as an opaque `Data string` column, so the schema does not need to migrate every time a config field is added.-- `PostableAuthDomain` carries the config as a structured object (not a string) for the request.-- `UpdateableAuthDomain` excludes `Name` because a domain's name cannot change after creation.+- `PostableAuthDomain` carries the config as a structured object (not a string) for the request; `AuthDomainConfig` is a kind/spec envelope.+- `UpdatableAuthDomain` excludes `Name` because a domain's name cannot change after creation.- `GettableAuthDomain` adds `AuthNProviderInfo`, which is derived at read time and never persisted.-The core `AuthDomain` holds the two live halves — `storableAuthDomain` and `authDomainConfig` — and owns business methods such as `Update(config)`. Conversions use the `New<Output>From<Input>` form: `NewAuthDomainFromConfig`, `NewAuthDomainFromStorableAuthDomain`, `NewGettableAuthDomainFromAuthDomain`.+The core `AuthDomain` holds the two live halves — `storableAuthDomain` and `storableAuthDomainConfig` — and owns business methods such as `Update(updatable)` and `Patch(patchable)`. Conversions use the `New<Output>From<Input>` form: `NewAuthDomainFromPostableAuthDomain`, `NewAuthDomainFromStorableAuthDomain`, `NewGettableAuthDomainFromAuthDomain`.## Sum types: the kind/spec envelopediff --git a/ee/authn/callbackauthn/oidccallbackauthn/authn.go b/ee/authn/callbackauthn/oidccallbackauthn/authn.goindex a607c2c5ac..62364a6f92 100644--- a/ee/authn/callbackauthn/oidccallbackauthn/authn.go+++ b/ee/authn/callbackauthn/oidccallbackauthn/authn.go@@ -53,10 +53,6 @@ func New(store authtypes.AuthNStore, licensing licensing.Licensing, providerSett}func (a *AuthN) LoginURL(ctx context.Context, siteURL *url.URL, authDomain *authtypes.AuthDomain) (string, error) {- if authDomain.AuthDomainConfig().AuthNProvider != authtypes.AuthNProviderOIDC {- return "", errors.Newf(errors.TypeInternal, authtypes.ErrCodeAuthDomainMismatch, "domain type is not oidc")- }-_, oauth2Config, err := a.oidcProviderAndoauth2Config(ctx, siteURL, authDomain)if err != nil {return "", err@@ -85,6 +81,11 @@ func (a *AuthN) HandleCallback(ctx context.Context, query url.Values) (*authtypereturn nil, errors.New(errors.TypeLicenseUnavailable, errors.CodeLicenseUnavailable, "a valid license is not available").WithAdditional("this feature requires a valid license").WithAdditional(err.Error())}+ oidcConfig, err := authDomain.Config().OIDCConfig()+ if err != nil {+ return nil, err+ }+oidcProvider, oauth2Config, err := a.oidcProviderAndoauth2Config(ctx, state.URL, authDomain)if err != nil {return nil, err@@ -106,14 +107,14 @@ func (a *AuthN) HandleCallback(ctx context.Context, query url.Values) (*authtypereturn nil, err}- if claims == nil && authDomain.AuthDomainConfig().OIDC.GetUserInfo {+ if claims == nil && oidcConfig.GetUserInfo {claims, err = a.claimsFromUserInfo(ctx, oidcProvider, token)if err != nil {return nil, err}}- emailClaim, ok := claims[authDomain.AuthDomainConfig().OIDC.ClaimMapping.Email].(string)+ emailClaim, ok := claims[oidcConfig.ClaimMapping.Email].(string)if !ok {return nil, errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "oidc: missing email in claims")}@@ -123,7 +124,7 @@ func (a *AuthN) HandleCallback(ctx context.Context, query url.Values) (*authtypereturn nil, errors.Newf(errors.TypeInvalidInput, errors.CodeInvalidInput, "oidc: failed to parse email").WithAdditional(err.Error())}- if !authDomain.AuthDomainConfig().OIDC.InsecureSkipEmailVerified {+ if !oidcConfig.InsecureSkipEmailVerified {emailVerifiedClaim, ok := claims["email_verified"].(bool)if !ok {return nil, errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "oidc: missing email_verified in claims")@@ -135,14 +136,14 @@ func (a *AuthN) HandleCallback(ctx context.Context, query url.Values) (*authtype}name := ""- if nameClaim := authDomain.AuthDomainConfig().OIDC.ClaimMapping.Name; nameClaim != "" {+ if nameClaim := oidcConfig.ClaimMapping.Name; nameClaim != "" {if n, ok := claims[nameClaim].(string); ok {name = n}}var groups []string- if groupsClaim := authDomain.AuthDomainConfig().OIDC.ClaimMapping.Groups; groupsClaim != "" {+ if groupsClaim := oidcConfig.ClaimMapping.Groups; groupsClaim != "" {if claimValue, exists := claims[groupsClaim]; exists {switch g := claimValue.(type) {case []any:@@ -161,7 +162,7 @@ func (a *AuthN) HandleCallback(ctx context.Context, query url.Values) (*authtype}role := ""- if roleClaim := authDomain.AuthDomainConfig().OIDC.ClaimMapping.Role; roleClaim != "" {+ if roleClaim := oidcConfig.ClaimMapping.Role; roleClaim != "" {if r, ok := claims[roleClaim].(string); ok {role = r}@@ -177,11 +178,16 @@ func (a *AuthN) ProviderInfo(ctx context.Context, authDomain *authtypes.AuthDoma}func (a *AuthN) oidcProviderAndoauth2Config(ctx context.Context, siteURL *url.URL, authDomain *authtypes.AuthDomain) (*oidc.Provider, *oauth2.Config, error) {- if authDomain.AuthDomainConfig().OIDC.IssuerAlias != "" {- ctx = oidc.InsecureIssuerURLContext(ctx, authDomain.AuthDomainConfig().OIDC.IssuerAlias)+ oidcConfig, err := authDomain.Config().OIDCConfig()+ if err != nil {+ return nil, nil, err+ }++ if oidcConfig.IssuerAlias != "" {+ ctx = oidc.InsecureIssuerURLContext(ctx, oidcConfig.IssuerAlias)}- oidcProvider, err := oidc.NewProvider(ctx, authDomain.AuthDomainConfig().OIDC.Issuer)+ oidcProvider, err := oidc.NewProvider(ctx, oidcConfig.Issuer)if err != nil {return nil, nil, err}@@ -189,13 +195,13 @@ func (a *AuthN) oidcProviderAndoauth2Config(ctx context.Context, siteURL *url.URscopes := make([]string, len(defaultScopes))copy(scopes, defaultScopes)- if authDomain.AuthDomainConfig().RoleMapping != nil && len(authDomain.AuthDomainConfig().RoleMapping.GroupMappings) > 0 {+ if authDomain.RoleMapping() != nil && len(authDomain.RoleMapping().GroupMappings) > 0 {scopes = append(scopes, "groups")}return oidcProvider, &oauth2.Config{- ClientID: authDomain.AuthDomainConfig().OIDC.ClientID,- ClientSecret: authDomain.AuthDomainConfig().OIDC.ClientSecret,+ ClientID: oidcConfig.ClientID,+ ClientSecret: oidcConfig.ClientSecret,Endpoint: oidcProvider.Endpoint(),Scopes: scopes,RedirectURL: (&url.URL{@@ -212,7 +218,12 @@ func (a *AuthN) claimsFromIDToken(ctx context.Context, authDomain *authtypes.Autreturn nil, errors.New(errors.TypeNotFound, errors.CodeNotFound, "oidc: no id_token in token response")}- verifier := provider.Verifier(&oidc.Config{ClientID: authDomain.AuthDomainConfig().OIDC.ClientID})+ oidcConfig, err := authDomain.Config().OIDCConfig()+ if err != nil {+ return nil, err+ }++ verifier := provider.Verifier(&oidc.Config{ClientID: oidcConfig.ClientID})idToken, err := verifier.Verify(ctx, rawIDToken)if err != nil {return nil, errors.Newf(errors.TypeForbidden, errors.CodeForbidden, "oidc: failed to verify token").WithAdditional(err.Error())diff --git a/ee/authn/callbackauthn/samlcallbackauthn/authn.go b/ee/authn/callbackauthn/samlcallbackauthn/authn.goindex 0233472320..be73af7a50 100644--- a/ee/authn/callbackauthn/samlcallbackauthn/authn.go+++ b/ee/authn/callbackauthn/samlcallbackauthn/authn.go@@ -40,10 +40,6 @@ func New(ctx context.Context, store authtypes.AuthNStore, licensing licensing.Li}func (a *AuthN) LoginURL(ctx context.Context, siteURL *url.URL, authDomain *authtypes.AuthDomain) (string, error) {- if authDomain.AuthDomainConfig().AuthNProvider != authtypes.AuthNProviderSAML {- return "", errors.Newf(errors.TypeInternal, authtypes.ErrCodeAuthDomainMismatch, "saml: domain type is not saml")- }-sp, err := a.serviceProvider(siteURL, authDomain)if err != nil {return "", err@@ -73,6 +69,11 @@ func (a *AuthN) HandleCallback(ctx context.Context, formValues url.Values) (*autreturn nil, errors.New(errors.TypeLicenseUnavailable, errors.CodeLicenseUnavailable, "a valid license is not available").WithAdditional("this feature requires a valid license").WithAdditional(err.Error())}+ samlConfig, err := authDomain.Config().SamlConfig()+ if err != nil {+ return nil, err+ }+sp, err := a.serviceProvider(state.URL, authDomain)if err != nil {return nil, err@@ -101,19 +102,19 @@ func (a *AuthN) HandleCallback(ctx context.Context, formValues url.Values) (*aut}name := ""- if nameAttribute := authDomain.AuthDomainConfig().SAML.AttributeMapping.Name; nameAttribute != "" {+ if nameAttribute := samlConfig.AttributeMapping.Name; nameAttribute != "" {if val := assertionInfo.Values.Get(nameAttribute); val != "" {name = val}}var groups []string- if groupAttribute := authDomain.AuthDomainConfig().SAML.AttributeMapping.Groups; groupAttribute != "" {+ if groupAttribute := samlConfig.AttributeMapping.Groups; groupAttribute != "" {groups = assertionInfo.Values.GetAll(groupAttribute)}role := ""- if roleAttribute := authDomain.AuthDomainConfig().SAML.AttributeMapping.Role; roleAttribute != "" {+ if roleAttribute := samlConfig.AttributeMapping.Role; roleAttribute != "" {if val := assertionInfo.Values.Get(roleAttribute); val != "" {role = val}@@ -131,7 +132,12 @@ func (a *AuthN) ProviderInfo(ctx context.Context, authDomain *authtypes.AuthDoma}func (a *AuthN) serviceProvider(siteURL *url.URL, authDomain *authtypes.AuthDomain) (*saml2.SAMLServiceProvider, error) {- certStore, err := a.getCertificateStore(authDomain)+ samlConfig, err := authDomain.Config().SamlConfig()+ if err != nil {+ return nil, err+ }++ certStore, err := a.getCertificateStore(samlConfig)if err != nil {return nil, err}@@ -142,32 +148,32 @@ func (a *AuthN) serviceProvider(siteURL *url.URL, authDomain *authtypes.AuthDoma// 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.// For AWSSSO, this is the value of Application SAML audience.return &saml2.SAMLServiceProvider{- IdentityProviderSSOURL: authDomain.AuthDomainConfig().SAML.SamlIdp,- IdentityProviderIssuer: authDomain.AuthDomainConfig().SAML.SamlEntity,+ IdentityProviderSSOURL: samlConfig.Location,+ IdentityProviderIssuer: samlConfig.EntityID,ServiceProviderIssuer: siteURL.Host,AssertionConsumerServiceURL: acsURL.String(),- SignAuthnRequests: !authDomain.AuthDomainConfig().SAML.InsecureSkipAuthNRequestsSigned,+ SignAuthnRequests: !samlConfig.InsecureSkipAuthNRequestsSigned,AllowMissingAttributes: true,IDPCertificateStore: certStore,SPKeyStore: dsig.RandomKeyStoreForTest(),}, nil}-func (a *AuthN) getCertificateStore(authDomain *authtypes.AuthDomain) (dsig.X509CertificateStore, error) {+func (a *AuthN) getCertificateStore(samlConfig authtypes.SamlConfig) (dsig.X509CertificateStore, error) {certStore := &dsig.MemoryX509CertificateStore{Roots: []*x509.Certificate{},}var certBytes []byte- if strings.Contains(authDomain.AuthDomainConfig().SAML.SamlCert, "-----BEGIN CERTIFICATE-----") {- block, _ := pem.Decode([]byte(authDomain.AuthDomainConfig().SAML.SamlCert))+ if strings.Contains(samlConfig.Certificate, "-----BEGIN CERTIFICATE-----") {+ block, _ := pem.Decode([]byte(samlConfig.Certificate))if block == nil {return certStore, errors.Newf(errors.TypeInvalidInput, errors.CodeInvalidInput, "no valid pem cert found")}certBytes = block.Bytes} else {- certData, err := base64.StdEncoding.DecodeString(authDomain.AuthDomainConfig().SAML.SamlCert)+ certData, err := base64.StdEncoding.DecodeString(samlConfig.Certificate)if err != nil {return certStore, errors.Newf(errors.TypeInvalidInput, errors.CodeInvalidInput, "failed to read certificate: %s", err.Error())}diff --git a/frontend/src/api/generated/services/authdomains/index.ts b/frontend/src/api/generated/services/authdomains/index.tsindex d9a4e2b5cd..5b5cf79e4f 100644--- a/frontend/src/api/generated/services/authdomains/index.ts+++ b/frontend/src/api/generated/services/authdomains/index.ts@@ -38,14 +38,14 @@ import type { ErrorType, BodyType } from '../../../generatedAPIInstance';*/export const listAuthDomains = (signal?: AbortSignal) => {return GeneratedAPIInstance<ListAuthDomains200>({- url: `/api/v1/domains`,+ url: `/api/v2/auth_domains`,method: 'GET',signal,});};export const getListAuthDomainsQueryKey = () => {- return [`/api/v1/domains`] as const;+ return [`/api/v2/auth_domains`] as const;};export const getListAuthDomainsQueryOptions = <@@ -125,7 +125,7 @@ export const createAuthDomain = (signal?: AbortSignal,) => {return GeneratedAPIInstance<CreateAuthDomain201>({- url: `/api/v1/domains`,+ url: `/api/v2/auth_domains`,method: 'POST',headers: { 'Content-Type': 'application/json' },data: authtypesPostableAuthDomainDTO,@@ -208,7 +208,7 @@ export const deleteAuthDomain = (signal?: AbortSignal,) => {return GeneratedAPIInstance<void>({- url: `/api/v1/domains/${id}`,+ url: `/api/v2/auth_domains/${id}`,method: 'DELETE',signal,});@@ -287,7 +287,7 @@ export const getAuthDomain = (signal?: AbortSignal,) => {return GeneratedAPIInstance<GetAuthDomain200>({- url: `/api/v1/domains/${id}`,+ url: `/api/v2/auth_domains/${id}`,method: 'GET',signal,});@@ -296,7 +296,7 @@ export const getAuthDomain = (export const getGetAuthDomainQueryKey = ({id,}: GetAuthDomainPathParameters) => {- return [`/api/v1/domains/${id}`] as const;+ return [`/api/v2/auth_domains/${id}`] as const;};export const getGetAuthDomainQueryOptions = <@@ -389,7 +389,7 @@ export const updateAuthDomain = (signal?: AbortSignal,) => {return GeneratedAPIInstance<void>({- url: `/api/v1/domains/${id}`,+ url: `/api/v2/auth_domains/${id}`,method: 'PUT',headers: { 'Content-Type': 'application/json' },data: authtypesUpdatableAuthDomainDTO,diff --git a/frontend/src/api/generated/services/sigNoz.schemas.ts b/frontend/src/api/generated/services/sigNoz.schemas.tsindex 5880fb536d..b77a0ffc6b 100644--- a/frontend/src/api/generated/services/sigNoz.schemas.ts+++ b/frontend/src/api/generated/services/sigNoz.schemas.ts@@ -1861,26 +1861,41 @@ export interface AuthtypesAttributeMappingDTO {role?: string;}+export enum AuthtypesAuthDomainConfigSAMLDTOKind {+ saml = 'saml',+}export interface AuthtypesSamlConfigDTO {attributeMapping?: AuthtypesAttributeMappingDTO;/**- * @type boolean+ * @type string*/- insecureSkipAuthNRequestsSigned?: boolean;+ certificate: string;/*** @type string*/- samlCert?: string;+ entityId: string;+ /**+ * @type boolean+ */+ insecureSkipAuthNRequestsSigned?: boolean;/*** @type string*/- samlEntity?: string;+ location: string;+}++export interface AuthtypesAuthDomainConfigSAMLDTO {/*** @type string+ * @enum saml*/- samlIdp?: string;+ kind: AuthtypesAuthDomainConfigSAMLDTOKind;+ spec: AuthtypesSamlConfigDTO;}+export enum AuthtypesAuthDomainConfigGoogleDTOKind {+ google = 'google',+}export type AuthtypesGoogleConfigDTODomainToAdminEmail = {[key: string]: string;};@@ -1893,11 +1908,12 @@ export interface AuthtypesGoogleConfigDTO {/*** @type string*/- clientId?: string;+ clientId: string;/*** @type string+ * @format password*/- clientSecret?: string;+ clientSecret: string;/*** @type object*/@@ -1916,24 +1932,34 @@ export interface AuthtypesGoogleConfigDTO {insecureSkipEmailVerified?: boolean;/*** @type string+ * @format password*/- redirectURI?: string;+ serviceAccountJson?: string;+}++export interface AuthtypesAuthDomainConfigGoogleDTO {/*** @type string+ * @enum google*/- serviceAccountJson?: string;+ kind: AuthtypesAuthDomainConfigGoogleDTOKind;+ spec: AuthtypesGoogleConfigDTO;}+export enum AuthtypesAuthDomainConfigOIDCDTOKind {+ oidc = 'oidc',+}export interface AuthtypesOIDCConfigDTO {claimMapping?: AuthtypesAttributeMappingDTO;/*** @type string*/- clientId?: string;+ clientId: string;/*** @type string+ * @format password*/- clientSecret?: string;+ clientSecret: string;/*** @type boolean*/@@ -1945,79 +1971,33 @@ export interface AuthtypesOIDCConfigDTO {/*** @type string*/- issuer?: string;+ issuer: string;/*** @type string*/issuerAlias?: string;}-export type AuthtypesRoleMappingDTOGroupMappingsAnyOf = {- [key: string]: string;-};--/**- * @nullable- */-export type AuthtypesRoleMappingDTOGroupMappings =- AuthtypesRoleMappingDTOGroupMappingsAnyOf | null;--export interface AuthtypesRoleMappingDTO {+export interface AuthtypesAuthDomainConfigOIDCDTO {/*** @type string+ * @enum oidc*/- defaultRole?: string;- /**- * @type object,null- */- groupMappings?: AuthtypesRoleMappingDTOGroupMappings;- /**- * @type boolean- */- useRoleAttribute?: boolean;+ kind: AuthtypesAuthDomainConfigOIDCDTOKind;+ spec: AuthtypesOIDCConfigDTO;}+export type AuthtypesAuthDomainConfigDTO =+ | AuthtypesAuthDomainConfigSAMLDTO+ | AuthtypesAuthDomainConfigGoogleDTO+ | AuthtypesAuthDomainConfigOIDCDTO;+export enum AuthtypesAuthNProviderDTO {- google_auth = 'google_auth',+ google = 'google',saml = 'saml',email_password = 'email_password',oidc = 'oidc',}-export type AuthtypesAuthDomainConfigDTO =- | (AuthtypesSamlConfigDTO & {- googleAuthConfig?: AuthtypesGoogleConfigDTO;- oidcConfig?: AuthtypesOIDCConfigDTO;- roleMapping?: AuthtypesRoleMappingDTO;- samlConfig?: AuthtypesSamlConfigDTO;- /**- * @type boolean- */- ssoEnabled?: boolean;- ssoType?: AuthtypesAuthNProviderDTO;- })- | (AuthtypesGoogleConfigDTO & {- googleAuthConfig?: AuthtypesGoogleConfigDTO;- oidcConfig?: AuthtypesOIDCConfigDTO;- roleMapping?: AuthtypesRoleMappingDTO;- samlConfig?: AuthtypesSamlConfigDTO;- /**- * @type boolean- */- ssoEnabled?: boolean;- ssoType?: AuthtypesAuthNProviderDTO;- })- | (AuthtypesOIDCConfigDTO & {- googleAuthConfig?: AuthtypesGoogleConfigDTO;- oidcConfig?: AuthtypesOIDCConfigDTO;- roleMapping?: AuthtypesRoleMappingDTO;- samlConfig?: AuthtypesSamlConfigDTO;- /**- * @type boolean- */- ssoEnabled?: boolean;- ssoType?: AuthtypesAuthNProviderDTO;- });-export interface AuthtypesAuthNProviderInfoDTO {/*** @type string,null@@ -2055,6 +2035,31 @@ export interface AuthtypesDeprecatedPostableUserRoleDTO {id: string;}+export type AuthtypesRoleMappingDTOGroupMappingsAnyOf = {+ [key: string]: string;+};++/**+ * @nullable+ */+export type AuthtypesRoleMappingDTOGroupMappings =+ AuthtypesRoleMappingDTOGroupMappingsAnyOf | null;++export interface AuthtypesRoleMappingDTO {+ /**+ * @type string+ */+ defaultRole?: string;+ /**+ * @type object,null+ */+ groupMappings?: AuthtypesRoleMappingDTOGroupMappings;+ /**+ * @type boolean+ */+ useRoleAttribute?: boolean;+}+export interface AuthtypesGettableAuthDomainDTO {authNProviderInfo?: AuthtypesAuthNProviderInfoDTO;config?: AuthtypesAuthDomainConfigDTO;@@ -2063,6 +2068,10 @@ export interface AuthtypesGettableAuthDomainDTO {* @format date-time*/createdAt?: string;+ /**+ * @type boolean+ */+ enabled?: boolean;/*** @type string*/@@ -2075,6 +2084,7 @@ export interface AuthtypesGettableAuthDomainDTO {* @type string*/orgId?: string;+ roleMapping?: AuthtypesRoleMappingDTO;/*** @type string* @format date-time@@ -2271,11 +2281,16 @@ export interface AuthtypesOrgSessionContextDTO {}export interface AuthtypesPostableAuthDomainDTO {- config?: AuthtypesAuthDomainConfigDTO;+ config: AuthtypesAuthDomainConfigDTO;+ /**+ * @type boolean+ */+ enabled?: boolean;/*** @type string*/- name?: string;+ name: string;+ roleMapping?: AuthtypesRoleMappingDTO;}export interface AuthtypesPostableEmailPasswordSessionDTO {@@ -2408,7 +2423,12 @@ export interface AuthtypesTransactionDTO {}export interface AuthtypesUpdatableAuthDomainDTO {- config?: AuthtypesAuthDomainConfigDTO;+ config: AuthtypesAuthDomainConfigDTO;+ /**+ * @type boolean+ */+ enabled?: boolean;+ roleMapping?: AuthtypesRoleMappingDTO;}export interface AuthtypesUpdatableRoleDTO {@@ -10417,42 +10437,6 @@ export type CreatePublicDashboard201 = {export type UpdatePublicDashboardPathParameters = {id: string;};-export type ListAuthDomains200 = {- /**- * @type array- */- data: AuthtypesGettableAuthDomainDTO[];- /**- * @type string- */- status: string;-};--export type CreateAuthDomain201 = {- data: TypesIdentifiableDTO;- /**- * @type string- */- status: string;-};--export type DeleteAuthDomainPathParameters = {- id: string;-};-export type GetAuthDomainPathParameters = {- id: string;-};-export type GetAuthDomain200 = {- data: AuthtypesGettableAuthDomainDTO;- /**- * @type string- */- status: string;-};--export type UpdateAuthDomainPathParameters = {- id: string;-};export type ListDowntimeSchedulesParams = {/*** @type boolean,null@@ -11088,6 +11072,42 @@ export type GetUserPreference200 = {export type UpdateUserPreferencePathParameters = {name: string;};+export type ListAuthDomains200 = {+ /**+ * @type array+ */+ data: AuthtypesGettableAuthDomainDTO[];+ /**+ * @type string+ */+ status: string;+};++export type CreateAuthDomain201 = {+ data: TypesIdentifiableDTO;+ /**+ * @type string+ */+ status: string;+};++export type DeleteAuthDomainPathParameters = {+ id: string;+};+export type GetAuthDomainPathParameters = {+ id: string;+};+export type GetAuthDomain200 = {+ data: AuthtypesGettableAuthDomainDTO;+ /**+ * @type string+ */+ status: string;+};++export type UpdateAuthDomainPathParameters = {+ id: string;+};export type ListDashboardViews200 = {data: DashboardtypesListableDashboardViewDTO;/**diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/AuthnProviderSelector.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/AuthnProviderSelector.tsxindex c0328cf4ab..eb185a89c4 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/AuthnProviderSelector.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/AuthnProviderSelector.tsx@@ -16,7 +16,7 @@ interface AuthNProvider {function getAuthNProviders(samlEnabled: boolean): AuthNProvider[] {return [{- key: AuthtypesAuthNProviderDTO.google_auth,+ key: AuthtypesAuthNProviderDTO.google,title: 'Google Apps Authentication',description: 'Let members sign-in with a Google workspace account',icon: <SolidGoogle size={37} />,@@ -78,6 +78,7 @@ function AuthnProviderSelector({<ButtononClick={(): void => setAuthnProvider(provider.key)}type="primary"+ data-testid={`authn-provider-configure-${provider.key}`}>Configure</Button>diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.tsxindex 39dc9721f5..c779f8efe1 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.tsx@@ -10,8 +10,6 @@ import {import {AuthtypesAuthNProviderDTO,AuthtypesGettableAuthDomainDTO,- AuthtypesGoogleConfigDTO,- AuthtypesRoleMappingDTO,RenderErrorResponseDTO,} from 'api/generated/services/sigNoz.schemas';import { AxiosError } from 'axios';@@ -24,10 +22,11 @@ import APIError from 'types/api/error';import AuthnProviderSelector from './AuthnProviderSelector';import {- convertDomainMappingsToRecord,- convertGroupMappingsToRecord,FormValues,+ kindToProvider,+ prepareConfig,prepareInitialValues,+ prepareRoleMapping,} from './CreateEdit.utils';import ConfigureGoogleAuthAuthnProvider from './Providers/AuthnGoogleAuth';import ConfigureOIDCAuthnProvider from './Providers/AuthnOIDC';@@ -41,7 +40,7 @@ function configureAuthnProvider(switch (authnProvider) {case 'saml':return <ConfigureSAMLAuthnProvider isCreate={isCreate} />;- case 'google_auth':+ case 'google':return <ConfigureGoogleAuthAuthnProvider isCreate={isCreate} />;case 'oidc':return <ConfigureOIDCAuthnProvider isCreate={isCreate} />;@@ -61,7 +60,7 @@ function CreateOrEdit(props: CreateOrEditProps): JSX.Element {const [form] = Form.useForm<FormValues>();const [authnProvider, setAuthnProvider] = useState<AuthtypesAuthNProviderDTO | ''- >(record?.config?.ssoType || '');+ >(kindToProvider(record?.config?.kind));const { showErrorModal } = useErrorModal();const { featureFlags } = useAppContext();@@ -85,68 +84,6 @@ function CreateOrEdit(props: CreateOrEditProps): JSX.Element {const { mutate: updateAuthDomain, isLoading: isUpdating } =useUpdateAuthDomain<AxiosError<RenderErrorResponseDTO>>();- /**- * Prepares Google Auth config for API payload- */- const getGoogleAuthConfig = useCallback(():- | AuthtypesGoogleConfigDTO- | undefined => {- const config = form.getFieldValue('googleAuthConfig');- if (!config) {- return undefined;- }-- const {- domainToAdminEmailList,- allowedGroups,- serviceAccountJson,- domainToAdminEmail: _domainToAdminEmail,- fetchTransitiveGroupMembership,- ...rest- } = config;- const domainToAdminEmail = convertDomainMappingsToRecord(- domainToAdminEmailList,- );-- return {- ...rest,- ...(rest.fetchGroups- ? {- allowedGroups,- serviceAccountJson,- domainToAdminEmail: domainToAdminEmail ?? {},- fetchTransitiveGroupMembership,- }- : { domainToAdminEmail: {} }),- };- }, [form]);-- // Prepares role mapping for API payload- const getRoleMapping = useCallback((): AuthtypesRoleMappingDTO | undefined => {- const roleMapping = form.getFieldValue('roleMapping');- if (!roleMapping) {- return undefined;- }-- const { groupMappingsList, ...rest } = roleMapping;- const groupMappings = convertGroupMappingsToRecord(groupMappingsList);-- // Only return roleMapping if there's meaningful content- const hasDefaultRole = !!rest.defaultRole;- const hasUseRoleAttribute = rest.useRoleAttribute === true;- const hasGroupMappings =- groupMappings && Object.keys(groupMappings).length > 0;-- if (!hasDefaultRole && !hasUseRoleAttribute && !hasGroupMappings) {- return undefined;- }-- return {- ...rest,- groupMappings: rest.useRoleAttribute ? undefined : (groupMappings ?? {}),- };- }, [form]);-const onSubmitHandler = useCallback(async (): Promise<void> => {try {await form.validateFields();@@ -158,25 +95,23 @@ function CreateOrEdit(props: CreateOrEditProps): JSX.Element {return;}- const name = form.getFieldValue('name');- const googleAuthConfig = getGoogleAuthConfig();- const samlConfig = form.getFieldValue('samlConfig');- const oidcConfig = form.getFieldValue('oidcConfig');- const roleMapping = getRoleMapping();+ const values = form.getFieldsValue(true) as FormValues;+ const name = values.name ?? '';+ const config = prepareConfig(values, authnProvider);+ const roleMapping = prepareRoleMapping(values);++ if (!config) {+ return;+ }if (isCreate) {createAuthDomain({data: {name,- config: {- ssoEnabled: true,- ssoType: authnProvider,- googleAuthConfig,- samlConfig,- oidcConfig,- roleMapping,- },+ enabled: true,+ config,+ roleMapping,},},{@@ -196,14 +131,9 @@ function CreateOrEdit(props: CreateOrEditProps): JSX.Element {{pathParams: { id: record.id },data: {- config: {- ssoEnabled: form.getFieldValue('ssoEnabled'),- ssoType: authnProvider,- googleAuthConfig,- samlConfig,- oidcConfig,- roleMapping,- },+ enabled: values.enabled ?? false,+ config,+ roleMapping,},},{@@ -219,8 +149,6 @@ function CreateOrEdit(props: CreateOrEditProps): JSX.Element {authnProvider,createAuthDomain,form,- getGoogleAuthConfig,- getRoleMapping,handleError,isCreate,@@ -243,10 +171,10 @@ function CreateOrEdit(props: CreateOrEditProps): JSX.Element {><Formname="auth-domain"+ data-testid="auth-domain-form"initialValues={defaultTo(prepareInitialValues(record), {name: '',- ssoEnabled: false,- ssoType: '',+ enabled: false,})}form={form}layout="vertical"@@ -262,12 +190,22 @@ function CreateOrEdit(props: CreateOrEditProps): JSX.Element {{configureAuthnProvider(authnProvider, isCreate)}<section className="action-buttons">{isCreate && (- <Button onClick={onBackHandler} variant="solid" color="secondary">+ <Button+ onClick={onBackHandler}+ variant="solid"+ color="secondary"+ testId="auth-domain-back"+ >Back</Button>)}{!isCreate && (- <Button onClick={onClose} variant="solid" color="secondary">+ <Button+ onClick={onClose}+ variant="solid"+ color="secondary"+ testId="auth-domain-cancel"+ >Cancel</Button>)}@@ -276,6 +214,7 @@ function CreateOrEdit(props: CreateOrEditProps): JSX.Element {variant="solid"color="primary"loading={isCreating || isUpdating}+ testId="auth-domain-save">Save Changes</Button>diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.utils.test.ts b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.utils.test.tsindex 4698360f14..f665c1a3d5 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.utils.test.ts+++ b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.utils.test.ts@@ -1,4 +1,8 @@-import { AuthtypesAuthNProviderDTO } from 'api/generated/services/sigNoz.schemas';+import {+ AuthtypesAuthDomainConfigGoogleDTOKind,+ AuthtypesAuthDomainConfigOIDCDTOKind,+ AuthtypesAuthDomainConfigSAMLDTOKind,+} from 'api/generated/services/sigNoz.schemas';import {convertDomainMappingsToList,@@ -82,8 +86,7 @@ describe('prepareInitialValues', () => {it('returns empty defaults when no record is provided', () => {expect(prepareInitialValues(undefined)).toStrictEqual({name: '',- ssoEnabled: false,- ssoType: '',+ enabled: false,});});@@ -91,15 +94,20 @@ describe('prepareInitialValues', () => {const result = prepareInitialValues({id: 'domain-1',name: 'example.com',+ enabled: true,config: {- ssoEnabled: true,- ssoType: AuthtypesAuthNProviderDTO.saml,- roleMapping: {- defaultRole: 'VIEWER',- useRoleAttribute: false,- groupMappings: { admins: 'ADMIN', viewers: 'VIEWER' },+ kind: AuthtypesAuthDomainConfigSAMLDTOKind.saml,+ spec: {+ location: 'https://idp.example.com/sso',+ entityId: 'urn:example:idp',+ certificate: 'CERT',},},+ roleMapping: {+ defaultRole: 'VIEWER',+ useRoleAttribute: false,+ groupMappings: { admins: 'ADMIN', viewers: 'VIEWER' },+ },});expect(result.roleMapping?.groupMappingsList).toStrictEqual([@@ -112,10 +120,10 @@ describe('prepareInitialValues', () => {const result = prepareInitialValues({id: 'domain-1',name: 'example.com',+ enabled: true,config: {- ssoEnabled: true,- ssoType: AuthtypesAuthNProviderDTO.google_auth,- googleAuthConfig: {+ kind: AuthtypesAuthDomainConfigGoogleDTOKind.google,+ spec: {clientId: 'id',clientSecret: 'secret',domainToAdminEmail: { 'example.com': '[email protected]' },@@ -132,11 +140,16 @@ describe('prepareInitialValues', () => {const result = prepareInitialValues({id: 'domain-1',name: 'example.com',+ enabled: true,config: {- ssoEnabled: true,- ssoType: AuthtypesAuthNProviderDTO.oidc,- roleMapping: { defaultRole: 'VIEWER', useRoleAttribute: true },+ kind: AuthtypesAuthDomainConfigOIDCDTOKind.oidc,+ spec: {+ issuer: 'https://oidc.example.com',+ clientId: 'id',+ clientSecret: 'secret',+ },},+ roleMapping: { defaultRole: 'VIEWER', useRoleAttribute: true },});expect(result.roleMapping?.groupMappingsList).toStrictEqual([]);diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.utils.ts b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.utils.tsindex 7cf5c4db58..5c9184ee91 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.utils.ts+++ b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/CreateEdit.utils.ts@@ -1,4 +1,9 @@import {+ AuthtypesAuthDomainConfigDTO,+ AuthtypesAuthDomainConfigGoogleDTOKind,+ AuthtypesAuthDomainConfigOIDCDTOKind,+ AuthtypesAuthDomainConfigSAMLDTOKind,+ AuthtypesAuthNProviderDTO,AuthtypesGettableAuthDomainDTO,AuthtypesGoogleConfigDTO,AuthtypesOIDCConfigDTO,@@ -6,11 +11,29 @@ import {AuthtypesSamlConfigDTO,} from 'api/generated/services/sigNoz.schemas';+/**+ * Maps the config envelope's per-variant kind to the provider enum driving the+ * create/edit UI.+ */+export function kindToProvider(+ kind?: AuthtypesAuthDomainConfigDTO['kind'],+): AuthtypesAuthNProviderDTO | '' {+ switch (kind) {+ case AuthtypesAuthDomainConfigSAMLDTOKind.saml:+ return AuthtypesAuthNProviderDTO.saml;+ case AuthtypesAuthDomainConfigGoogleDTOKind.google:+ return AuthtypesAuthNProviderDTO.google;+ case AuthtypesAuthDomainConfigOIDCDTOKind.oidc:+ return AuthtypesAuthNProviderDTO.oidc;+ default:+ return '';+ }+}+// Form values interface for internal use (includes array-based fields for UI)export interface FormValues {name?: string;- ssoEnabled?: boolean;- ssoType?: string;+ enabled?: boolean;googleAuthConfig?: AuthtypesGoogleConfigDTO & {domainToAdminEmailList?: Array<{ domain?: string; adminEmail?: string }>;};@@ -107,33 +130,141 @@ export function prepareInitialValues(if (!record) {return {name: '',- ssoEnabled: false,- ssoType: '',+ enabled: false,};}- const config = record.config ?? {};+ const { config } = record;return {name: record.name,- ssoEnabled: config.ssoEnabled,- ssoType: config.ssoType,- samlConfig: config.samlConfig ?? undefined,- oidcConfig: config.oidcConfig ?? undefined,- googleAuthConfig: config.googleAuthConfig+ enabled: record.enabled,+ samlConfig:+ config?.kind === AuthtypesAuthDomainConfigSAMLDTOKind.saml+ ? config.spec+ : undefined,+ oidcConfig:+ config?.kind === AuthtypesAuthDomainConfigOIDCDTOKind.oidc+ ? config.spec+ : undefined,+ googleAuthConfig:+ config?.kind === AuthtypesAuthDomainConfigGoogleDTOKind.google+ ? {+ ...config.spec,+ domainToAdminEmailList: convertDomainMappingsToList(+ config.spec.domainToAdminEmail,+ ),+ }+ : undefined,+ roleMapping: record.roleMapping? {- ...config.googleAuthConfig,- domainToAdminEmailList: convertDomainMappingsToList(- config.googleAuthConfig.domainToAdminEmail,+ ...record.roleMapping,+ groupMappingsList: convertGroupMappingsToList(+ record.roleMapping.groupMappings,),}: undefined,- roleMapping: config.roleMapping+ };+}++/**+ * Prepares Google Auth config for API payload+ */+export function prepareGoogleAuthConfig(+ values: FormValues,+): AuthtypesGoogleConfigDTO | undefined {+ const config = values.googleAuthConfig;+ if (!config) {+ return undefined;+ }++ const {+ domainToAdminEmailList,+ allowedGroups,+ serviceAccountJson,+ domainToAdminEmail: _domainToAdminEmail,+ fetchTransitiveGroupMembership,+ ...rest+ } = config;+ const domainToAdminEmail = convertDomainMappingsToRecord(+ domainToAdminEmailList,+ );++ return {+ ...rest,+ ...(rest.fetchGroups? {- ...config.roleMapping,- groupMappingsList: convertGroupMappingsToList(- config.roleMapping.groupMappings,- ),+ allowedGroups,+ serviceAccountJson,+ domainToAdminEmail: domainToAdminEmail ?? {},+ fetchTransitiveGroupMembership,}- : undefined,+ : { domainToAdminEmail: {} }),};}++/**+ * Prepares role mapping for API payload; only returned when there is+ * meaningful content.+ */+export function prepareRoleMapping(+ values: FormValues,+): AuthtypesRoleMappingDTO | undefined {+ const roleMapping = values.roleMapping;+ if (!roleMapping) {+ return undefined;+ }++ const { groupMappingsList, ...rest } = roleMapping;+ const groupMappings = convertGroupMappingsToRecord(groupMappingsList);++ const hasDefaultRole = !!rest.defaultRole;+ const hasUseRoleAttribute = rest.useRoleAttribute === true;+ const hasGroupMappings =+ groupMappings && Object.keys(groupMappings).length > 0;++ if (!hasDefaultRole && !hasUseRoleAttribute && !hasGroupMappings) {+ return undefined;+ }++ return {+ ...rest,+ groupMappings: rest.useRoleAttribute ? undefined : (groupMappings ?? {}),+ };+}++/**+ * Prepares the kind/spec config envelope for API payload; the inverse of+ * prepareInitialValues.+ */+export function prepareConfig(+ values: FormValues,+ provider: AuthtypesAuthNProviderDTO | '',+): AuthtypesAuthDomainConfigDTO | undefined {+ switch (provider) {+ case AuthtypesAuthNProviderDTO.saml:+ return values.samlConfig+ ? {+ kind: AuthtypesAuthDomainConfigSAMLDTOKind.saml,+ spec: values.samlConfig,+ }+ : undefined;+ case AuthtypesAuthNProviderDTO.google: {+ const spec = prepareGoogleAuthConfig(values);+ return spec+ ? {+ kind: AuthtypesAuthDomainConfigGoogleDTOKind.google,+ spec,+ }+ : undefined;+ }+ case AuthtypesAuthNProviderDTO.oidc:+ return values.oidcConfig+ ? {+ kind: AuthtypesAuthDomainConfigOIDCDTOKind.oidc,+ spec: values.oidcConfig,+ }+ : undefined;+ default:+ return undefined;+ }+}diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/AuthnGoogleAuth.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/AuthnGoogleAuth.tsxindex c1834cd67c..f3a59925bb 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/AuthnGoogleAuth.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/AuthnGoogleAuth.tsx@@ -91,7 +91,11 @@ function ConfigureGoogleAuthAuthnProvider({{ required: true, message: 'Domain is required', whitespace: true },]}>- <Input id="google-domain" disabled={!isCreate} />+ <Input+ id="google-domain"+ disabled={!isCreate}+ testId="google-auth-domain"+ /></Form.Item></div>@@ -109,7 +113,7 @@ function ConfigureGoogleAuthAuthnProvider({{ required: true, message: 'Client ID is required', whitespace: true },]}>- <Input id="google-client-id" />+ <Input id="google-client-id" testId="google-auth-client-id" /></Form.Item></div>@@ -131,7 +135,7 @@ function ConfigureGoogleAuthAuthnProvider({},]}>- <Input id="google-client-secret" />+ <Input id="google-client-secret" testId="google-auth-client-secret" /></Form.Item></div>@@ -143,6 +147,7 @@ function ConfigureGoogleAuthAuthnProvider({><Checkboxid="google-skip-email-verification"+ testId="google-auth-skip-email-verified"onChange={(checked: boolean): void => {form.setFieldValue(['googleAuthConfig', 'insecureSkipEmailVerified'],@@ -180,7 +185,10 @@ function ConfigureGoogleAuthAuthnProvider({<Collapse.Panelkey="workspace-groups"header={- <div className="authn-provider__collapse-header">+ <div+ className="authn-provider__collapse-header"+ data-testid="google-auth-workspace-groups-header"+ >{expandedSection !== 'workspace-groups' ? (<ChevronRight size={16} />) : (@@ -221,6 +229,7 @@ function ConfigureGoogleAuthAuthnProvider({><Checkboxid="google-fetch-groups"+ testId="google-auth-fetch-groups"onChange={(checked: boolean): void => {form.setFieldValue(['googleAuthConfig', 'fetchGroups'], checked);}}@@ -251,6 +260,7 @@ function ConfigureGoogleAuthAuthnProvider({><AntdInput.TextAreaid="google-service-account-json"+ data-testid="google-auth-service-account-json"rows={3}placeholder="Paste service account JSON"className="authn-provider__textarea"@@ -270,6 +280,7 @@ function ConfigureGoogleAuthAuthnProvider({><Checkboxid="google-transitive-membership"+ testId="google-auth-transitive-membership"onChange={(checked: boolean): void => {form.setFieldValue(['googleAuthConfig', 'fetchTransitiveGroupMembership'],@@ -299,7 +310,10 @@ function ConfigureGoogleAuthAuthnProvider({name={['googleAuthConfig', 'allowedGroups']}className="authn-provider__form-item">- <EmailTagInput placeholder="Type a group email and press Enter" />+ <EmailTagInput+ placeholder="Type a group email and press Enter"+ testId="google-auth-allowed-groups"+ /></Form.Item></div></div>diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/AuthnSAML.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/AuthnSAML.tsxindex 5f01a3227f..1f95518b32 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/AuthnSAML.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/AuthnSAML.tsx@@ -76,7 +76,7 @@ function ConfigureSAMLAuthnProvider({</Tooltip></label><Form.Item- name={['samlConfig', 'samlIdp']}+ name={['samlConfig', 'location']}className="authn-provider__form-item"rules={[{@@ -98,7 +98,7 @@ function ConfigureSAMLAuthnProvider({</Tooltip></label><Form.Item- name={['samlConfig', 'samlEntity']}+ name={['samlConfig', 'entityId']}className="authn-provider__form-item"rules={[{@@ -120,7 +120,7 @@ function ConfigureSAMLAuthnProvider({</Tooltip></label><Form.Item- name={['samlConfig', 'samlCert']}+ name={['samlConfig', 'certificate']}className="authn-provider__form-item"rules={[{diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/components/EmailTagInput.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/components/EmailTagInput.tsxindex 745d1218c3..e9c4ec0b43 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/components/EmailTagInput.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/components/EmailTagInput.tsx@@ -9,12 +9,14 @@ interface EmailTagInputProps {value?: string[];onChange?: (value: string[]) => void;placeholder?: string;+ testId?: string;}function EmailTagInput({value = [],onChange,placeholder = 'Type an email and press Enter',+ testId,}: EmailTagInputProps): JSX.Element {const [validationError, setValidationError] = useState('');@@ -34,7 +36,7 @@ function EmailTagInput({);return (- <div className="email-tag-input">+ <div className="email-tag-input" data-testid={testId}><Tooltiptitle={validationError}open={!!validationError}diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/components/RoleMappingSection.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/components/RoleMappingSection.tsxindex 4c4f3629e3..d50c45d3ac 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/components/RoleMappingSection.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/CreateEdit/Providers/components/RoleMappingSection.tsx@@ -74,6 +74,7 @@ function RoleMappingSection({role="button"aria-expanded={expanded}aria-controls="role-mapping-content"+ data-testid="role-mapping-header">{!expanded ? <ChevronRight size={16} /> : <ChevronDown size={16} />}<div className="role-mapping-section__collapse-header-text">@@ -138,6 +139,7 @@ function RoleMappingSection({><Checkboxid="use-role-attribute"+ testId="role-mapping-use-role-attribute"onChange={(checked: boolean): void => {form.setFieldValue([...fieldNamePrefix, 'useRoleAttribute'], checked);}}@@ -166,13 +168,20 @@ function RoleMappingSection({{(fields, { add, remove }): JSX.Element => (<div className="role-mapping-section__items">{fields.map((field) => (- <div key={field.key} className="role-mapping-section__row">+ <div+ key={field.key}+ className="role-mapping-section__row"+ data-testid="role-mapping-row"+ ><Form.Itemname={[field.name, 'groupName']}className="role-mapping-section__field role-mapping-section__field--group"rules={[{ required: true, message: 'Group name is required' }]}>- <Input placeholder="IDP Group Name" />+ <Input+ placeholder="IDP Group Name"+ testId="role-mapping-group-name"+ /></Form.Item><Form.Item@@ -199,6 +208,7 @@ function RoleMappingSection({className="role-mapping-section__remove-btn"onClick={(): void => remove(field.name)}aria-label="Remove mapping"+ testId="role-mapping-remove"><Trash2 size={12} /></Button>@@ -212,6 +222,7 @@ function RoleMappingSection({add({ groupName: '', role: SIGNOZ_VIEWER_ROLE })}prefix={<Plus size={14} />}+ testId="role-mapping-add">Add Group Mapping</Button>diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/SSOEnforcementToggle.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/SSOEnforcementToggle.tsxindex 6a534f4c73..c8bc6e1542 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/SSOEnforcementToggle.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/SSOEnforcementToggle.tsx@@ -31,7 +31,7 @@ function SSOEnforcementToggle({useUpdateAuthDomain<AxiosError<RenderErrorResponseDTO>>();const onChangeHandler = (checked: boolean): void => {- if (!record.id) {+ if (!record.id || !record.config) {return;}@@ -41,14 +41,9 @@ function SSOEnforcementToggle({{pathParams: { id: record.id },data: {- config: {- ssoEnabled: checked,- ssoType: record.config?.ssoType,- googleAuthConfig: record.config?.googleAuthConfig,- oidcConfig: record.config?.oidcConfig,- samlConfig: record.config?.samlConfig,- roleMapping: record.config?.roleMapping,- },+ enabled: checked,+ config: record.config,+ roleMapping: record.roleMapping,},},{@@ -65,7 +60,12 @@ function SSOEnforcementToggle({};return (- <Switch disabled={isLoading} value={isChecked} onChange={onChangeHandler} />+ <Switch+ disabled={isLoading}+ value={isChecked}+ onChange={onChangeHandler}+ testId="auth-domain-enforce-sso"+ />);}diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/AuthDomain.test.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/AuthDomain.test.tsxindex 9f9132d3b1..a45dd6dbbc 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/AuthDomain.test.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/AuthDomain.test.tsx@@ -58,7 +58,7 @@ describe('AuthDomain', () => {});});- it('reflects ssoEnabled state from nested config in each row toggle', async () => {+ it('reflects the enabled state in each row toggle', async () => {server.use(rest.get(AUTH_DOMAINS_LIST_ENDPOINT, (_, res, ctx) =>res(ctx.status(200), ctx.json(mockDomainsListResponse)),@@ -68,9 +68,9 @@ describe('AuthDomain', () => {render(<AuthDomain />);// mockDomainsListResponse rows:- // [0] signoz.io → config.ssoEnabled: true- // [1] example.com → config.ssoEnabled: false- // [2] corp.io → config.ssoEnabled: true+ // [0] signoz.io → enabled: true+ // [1] example.com → enabled: false+ // [2] corp.io → enabled: trueconst switches = await screen.findAllByRole('switch');expect(switches).toHaveLength(3);expect(switches[0]).toBeChecked();diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.payload.test.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.payload.test.tsxindex fb9a6fae00..fdbf652536 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.payload.test.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.payload.test.tsx@@ -112,9 +112,7 @@ describe('CreateEdit — save payload correctness', () => {await waitFor(() => expect(capturedPayload).not.toBeNull());expect(capturedPayload).toMatchObject({- config: expect.objectContaining({- roleMapping: expect.objectContaining({ groupMappings: {} }),- }),+ roleMapping: expect.objectContaining({ groupMappings: {} }),});});@@ -161,7 +159,7 @@ describe('CreateEdit — save payload correctness', () => {expect(capturedPayload).toMatchObject({config: expect.objectContaining({- googleAuthConfig: expect.objectContaining({+ spec: expect.objectContaining({domainToAdminEmail: {},}),}),diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.roleMapping.test.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.roleMapping.test.tsxindex ce0e65d4f9..a0cabf6193 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.roleMapping.test.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.roleMapping.test.tsx@@ -188,8 +188,8 @@ describe('CreateEdit — role mapping uses API roles', () => {// SSO role mapping matches roles by name, so the payload carries the// role *name*, not the opaque id.- expect(payload.get().config.roleMapping.defaultRole).toBe(editorRole.name);- expect(payload.get().config.roleMapping.defaultRole).not.toBe(editorRole.id);+ expect(payload.get().roleMapping.defaultRole).toBe(editorRole.name);+ expect(payload.get().roleMapping.defaultRole).not.toBe(editorRole.id);});it('defaults a fresh role mapping to the signoz-viewer role name', async () => {@@ -221,8 +221,8 @@ describe('CreateEdit — role mapping uses API roles', () => {await waitFor(() => expect(payload.get()).not.toBeNull());- expect(payload.get().config.roleMapping.defaultRole).toBe(viewerRole.name);- expect(payload.get().config.roleMapping.defaultRole).not.toBe(viewerRole.id);+ expect(payload.get().roleMapping.defaultRole).toBe(viewerRole.name);+ expect(payload.get().roleMapping.defaultRole).not.toBe(viewerRole.id);});it('still defaults to signoz-viewer when the roles fetch returns empty', async () => {@@ -249,7 +249,7 @@ describe('CreateEdit — role mapping uses API roles', () => {await waitFor(() => expect(payload.get()).not.toBeNull());// The Form.Item initialValue (signoz-viewer) survives an empty roles list.- expect(payload.get().config.roleMapping.defaultRole).toBe(viewerRole.name);+ expect(payload.get().roleMapping.defaultRole).toBe(viewerRole.name);});it('loads a stored role mapping by role name and round-trips it on save', async () => {@@ -280,8 +280,8 @@ describe('CreateEdit — role mapping uses API roles', () => {await waitFor(() => expect(payload.get()).not.toBeNull());- expect(payload.get().config.roleMapping.defaultRole).toBe(editorRole.name);- expect(payload.get().config.roleMapping.groupMappings).toStrictEqual({+ expect(payload.get().roleMapping.defaultRole).toBe(editorRole.name);+ expect(payload.get().roleMapping.groupMappings).toStrictEqual({'admin-group': 'signoz-admin','dev-team': 'signoz-editor',viewers: 'signoz-viewer',diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.sanitization.test.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.sanitization.test.tsxindex 4eb22699f3..0678ba5b13 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.sanitization.test.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/CreateEdit.sanitization.test.tsx@@ -1,6 +1,9 @@import { fireEvent, render, screen, waitFor } from 'tests/test-utils';import { rest, server } from 'mocks-server/server';-import { AuthtypesGettableAuthDomainDTO } from 'api/generated/services/sigNoz.schemas';+import {+ AuthtypesAuthDomainConfigGoogleDTO,+ AuthtypesGettableAuthDomainDTO,+} from 'api/generated/services/sigNoz.schemas';import CreateEdit from '../CreateEdit/CreateEdit';import {@@ -48,11 +51,10 @@ jest.mock('@signozhq/ui/button', () => ({type SavedPayload = {config: {- googleAuthConfig?: Record<string, unknown>;- samlConfig?: Record<string, unknown>;- oidcConfig?: Record<string, unknown>;- roleMapping?: Record<string, unknown>;+ kind?: string;+ spec?: Record<string, unknown>;};+ roleMapping?: Record<string, unknown>;};async function submitForm(@@ -81,7 +83,7 @@ describe('CreateEdit — payload sanitization', () => {it('sends core fields and omits workspace fields when fetchGroups is not set', async () => {const payload = await submitForm(mockGoogleAuthDomain);- const g = payload.config.googleAuthConfig;+ const g = payload.config.spec;expect(g?.clientId).toBe('test-client-id');expect(g?.clientSecret).toBe('test-client-secret');expect(g?.allowedGroups).toBeUndefined();@@ -91,18 +93,20 @@ describe('CreateEdit — payload sanitization', () => {});it('strips workspace fields when fetchGroups is false', async () => {+ const googleConfig =+ mockGoogleAuthWithWorkspaceGroups.config as AuthtypesAuthDomainConfigGoogleDTO;const payload = await submitForm({...mockGoogleAuthWithWorkspaceGroups,config: {- ...mockGoogleAuthWithWorkspaceGroups.config,- googleAuthConfig: {- ...mockGoogleAuthWithWorkspaceGroups.config?.googleAuthConfig,+ ...googleConfig,+ spec: {+ ...googleConfig.spec,fetchGroups: false,},},});- const g = payload.config.googleAuthConfig;+ const g = payload.config.spec;expect(g?.fetchGroups).toBe(false);expect(g?.allowedGroups).toBeUndefined();expect(g?.serviceAccountJson).toBeUndefined();@@ -113,7 +117,7 @@ describe('CreateEdit — payload sanitization', () => {it('includes all workspace fields when fetchGroups is true', async () => {const payload = await submitForm(mockGoogleAuthWithWorkspaceGroups);- const g = payload.config.googleAuthConfig;+ const g = payload.config.spec;expect(g?.fetchGroups).toBe(true);expect(g?.serviceAccountJson).toBe('{"type": "service_account"}');expect(g?.fetchTransitiveGroupMembership).toBe(true);@@ -131,10 +135,10 @@ describe('CreateEdit — payload sanitization', () => {it('sends core and attributeMapping fields', async () => {const payload = await submitForm(mockSamlWithAttributeMapping);- const s = payload.config.samlConfig;- expect(s?.samlIdp).toBe('https://idp.saml-attrs.com/sso');- expect(s?.samlEntity).toBe('urn:saml-attrs:idp');- expect(s?.samlCert).toBe('MOCK_CERTIFICATE_ATTRS');+ const s = payload.config.spec;+ expect(s?.location).toBe('https://idp.saml-attrs.com/sso');+ expect(s?.entityId).toBe('urn:saml-attrs:idp');+ expect(s?.certificate).toBe('MOCK_CERTIFICATE_ATTRS');expect(s?.insecureSkipAuthNRequestsSigned).toBe(true);const attr = s?.attributeMapping as Record<string, unknown>;@@ -148,7 +152,7 @@ describe('CreateEdit — payload sanitization', () => {it('sends all fields including claimMapping', async () => {const payload = await submitForm(mockOidcWithClaimMapping);- const o = payload.config.oidcConfig;+ const o = payload.config.spec;expect(o?.issuer).toBe('https://oidc.claims.com');expect(o?.issuerAlias).toBe('https://alias.claims.com');expect(o?.clientId).toBe('claims-client-id');@@ -168,24 +172,21 @@ describe('CreateEdit — payload sanitization', () => {it('strips groupMappings when useRoleAttribute is true', async () => {const payload = await submitForm({...mockDomainWithRoleMapping,- config: {- ...mockDomainWithRoleMapping.config,- roleMapping: {- ...mockDomainWithRoleMapping.config?.roleMapping,- useRoleAttribute: true,- },+ roleMapping: {+ ...mockDomainWithRoleMapping.roleMapping,+ useRoleAttribute: true,},});- expect(payload.config.roleMapping?.useRoleAttribute).toBe(true);- expect(payload.config.roleMapping?.groupMappings).toBeUndefined();+ expect(payload.roleMapping?.useRoleAttribute).toBe(true);+ expect(payload.roleMapping?.groupMappings).toBeUndefined();});it('sends groupMappings when useRoleAttribute is false', async () => {const payload = await submitForm(mockDomainWithRoleMapping);- expect(payload.config.roleMapping?.useRoleAttribute).toBe(false);- expect(payload.config.roleMapping?.groupMappings).toStrictEqual({+ expect(payload.roleMapping?.useRoleAttribute).toBe(false);+ expect(payload.roleMapping?.groupMappings).toStrictEqual({'admin-group': 'signoz-admin','dev-team': 'signoz-editor',viewers: 'signoz-viewer',diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/SSOEnforcementToggle.test.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/SSOEnforcementToggle.test.tsxindex cfd73c4ed9..8d6064402e 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/SSOEnforcementToggle.test.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/SSOEnforcementToggle.test.tsx@@ -25,6 +25,7 @@ jest.mock('@signozhq/ui/switch', () => ({import SSOEnforcementToggle from '../SSOEnforcementToggle';import {AUTH_DOMAINS_UPDATE_ENDPOINT,+ mockDomainWithRoleMapping,mockErrorResponse,mockGoogleAuthDomain,mockUpdateSuccessResponse,@@ -57,7 +58,7 @@ describe('SSOEnforcementToggle', () => {isDefaultChecked={false}record={{...mockGoogleAuthDomain,- config: { ...mockGoogleAuthDomain.config, ssoEnabled: false },+ enabled: false,}}/>,);@@ -95,13 +96,42 @@ describe('SSOEnforcementToggle', () => {expect(mockUpdateAPI).toHaveBeenCalledTimes(1);expect(mockUpdateAPI).toHaveBeenCalledWith(expect.objectContaining({- config: expect.objectContaining({- ssoEnabled: false,- }),+ enabled: false,+ config: mockGoogleAuthDomain.config,}),);});+ // The toggle sends a full replacement, so anything it fails to echo back is+ // dropped from the domain — role mappings included.+ it('echoes the existing role mapping when toggling enforcement', async () => {+ const user = userEvent.setup({ pointerEventsCheck: 0 });+ const mockUpdateAPI = jest.fn();++ server.use(+ rest.put(AUTH_DOMAINS_UPDATE_ENDPOINT, async (req, res, ctx) => {+ mockUpdateAPI(await req.json());+ return res(ctx.status(200), ctx.json(mockUpdateSuccessResponse));+ }),+ );++ render(+ <SSOEnforcementToggle+ isDefaultChecked={true}+ record={mockDomainWithRoleMapping}+ />,+ );++ await user.click(screen.getByRole('switch'));++ await waitFor(() => expect(mockUpdateAPI).toHaveBeenCalledTimes(1));+ expect(mockUpdateAPI).toHaveBeenCalledWith({+ enabled: false,+ config: mockDomainWithRoleMapping.config,+ roleMapping: mockDomainWithRoleMapping.roleMapping,+ });+ });+it('shows error modal when update fails', async () => {const user = userEvent.setup({ pointerEventsCheck: 0 });diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/mocks.ts b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/mocks.tsindex 3a247a3fda..43f9f7d4e7 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/mocks.ts+++ b/frontend/src/container/OrganizationSettings/AuthDomain/__tests__/mocks.ts@@ -1,22 +1,24 @@import {- AuthtypesAuthNProviderDTO,+ AuthtypesAuthDomainConfigGoogleDTOKind,+ AuthtypesAuthDomainConfigOIDCDTOKind,+ AuthtypesAuthDomainConfigSAMLDTOKind,AuthtypesGettableAuthDomainDTO,} from 'api/generated/services/sigNoz.schemas';// API Endpoints-export const AUTH_DOMAINS_LIST_ENDPOINT = '*/api/v1/domains';-export const AUTH_DOMAINS_CREATE_ENDPOINT = '*/api/v1/domains';-export const AUTH_DOMAINS_UPDATE_ENDPOINT = '*/api/v1/domains/:id';-export const AUTH_DOMAINS_DELETE_ENDPOINT = '*/api/v1/domains/:id';+export const AUTH_DOMAINS_LIST_ENDPOINT = '*/api/v2/auth_domains';+export const AUTH_DOMAINS_CREATE_ENDPOINT = '*/api/v2/auth_domains';+export const AUTH_DOMAINS_UPDATE_ENDPOINT = '*/api/v2/auth_domains/:id';+export const AUTH_DOMAINS_DELETE_ENDPOINT = '*/api/v2/auth_domains/:id';// Mock Auth Domain with Google Authexport const mockGoogleAuthDomain: AuthtypesGettableAuthDomainDTO = {id: 'domain-1',name: 'signoz.io',+ enabled: true,config: {- ssoEnabled: true,- ssoType: AuthtypesAuthNProviderDTO.google_auth,- googleAuthConfig: {+ kind: AuthtypesAuthDomainConfigGoogleDTOKind.google,+ spec: {clientId: 'test-client-id',clientSecret: 'test-client-secret',},@@ -30,13 +32,13 @@ export const mockGoogleAuthDomain: AuthtypesGettableAuthDomainDTO = {export const mockSamlAuthDomain: AuthtypesGettableAuthDomainDTO = {id: 'domain-2',name: 'example.com',+ enabled: false,config: {- ssoEnabled: false,- ssoType: AuthtypesAuthNProviderDTO.saml,- samlConfig: {- samlIdp: 'https://idp.example.com/sso',- samlEntity: 'urn:example:idp',- samlCert: 'MOCK_CERTIFICATE',+ kind: AuthtypesAuthDomainConfigSAMLDTOKind.saml,+ spec: {+ location: 'https://idp.example.com/sso',+ entityId: 'urn:example:idp',+ certificate: 'MOCK_CERTIFICATE',},},authNProviderInfo: {@@ -48,10 +50,10 @@ export const mockSamlAuthDomain: AuthtypesGettableAuthDomainDTO = {export const mockOidcAuthDomain: AuthtypesGettableAuthDomainDTO = {id: 'domain-3',name: 'corp.io',+ enabled: true,config: {- ssoEnabled: true,- ssoType: AuthtypesAuthNProviderDTO.oidc,- oidcConfig: {+ kind: AuthtypesAuthDomainConfigOIDCDTOKind.oidc,+ spec: {issuer: 'https://oidc.corp.io',clientId: 'oidc-client-id',clientSecret: 'oidc-client-secret',@@ -66,22 +68,22 @@ export const mockOidcAuthDomain: AuthtypesGettableAuthDomainDTO = {export const mockDomainWithRoleMapping: AuthtypesGettableAuthDomainDTO = {id: 'domain-4',name: 'enterprise.com',+ enabled: true,config: {- ssoEnabled: true,- ssoType: AuthtypesAuthNProviderDTO.saml,- samlConfig: {- samlIdp: 'https://idp.enterprise.com/sso',- samlEntity: 'urn:enterprise:idp',- samlCert: 'MOCK_CERTIFICATE',+ kind: AuthtypesAuthDomainConfigSAMLDTOKind.saml,+ spec: {+ location: 'https://idp.enterprise.com/sso',+ entityId: 'urn:enterprise:idp',+ certificate: 'MOCK_CERTIFICATE',},- roleMapping: {- defaultRole: 'signoz-editor',- useRoleAttribute: false,- groupMappings: {- 'admin-group': 'signoz-admin',- 'dev-team': 'signoz-editor',- viewers: 'signoz-viewer',- },+ },+ roleMapping: {+ defaultRole: 'signoz-editor',+ useRoleAttribute: false,+ groupMappings: {+ 'admin-group': 'signoz-admin',+ 'dev-team': 'signoz-editor',+ viewers: 'signoz-viewer',},},authNProviderInfo: {@@ -94,18 +96,18 @@ export const mockDomainWithDirectRoleAttribute: AuthtypesGettableAuthDomainDTO ={id: 'domain-5',name: 'direct-role.com',+ enabled: true,config: {- ssoEnabled: true,- ssoType: AuthtypesAuthNProviderDTO.oidc,- oidcConfig: {+ kind: AuthtypesAuthDomainConfigOIDCDTOKind.oidc,+ spec: {issuer: 'https://oidc.direct-role.com',clientId: 'direct-role-client-id',clientSecret: 'direct-role-client-secret',},- roleMapping: {- defaultRole: 'signoz-viewer',- useRoleAttribute: true,- },+ },+ roleMapping: {+ defaultRole: 'signoz-viewer',+ useRoleAttribute: true,},authNProviderInfo: {relayStatePath: 'api/v1/sso/relay/domain-5',@@ -116,10 +118,10 @@ export const mockDomainWithDirectRoleAttribute: AuthtypesGettableAuthDomainDTO =export const mockOidcWithClaimMapping: AuthtypesGettableAuthDomainDTO = {id: 'domain-6',name: 'oidc-claims.com',+ enabled: true,config: {- ssoEnabled: true,- ssoType: AuthtypesAuthNProviderDTO.oidc,- oidcConfig: {+ kind: AuthtypesAuthDomainConfigOIDCDTOKind.oidc,+ spec: {issuer: 'https://oidc.claims.com',issuerAlias: 'https://alias.claims.com',clientId: 'claims-client-id',@@ -143,13 +145,13 @@ export const mockOidcWithClaimMapping: AuthtypesGettableAuthDomainDTO = {export const mockSamlWithAttributeMapping: AuthtypesGettableAuthDomainDTO = {id: 'domain-7',name: 'saml-attrs.com',+ enabled: true,config: {- ssoEnabled: true,- ssoType: AuthtypesAuthNProviderDTO.saml,- samlConfig: {- samlIdp: 'https://idp.saml-attrs.com/sso',- samlEntity: 'urn:saml-attrs:idp',- samlCert: 'MOCK_CERTIFICATE_ATTRS',+ kind: AuthtypesAuthDomainConfigSAMLDTOKind.saml,+ spec: {+ location: 'https://idp.saml-attrs.com/sso',+ entityId: 'urn:saml-attrs:idp',+ certificate: 'MOCK_CERTIFICATE_ATTRS',insecureSkipAuthNRequestsSigned: true,attributeMapping: {name: 'user_display_name',@@ -168,10 +170,10 @@ export const mockGoogleAuthWithWorkspaceGroups: AuthtypesGettableAuthDomainDTO ={id: 'domain-8',name: 'google-groups.com',+ enabled: true,config: {- ssoEnabled: true,- ssoType: AuthtypesAuthNProviderDTO.google_auth,- googleAuthConfig: {+ kind: AuthtypesAuthDomainConfigGoogleDTOKind.google,+ spec: {clientId: 'google-groups-client-id',clientSecret: 'google-groups-client-secret',insecureSkipEmailVerified: false,@@ -218,7 +220,7 @@ export const mockUpdateSuccessResponse = {status: 'success',data: {...mockGoogleAuthDomain,- config: { ...mockGoogleAuthDomain.config, ssoEnabled: false },+ enabled: false,},};diff --git a/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx b/frontend/src/container/OrganizationSettings/AuthDomain/index.tsxindex 8f83a164dc..f9f601e5b4 100644--- a/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx+++ b/frontend/src/container/OrganizationSettings/AuthDomain/index.tsx@@ -1,4 +1,4 @@-import { useCallback, useMemo, useState } from 'react';+import { HTMLAttributes, useCallback, useMemo, useState } from 'react';import { Plus, Trash2, X } from '@signozhq/icons';import { Button } from '@signozhq/ui/button';import { toast } from '@signozhq/ui/sonner';@@ -26,7 +26,7 @@ import './AuthDomain.styles.scss';import '../../IngestionSettings/IngestionSettings.styles.scss';export const SSOType = new Map<string, string>([- ['google_auth', 'Google Auth'],+ ['google', 'Google Auth'],['saml', 'SAML'],['email_password', 'Email Password'],['oidc', 'OIDC'],@@ -121,8 +121,8 @@ function AuthDomain(): JSX.Element {},{title: 'Enforce SSO',- dataIndex: ['config', 'ssoEnabled'],- key: 'ssoEnabled',+ dataIndex: 'enabled',+ key: 'enabled',width: 80,render: (value: boolean,@@ -157,13 +157,15 @@ function AuthDomain(): JSX.Element {className="auth-domain-list-action-link"onClick={(): void => setRecord(record)}variant="link"+ testId="auth-domain-configure">- Configure {SSOType.get(record.config?.ssoType || '')}+ Configure {SSOType.get(record.config?.kind || '')}</Button><ButtonclassName="auth-domain-list-action-link delete"onClick={(): void => showDeleteModal(record)}variant="link"+ testId="auth-domain-delete">Delete</Button>@@ -177,7 +179,9 @@ function AuthDomain(): JSX.Element {return (<div className="auth-domain"><section className="auth-domain-header">- <h3 className="auth-domain-title">Authenticated Domains</h3>+ <h3 className="auth-domain-title" data-testid="auth-domain-title">+ Authenticated Domains+ </h3><Buttonprefix={<Plus size="md" />}onClick={(): void => {@@ -186,6 +190,7 @@ function AuthDomain(): JSX.Element {variant="solid"size="sm"color="primary"+ testId="auth-domain-add">Add Domain</Button>@@ -195,7 +200,14 @@ function AuthDomain(): JSX.Element {<Tablecolumns={columns}dataSource={authDomainListResponse?.data}- onRow={undefined}+ onRow={(+ record: AuthtypesGettableAuthDomainDTO,+ ): HTMLAttributes<HTMLElement> =>+ // data-* attributes are valid row props but absent from the antd typing+ ({+ 'data-testid': `auth-domain-row-${record.name}`,+ }) as unknown as HTMLAttributes<HTMLElement>+ }loading={isLoadingAuthDomainListResponse || isFetchingAuthDomainListResponse}@@ -228,6 +240,7 @@ function AuthDomain(): JSX.Element {onClick={hideDeleteModal}className="cancel-btn"prefix={<X size={16} />}+ testId="auth-domain-delete-cancel">Cancel</Button>,@@ -237,6 +250,7 @@ function AuthDomain(): JSX.Element {onClick={handleDeleteDomain}className="delete-btn"loading={isLoading}+ testId="auth-domain-delete-confirm">Delete Domain</Button>,diff --git a/pkg/apiserver/signozapiserver/authdomain.go b/pkg/apiserver/signozapiserver/authdomain.goindex 7fedf9f1f2..690bfb8b34 100644--- a/pkg/apiserver/signozapiserver/authdomain.go+++ b/pkg/apiserver/signozapiserver/authdomain.go@@ -10,7 +10,7 @@ import ()func (provider *provider) addAuthDomainRoutes(router *mux.Router) error {- if err := router.Handle("/api/v1/domains", handler.New(provider.authzMiddleware.AdminAccess(provider.authDomainHandler.List), handler.OpenAPIDef{+ if err := router.Handle("/api/v2/auth_domains", handler.New(provider.authzMiddleware.AdminAccess(provider.authDomainHandler.List), handler.OpenAPIDef{ID: "ListAuthDomains",Tags: []string{"authdomains"},Summary: "List all auth domains",@@ -27,7 +27,7 @@ func (provider *provider) addAuthDomainRoutes(router *mux.Router) error {return err}- if err := router.Handle("/api/v1/domains", handler.New(provider.authzMiddleware.AdminAccess(provider.authDomainHandler.Create), handler.OpenAPIDef{+ if err := router.Handle("/api/v2/auth_domains", handler.New(provider.authzMiddleware.AdminAccess(provider.authDomainHandler.Create), handler.OpenAPIDef{ID: "CreateAuthDomain",Tags: []string{"authdomains"},Summary: "Create auth domain",@@ -44,7 +44,7 @@ func (provider *provider) addAuthDomainRoutes(router *mux.Router) error {return err}- if err := router.Handle("/api/v1/domains/{id}", handler.New(provider.authzMiddleware.AdminAccess(provider.authDomainHandler.Get), handler.OpenAPIDef{+ if err := router.Handle("/api/v2/auth_domains/{id}", handler.New(provider.authzMiddleware.AdminAccess(provider.authDomainHandler.Get), handler.OpenAPIDef{ID: "GetAuthDomain",Tags: []string{"authdomains"},Summary: "Get auth domain by ID",@@ -61,7 +61,7 @@ func (provider *provider) addAuthDomainRoutes(router *mux.Router) error {return err}- if err := router.Handle("/api/v1/domains/{id}", handler.New(provider.authzMiddleware.AdminAccess(provider.authDomainHandler.Update), handler.OpenAPIDef{+ if err := router.Handle("/api/v2/auth_domains/{id}", handler.New(provider.authzMiddleware.AdminAccess(provider.authDomainHandler.Update), handler.OpenAPIDef{ID: "UpdateAuthDomain",Tags: []string{"authdomains"},Summary: "Update auth domain",@@ -78,7 +78,7 @@ func (provider *provider) addAuthDomainRoutes(router *mux.Router) error {return err}- if err := router.Handle("/api/v1/domains/{id}", handler.New(provider.authzMiddleware.AdminAccess(provider.authDomainHandler.Delete), handler.OpenAPIDef{+ if err := router.Handle("/api/v2/auth_domains/{id}", handler.New(provider.authzMiddleware.AdminAccess(provider.authDomainHandler.Delete), handler.OpenAPIDef{ID: "DeleteAuthDomain",Tags: []string{"authdomains"},Summary: "Delete auth domain",diff --git a/pkg/authn/callbackauthn/googlecallbackauthn/authn.go b/pkg/authn/callbackauthn/googlecallbackauthn/authn.goindex e76fcdbff2..d34cffddc8 100644--- a/pkg/authn/callbackauthn/googlecallbackauthn/authn.go+++ b/pkg/authn/callbackauthn/googlecallbackauthn/authn.go@@ -59,12 +59,11 @@ func (a *AuthN) LoginURL(ctx context.Context, siteURL *url.URL, authDomain *authreturn "", err}- if authDomain.AuthDomainConfig().AuthNProvider != authtypes.AuthNProviderGoogleAuth {- return "", errors.Newf(errors.TypeInternal, authtypes.ErrCodeAuthDomainMismatch, "domain type is not google")+ oauth2Config, err := a.oauth2Config(siteURL, authDomain, oidcProvider)+ if err != nil {+ return "", err}- oauth2Config := a.oauth2Config(siteURL, authDomain, oidcProvider)-return oauth2Config.AuthCodeURL(authtypes.NewState(siteURL, authDomain.StorableAuthDomain().ID).URL.String(),oauth2.SetAuthURLParam("hd", authDomain.StorableAuthDomain().Name),@@ -93,7 +92,16 @@ func (a *AuthN) HandleCallback(ctx context.Context, query url.Values) (*authtypereturn nil, err}- oauth2Config := a.oauth2Config(state.URL, authDomain, oidcProvider)+ googleConfig, err := authDomain.Config().GoogleConfig()+ if err != nil {+ return nil, err+ }++ oauth2Config, err := a.oauth2Config(state.URL, authDomain, oidcProvider)+ if err != nil {+ return nil, err+ }+token, err := oauth2Config.Exchange(ctx, query.Get("code"))if err != nil {var retrieveError *oauth2.RetrieveError@@ -111,7 +119,7 @@ func (a *AuthN) HandleCallback(ctx context.Context, query url.Values) (*authtypereturn nil, errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "google: no id_token in token response")}- verifier := oidcProvider.Verifier(&oidc.Config{ClientID: authDomain.AuthDomainConfig().Google.ClientID})+ verifier := oidcProvider.Verifier(&oidc.Config{ClientID: googleConfig.ClientID})idToken, err := verifier.Verify(ctx, rawIDToken)if err != nil {a.settings.Logger().ErrorContext(ctx, "google: failed to verify token", errors.Attr(err))@@ -135,7 +143,7 @@ func (a *AuthN) HandleCallback(ctx context.Context, query url.Values) (*authtypereturn nil, errors.Newf(errors.TypeForbidden, errors.CodeForbidden, "google: unexpected hd claim")}- if !authDomain.AuthDomainConfig().Google.InsecureSkipEmailVerified {+ if !googleConfig.InsecureSkipEmailVerified {if !claims.EmailVerified {a.settings.Logger().ErrorContext(ctx, "google: email is not verified", slog.String("email", claims.Email))return nil, errors.Newf(errors.TypeForbidden, errors.CodeForbidden, "google: email is not verified")@@ -148,14 +156,14 @@ func (a *AuthN) HandleCallback(ctx context.Context, query url.Values) (*authtype}var groups []string- if authDomain.AuthDomainConfig().Google.FetchGroups {- groups, err = a.fetchGoogleWorkspaceGroups(ctx, claims.Email, authDomain.AuthDomainConfig().Google)+ if googleConfig.FetchGroups {+ groups, err = a.fetchGoogleWorkspaceGroups(ctx, claims.Email, googleConfig)if err != nil {a.settings.Logger().ErrorContext(ctx, "google: could not fetch groups", errors.Attr(err))return nil, errors.Newf(errors.TypeInternal, errors.CodeInternal, "google: could not fetch groups").WithAdditional(err.Error())}- allowedGroups := authDomain.AuthDomainConfig().Google.AllowedGroups+ allowedGroups := googleConfig.AllowedGroupsif len(allowedGroups) > 0 {groups = filterGroups(groups, allowedGroups)if len(groups) == 0 {@@ -173,10 +181,15 @@ func (a *AuthN) ProviderInfo(ctx context.Context, authDomain *authtypes.AuthDoma}}-func (a *AuthN) oauth2Config(siteURL *url.URL, authDomain *authtypes.AuthDomain, provider *oidc.Provider) *oauth2.Config {+func (a *AuthN) oauth2Config(siteURL *url.URL, authDomain *authtypes.AuthDomain, provider *oidc.Provider) (*oauth2.Config, error) {+ googleConfig, err := authDomain.Config().GoogleConfig()+ if err != nil {+ return nil, err+ }+return &oauth2.Config{- ClientID: authDomain.AuthDomainConfig().Google.ClientID,- ClientSecret: authDomain.AuthDomainConfig().Google.ClientSecret,+ ClientID: googleConfig.ClientID,+ ClientSecret: googleConfig.ClientSecret,Endpoint: provider.Endpoint(),Scopes: scopes,RedirectURL: (&url.URL{@@ -184,10 +197,10 @@ func (a *AuthN) oauth2Config(siteURL *url.URL, authDomain *authtypes.AuthDomain,Host: siteURL.Host,Path: path.Join(a.globalConfig.ExternalPath(), redirectPath),}).String(),- }+ }, nil}-func (a *AuthN) fetchGoogleWorkspaceGroups(ctx context.Context, userEmail string, config *authtypes.GoogleConfig) ([]string, error) {+func (a *AuthN) fetchGoogleWorkspaceGroups(ctx context.Context, userEmail string, config authtypes.GoogleConfig) ([]string, error) {adminEmail := config.GetAdminEmailForDomain(userEmail)if adminEmail == "" {return nil, errors.Newf(errors.TypeInvalidInput, errors.CodeInvalidInput, "no admin email configured for domain of %s", userEmail)diff --git a/pkg/modules/authdomain/implauthdomain/getter.go b/pkg/modules/authdomain/implauthdomain/getter.goindex 851962e8c1..3ec4f059f1 100644--- a/pkg/modules/authdomain/implauthdomain/getter.go+++ b/pkg/modules/authdomain/implauthdomain/getter.go@@ -26,7 +26,7 @@ func (getter *getter) OnBeforeRoleDelete(ctx context.Context, orgID valuer.UUID,referencedBy := make([]string, 0)for _, domain := range domains {- for _, mappedRole := range domain.AuthDomainConfig().RoleMapping.RoleNames() {+ for _, mappedRole := range domain.RoleMapping().RoleNames() {if mappedRole == roleName {referencedBy = append(referencedBy, domain.StorableAuthDomain().Name)breakdiff --git a/pkg/modules/authdomain/implauthdomain/handler.go b/pkg/modules/authdomain/implauthdomain/handler.goindex 8fe8d0eee3..afcf34ca25 100644--- a/pkg/modules/authdomain/implauthdomain/handler.go+++ b/pkg/modules/authdomain/implauthdomain/handler.go@@ -38,7 +38,7 @@ func (handler *handler) Create(rw http.ResponseWriter, req *http.Request) {return}- authDomain, err := authtypes.NewAuthDomainFromConfig(body.Name, &body.Config, valuer.MustNewUUID(claims.OrgID))+ authDomain, err := authtypes.NewAuthDomainFromPostableAuthDomain(body, valuer.MustNewUUID(claims.OrgID))if err != nil {render.Error(rw, err)return@@ -154,7 +154,7 @@ func (handler *handler) Update(rw http.ResponseWriter, r *http.Request) {return}- err = authDomain.Update(&body.Config)+ err = authDomain.Update(body)if err != nil {render.Error(rw, err)returndiff --git a/pkg/modules/authdomain/implauthdomain/module.go b/pkg/modules/authdomain/implauthdomain/module.goindex b6ec444c15..714d578ced 100644--- a/pkg/modules/authdomain/implauthdomain/module.go+++ b/pkg/modules/authdomain/implauthdomain/module.go@@ -33,7 +33,7 @@ func (module *module) Get(ctx context.Context, id valuer.UUID) (*authtypes.AuthD}func (module *module) GetAuthNProviderInfo(ctx context.Context, domain *authtypes.AuthDomain) *authtypes.AuthNProviderInfo {- if callbackAuthN, ok := module.authNs[domain.AuthDomainConfig().AuthNProvider].(authn.CallbackAuthN); ok {+ if callbackAuthN, ok := module.authNs[domain.Kind()].(authn.CallbackAuthN); ok {return callbackAuthN.ProviderInfo(ctx, domain)}return &authtypes.AuthNProviderInfo{}@@ -72,7 +72,7 @@ func (module *module) Collect(ctx context.Context, orgID valuer.UUID) (map[strinstats := make(map[string]any)for _, domain := range domains {- key := "authdomain." + domain.AuthDomainConfig().AuthNProvider.StringValue() + ".count"+ key := "authdomain." + domain.Kind().StringValue() + ".count"if value, ok := stats[key]; ok {stats[key] = value.(int64) + 1} else {@@ -86,7 +86,7 @@ func (module *module) Collect(ctx context.Context, orgID valuer.UUID) (map[strin}func (module *module) validateRoleMapping(ctx context.Context, domain *authtypes.AuthDomain) error {- roleNames := domain.AuthDomainConfig().RoleMapping.RoleNames()+ roleNames := domain.RoleMapping().RoleNames()if len(roleNames) == 0 {return nil}diff --git a/pkg/modules/session/implsession/handler.go b/pkg/modules/session/implsession/handler.goindex 1e771061b5..2a4bcbef9c 100644--- a/pkg/modules/session/implsession/handler.go+++ b/pkg/modules/session/implsession/handler.go@@ -75,7 +75,7 @@ func (handler *handler) CreateSessionByGoogleCallback(rw http.ResponseWriter, revalues := req.URL.Query()- redirectURL, err := handler.module.CreateCallbackAuthNSession(ctx, authtypes.AuthNProviderGoogleAuth, values)+ redirectURL, err := handler.module.CreateCallbackAuthNSession(ctx, authtypes.AuthNProviderGoogle, values)if err != nil {http.Redirect(rw, req, handler.getRedirectURLFromErr(err), http.StatusSeeOther)returndiff --git a/pkg/modules/session/implsession/module.go b/pkg/modules/session/implsession/module.goindex 9ee8f04f89..68285b2957 100644--- a/pkg/modules/session/implsession/module.go+++ b/pkg/modules/session/implsession/module.go@@ -152,7 +152,7 @@ func (module *module) CreateCallbackAuthNSession(ctx context.Context, authNProvireturn "", err}- roleMapping := authDomain.AuthDomainConfig().RoleMapping+ roleMapping := authDomain.RoleMapping()roleAttributeExists := falseif roleMapping != nil && roleMapping.UseRoleAttribute && callbackIdentity.Role != "" {@@ -215,11 +215,11 @@ func (module *module) getOrgSessionContext(ctx context.Context, org *types.Organreturn authtypes.NewOrgSessionContext(org.ID, org.Name).AddPasswordAuthNSupport(authtypes.AuthNProviderEmailPassword), nil}- if !authDomain.AuthDomainConfig().SSOEnabled {+ if !authDomain.Enabled() {return authtypes.NewOrgSessionContext(org.ID, org.Name).AddPasswordAuthNSupport(authtypes.AuthNProviderEmailPassword), nil}- provider, err := getProvider[authn.CallbackAuthN](authDomain.AuthDomainConfig().AuthNProvider, module.authNs)+ provider, err := getProvider[authn.CallbackAuthN](authDomain.Kind(), module.authNs)if err != nil {return nil, err}@@ -233,7 +233,7 @@ func (module *module) getOrgSessionContext(ctx context.Context, org *types.Organreturn nil, err}- return authtypes.NewOrgSessionContext(org.ID, org.Name).AddCallbackAuthNSupport(authDomain.AuthDomainConfig().AuthNProvider, loginURL), nil+ return authtypes.NewOrgSessionContext(org.ID, org.Name).AddCallbackAuthNSupport(authDomain.Kind(), loginURL), nil}func getProvider[T authn.AuthN](authNProvider authtypes.AuthNProvider, authNs map[authtypes.AuthNProvider]authn.AuthN) (T, error) {diff --git a/pkg/signoz/authn.go b/pkg/signoz/authn.goindex 9e89b58e4a..4a8e29fc2b 100644--- a/pkg/signoz/authn.go+++ b/pkg/signoz/authn.go@@ -22,6 +22,6 @@ func NewAuthNs(ctx context.Context, providerSettings factory.ProviderSettings, sreturn map[authtypes.AuthNProvider]authn.AuthN{authtypes.AuthNProviderEmailPassword: emailPasswordAuthN,- authtypes.AuthNProviderGoogleAuth: googleCallbackAuthN,+ authtypes.AuthNProviderGoogle: googleCallbackAuthN,}, nil}diff --git a/pkg/signoz/provider.go b/pkg/signoz/provider.goindex adc90e14f4..5eab0c45d6 100644--- a/pkg/signoz/provider.go+++ b/pkg/signoz/provider.go@@ -239,6 +239,7 @@ func NewSQLMigrationProviderFactories(sqlmigration.NewAddSavedViewTuplesFactory(sqlstore),sqlmigration.NewFixSavedViewSelectedFieldsFactory(sqlstore),sqlmigration.NewBackfillSavedViewRequestTypeFactory(sqlstore),+ sqlmigration.NewRestructureAuthDomainConfigFactory(sqlstore),)}diff --git a/pkg/sqlmigration/113_restructure_auth_domain_config.go b/pkg/sqlmigration/113_restructure_auth_domain_config.gonew file mode 100644index 0000000000..b39e610f5c--- /dev/null+++ b/pkg/sqlmigration/113_restructure_auth_domain_config.go@@ -0,0 +1,215 @@+package sqlmigration++import (+ "context"+ "encoding/json"+ "log/slog"+ "strings"++ "github.com/SigNoz/signoz/pkg/errors"+ "github.com/SigNoz/signoz/pkg/factory"+ "github.com/SigNoz/signoz/pkg/sqlstore"+ "github.com/uptrace/bun"+ "github.com/uptrace/bun/migrate"+)++type restructureAuthDomainConfig struct {+ sqlstore sqlstore.SQLStore+ logger *slog.Logger+}++type restructureAuthDomainRow struct {+ bun.BaseModel `bun:"table:auth_domain"`++ ID string `bun:"id"`+ Data string `bun:"data"`+}++// The legacy document keyed the discriminator as ssoType with the chosen+// provider's config in a sibling field; the restructured document is+// {enabled, config: {kind, spec}, roleMapping} with renamed saml spec keys.+var legacySSOTypeToKind = map[string]string{+ "google_auth": "google",+ "saml": "saml",+ "oidc": "oidc",+}++var legacySSOTypeToConfigKey = map[string]string{+ "google_auth": "googleAuthConfig",+ "saml": "samlConfig",+ "oidc": "oidcConfig",+}++var legacySamlKeyToKey = map[string]string{+ "samlEntity": "entityId",+ "samlIdp": "location",+ "samlCert": "certificate",+}++func NewRestructureAuthDomainConfigFactory(sqlstore sqlstore.SQLStore) factory.ProviderFactory[SQLMigration, Config] {+ return factory.NewProviderFactory(+ factory.MustNewName("restructure_auth_domain_config"),+ func(ctx context.Context, ps factory.ProviderSettings, c Config) (SQLMigration, error) {+ return &restructureAuthDomainConfig{sqlstore: sqlstore, logger: ps.Logger}, nil+ },+ )+}++func (migration *restructureAuthDomainConfig) Register(migrations *migrate.Migrations) error {+ return migrations.Register(migration.Up, migration.Down)+}++// remove deletes a legacy row the migration cannot convert. Such rows never+// carry the {kind, spec} envelope, so the reader would reject them; dropping+// them here keeps the read path from failing on a document it cannot decode.+func (migration *restructureAuthDomainConfig) remove(ctx context.Context, tx bun.Tx, id string) error {+ _, err := tx.NewDelete().Model((*restructureAuthDomainRow)(nil)).Where("id = ?", id).Exec(ctx)+ return err+}++func (migration *restructureAuthDomainConfig) Up(ctx context.Context, db *bun.DB) error {+ tx, err := db.BeginTx(ctx, nil)+ if err != nil {+ return err+ }++ defer func() {+ _ = tx.Rollback()+ }()++ rows := make([]*restructureAuthDomainRow, 0)+ if err := tx.NewSelect().Model(&rows).Scan(ctx); err != nil {+ return err+ }++ for _, row := range rows {+ legacy := make(map[string]json.RawMessage)+ if err := json.Unmarshal([]byte(row.Data), &legacy); err != nil {+ migration.logger.WarnContext(ctx, "removing auth domain with unreadable data", slog.String("auth_domain_id", row.ID), errors.Attr(err))+ if err := migration.remove(ctx, tx, row.ID); err != nil {+ return err+ }+ continue+ }++ ssoTypeRaw, ok := legacy["ssoType"]+ if !ok {+ continue+ }++ var ssoType string+ if err := json.Unmarshal(ssoTypeRaw, &ssoType); err != nil {+ migration.logger.WarnContext(ctx, "removing auth domain with unreadable ssoType", slog.String("auth_domain_id", row.ID), errors.Attr(err))+ if err := migration.remove(ctx, tx, row.ID); err != nil {+ return err+ }+ continue+ }++ // Documents written before the provider enum became a valuer.String spell+ // the discriminator uppercase ("SAML", "GOOGLE_AUTH"); reads lowercase it+ // through valuer.NewString, so those rows still carry the original casing+ // on disk. Every lookup and spec rewrite below keys off this value.+ ssoType = strings.ToLower(strings.TrimSpace(ssoType))++ kind, ok := legacySSOTypeToKind[ssoType]+ if !ok {+ migration.logger.WarnContext(ctx, "removing auth domain with unknown ssoType", slog.String("auth_domain_id", row.ID), slog.String("sso_type", ssoType))+ if err := migration.remove(ctx, tx, row.ID); err != nil {+ return err+ }+ continue+ }++ spec, ok := legacy[legacySSOTypeToConfigKey[ssoType]]+ if !ok || string(spec) == "null" {+ migration.logger.WarnContext(ctx, "removing auth domain with missing provider config", slog.String("auth_domain_id", row.ID), slog.String("sso_type", ssoType))+ if err := migration.remove(ctx, tx, row.ID); err != nil {+ return err+ }+ continue+ }++ if ssoType == "saml" {+ samlSpec := make(map[string]json.RawMessage)+ if err := json.Unmarshal(spec, &samlSpec); err != nil {+ migration.logger.WarnContext(ctx, "removing auth domain with unreadable saml config", slog.String("auth_domain_id", row.ID), errors.Attr(err))+ if err := migration.remove(ctx, tx, row.ID); err != nil {+ return err+ }+ continue+ }++ for legacyKey, key := range legacySamlKeyToKey {+ if value, ok := samlSpec[legacyKey]; ok {+ samlSpec[key] = value+ delete(samlSpec, legacyKey)+ }+ }++ if spec, err = json.Marshal(samlSpec); err != nil {+ return err+ }+ }++ if ssoType == "google_auth" {+ googleSpec := make(map[string]json.RawMessage)+ if err := json.Unmarshal(spec, &googleSpec); err != nil {+ migration.logger.WarnContext(ctx, "removing auth domain with unreadable google config", slog.String("auth_domain_id", row.ID), errors.Attr(err))+ if err := migration.remove(ctx, tx, row.ID); err != nil {+ return err+ }+ continue+ }++ delete(googleSpec, "redirectURI")++ if spec, err = json.Marshal(googleSpec); err != nil {+ return err+ }+ }++ kindRaw, err := json.Marshal(kind)+ if err != nil {+ return err+ }++ config, err := json.Marshal(map[string]json.RawMessage{+ "kind": kindRaw,+ "spec": spec,+ })+ if err != nil {+ return err+ }++ restructured := map[string]json.RawMessage{+ "enabled": json.RawMessage("false"),+ "config": config,+ }+ if enabled, ok := legacy["ssoEnabled"]; ok {+ restructured["enabled"] = enabled+ }+ if roleMapping, ok := legacy["roleMapping"]; ok && string(roleMapping) != "null" {+ restructured["roleMapping"] = roleMapping+ }++ newData, err := json.Marshal(restructured)+ if err != nil {+ return err+ }++ if _, err := tx.NewUpdate().+ Model((*restructureAuthDomainRow)(nil)).+ Set("data = ?", string(newData)).+ Where("id = ?", row.ID).+ Exec(ctx); err != nil {+ return err+ }+ }++ return tx.Commit()+}++func (migration *restructureAuthDomainConfig) Down(context.Context, *bun.DB) error {+ return nil+}diff --git a/pkg/types/authtypes/authn.go b/pkg/types/authtypes/authn.goindex b43176bfa4..c4ab0e7ea9 100644--- a/pkg/types/authtypes/authn.go+++ b/pkg/types/authtypes/authn.go@@ -16,7 +16,7 @@ var ()var (- AuthNProviderGoogleAuth = AuthNProvider{valuer.NewString("google_auth")}+ AuthNProviderGoogle = AuthNProvider{valuer.NewString("google")}AuthNProviderSAML = AuthNProvider{valuer.NewString("saml")}AuthNProviderEmailPassword = AuthNProvider{valuer.NewString("email_password")}AuthNProviderOIDC = AuthNProvider{valuer.NewString("oidc")}@@ -158,7 +158,7 @@ func (typ *Identity) ToClaims() Claims {func (AuthNProvider) Enum() []any {return []any{- AuthNProviderGoogleAuth,+ AuthNProviderGoogle,AuthNProviderSAML,AuthNProviderEmailPassword,AuthNProviderOIDC,diff --git a/pkg/types/authtypes/domain.go b/pkg/types/authtypes/domain.goindex ec3d91a2d4..4f385f9c89 100644--- a/pkg/types/authtypes/domain.go+++ b/pkg/types/authtypes/domain.go@@ -30,7 +30,9 @@ var (type GettableAuthDomain struct {StorableAuthDomain+ Enabled bool `json:"enabled"`Config AuthDomainConfig `json:"config"`+ RoleMapping *RoleMapping `json:"roleMapping"`AuthNProviderInfo *AuthNProviderInfo `json:"authNProviderInfo"`}@@ -39,12 +41,16 @@ type AuthNProviderInfo struct {}type PostableAuthDomain struct {- Config AuthDomainConfig `json:"config"`- Name string `json:"name"`+ Name string `json:"name" required:"true"`+ Enabled bool `json:"enabled"`+ Config AuthDomainConfig `json:"config" required:"true"`+ RoleMapping *RoleMapping `json:"roleMapping"`}type UpdatableAuthDomain struct {- Config AuthDomainConfig `json:"config"`+ Enabled bool `json:"enabled"`+ Config AuthDomainConfig `json:"config" required:"true"`+ RoleMapping *RoleMapping `json:"roleMapping"`}type StorableAuthDomain struct {@@ -57,71 +63,58 @@ type StorableAuthDomain struct {types.TimeAuditable}-// TODO: the oneOf emitted by JSONSchemaOneOf is not the shape OpenAPI wants-// for a discriminated union. OpenAPI's discriminator requires every oneOf-// branch to be a $ref to a named component and a sibling property whose value-// selects the variant. ssoType is already discriminator-shaped, but the-// variant payload lives in a sibling field (samlConfig / googleAuthConfig /-// oidcConfig) instead of being the payload itself, so no discriminator can-// be attached. Refactor AuthDomainConfig into an envelope (see-// ruletypes.RuleThresholdData for the pattern) where the chosen config is-// the payload and ssoType is the discriminator.-type AuthDomainConfig struct {- SSOEnabled bool `json:"ssoEnabled"`- AuthNProvider AuthNProvider `json:"ssoType"`- SAML *SamlConfig `json:"samlConfig"`- Google *GoogleConfig `json:"googleAuthConfig"`- OIDC *OIDCConfig `json:"oidcConfig"`- RoleMapping *RoleMapping `json:"roleMapping"`-}-type AuthDomain struct {- storableAuthDomain *StorableAuthDomain- authDomainConfig *AuthDomainConfig+ storableAuthDomain *StorableAuthDomain+ storableAuthDomainConfig *StorableAuthDomainConfig}-func NewAuthDomainFromConfig(name string, config *AuthDomainConfig, orgID valuer.UUID) (*AuthDomain, error) {- data, err := json.Marshal(config)+func NewAuthDomainFromPostableAuthDomain(postableAuthDomain *PostableAuthDomain, orgID valuer.UUID) (*AuthDomain, error) {+ storableAuthDomainConfig := &StorableAuthDomainConfig{+ Enabled: postableAuthDomain.Enabled,+ Config: postableAuthDomain.Config,+ RoleMapping: postableAuthDomain.RoleMapping,+ }++ data, err := json.Marshal(storableAuthDomainConfig)if err != nil {return nil, err}- return NewAuthDomain(name, string(data), orgID)-}--func NewAuthDomain(name string, data string, orgID valuer.UUID) (*AuthDomain, error) {- storableAuthDomain := &StorableAuthDomain{- Identifiable: types.Identifiable{- ID: valuer.GenerateUUID(),- },- Name: name,- Data: data,- OrgID: orgID,- TimeAuditable: types.TimeAuditable{- CreatedAt: time.Now(),- UpdatedAt: time.Now(),+ return &AuthDomain{+ storableAuthDomain: &StorableAuthDomain{+ Identifiable: types.Identifiable{+ ID: valuer.GenerateUUID(),+ },+ Name: postableAuthDomain.Name,+ Data: string(data),+ OrgID: orgID,+ TimeAuditable: types.TimeAuditable{+ CreatedAt: time.Now(),+ UpdatedAt: time.Now(),+ },},- }-- return NewAuthDomainFromStorableAuthDomain(storableAuthDomain)+ storableAuthDomainConfig: storableAuthDomainConfig,+ }, nil}func NewAuthDomainFromStorableAuthDomain(storableAuthDomain *StorableAuthDomain) (*AuthDomain, error) {- authDomainConfig := new(AuthDomainConfig)- if err := json.Unmarshal([]byte(storableAuthDomain.Data), authDomainConfig); err != nil {+ storableAuthDomainConfig := new(StorableAuthDomainConfig)+ if err := json.Unmarshal([]byte(storableAuthDomain.Data), storableAuthDomainConfig); err != nil {return nil, err}return &AuthDomain{- storableAuthDomain: storableAuthDomain,- authDomainConfig: authDomainConfig,+ storableAuthDomain: storableAuthDomain,+ storableAuthDomainConfig: storableAuthDomainConfig,}, nil}func NewGettableAuthDomainFromAuthDomain(authDomain *AuthDomain, authNProviderInfo *AuthNProviderInfo) *GettableAuthDomain {return &GettableAuthDomain{StorableAuthDomain: *authDomain.StorableAuthDomain(),- Config: *authDomain.AuthDomainConfig(),+ Enabled: authDomain.Enabled(),+ Config: authDomain.Config(),+ RoleMapping: authDomain.RoleMapping(),AuthNProviderInfo: authNProviderInfo,}}@@ -130,17 +123,35 @@ func (typ *AuthDomain) StorableAuthDomain() *StorableAuthDomain {return typ.storableAuthDomain}-func (typ *AuthDomain) AuthDomainConfig() *AuthDomainConfig {- return typ.authDomainConfig+func (typ *AuthDomain) Enabled() bool {+ return typ.storableAuthDomainConfig.Enabled+}++func (typ *AuthDomain) Kind() AuthNProvider {+ return typ.storableAuthDomainConfig.Config.Kind+}++func (typ *AuthDomain) Config() AuthDomainConfig {+ return typ.storableAuthDomainConfig.Config+}++func (typ *AuthDomain) RoleMapping() *RoleMapping {+ return typ.storableAuthDomainConfig.RoleMapping}-func (typ *AuthDomain) Update(config *AuthDomainConfig) error {- data, err := json.Marshal(config)+func (typ *AuthDomain) Update(updatableAuthDomain *UpdatableAuthDomain) error {+ storableAuthDomainConfig := &StorableAuthDomainConfig{+ Enabled: updatableAuthDomain.Enabled,+ Config: updatableAuthDomain.Config,+ RoleMapping: updatableAuthDomain.RoleMapping,+ }++ data, err := json.Marshal(storableAuthDomainConfig)if err != nil {return err}- typ.authDomainConfig = config+ typ.storableAuthDomainConfig = storableAuthDomainConfigtyp.storableAuthDomain.Data = string(data)typ.storableAuthDomain.UpdatedAt = time.Now()return nil@@ -158,49 +169,32 @@ func (typ *PostableAuthDomain) UnmarshalJSON(data []byte) error {return errors.Newf(errors.TypeInvalidInput, ErrCodeAuthDomainInvalidName, "invalid domain name %s", temp.Name)}+ // A present config always carries a kind (its UnmarshalJSON rejects+ // anything else), so a zero kind means the key was absent.+ if temp.Config.Kind.IsZero() {+ return errors.Newf(errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "config is required")+ }+*typ = PostableAuthDomain(temp)return nil}-func (typ *AuthDomainConfig) UnmarshalJSON(data []byte) error {- type Alias AuthDomainConfig+func (typ *UpdatableAuthDomain) UnmarshalJSON(data []byte) error {+ type Alias UpdatableAuthDomainvar temp Aliasif err := json.Unmarshal(data, &temp); err != nil {return err}- switch temp.AuthNProvider {- case AuthNProviderGoogleAuth:- if temp.Google == nil {- return errors.Newf(errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "google auth config is required")- }-- case AuthNProviderSAML:- if temp.SAML == nil {- return errors.Newf(errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "saml config is required")- }-- case AuthNProviderOIDC:- if temp.OIDC == nil {- return errors.Newf(errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "oidc config is required")- }-- default:- return errors.Newf(errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "invalid authn provider %q", temp.AuthNProvider.StringValue())+ // A present config always carries a kind (its UnmarshalJSON rejects+ // anything else), so a zero kind means the key was absent.+ if temp.Config.Kind.IsZero() {+ return errors.Newf(errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "config is required")}- *typ = AuthDomainConfig(temp)+ *typ = UpdatableAuthDomain(temp)return nil--}--func (AuthDomainConfig) JSONSchemaOneOf() []any {- return []any{- SamlConfig{},- GoogleConfig{},- OIDCConfig{},- }}type AuthDomainStore interface {diff --git a/pkg/types/authtypes/domain_config.go b/pkg/types/authtypes/domain_config.gonew file mode 100644index 0000000000..ee41b32934--- /dev/null+++ b/pkg/types/authtypes/domain_config.go@@ -0,0 +1,178 @@+package authtypes++import (+ "encoding/json"++ "github.com/SigNoz/signoz/pkg/errors"+ "github.com/swaggest/jsonschema-go"+)++var (+ _ jsonschema.OneOfExposer = AuthDomainConfig{}+ _ jsonschema.Preparer = AuthDomainConfig{}+)++var authDomainConfigVariants = []authDomainConfigVariant{+ {+ kind: AuthNProviderSAML,+ decodeSpec: func(data []byte) (any, error) {+ spec := SamlConfig{}+ if err := json.Unmarshal(data, &spec); err != nil {+ return nil, err+ }+ return spec, nil+ },+ schema: authDomainConfigSAML{},+ schemaRef: "#/components/schemas/AuthtypesAuthDomainConfigSAML",+ },+ {+ kind: AuthNProviderGoogle,+ decodeSpec: func(data []byte) (any, error) {+ spec := GoogleConfig{}+ if err := json.Unmarshal(data, &spec); err != nil {+ return nil, err+ }+ return spec, nil+ },+ schema: authDomainConfigGoogle{},+ schemaRef: "#/components/schemas/AuthtypesAuthDomainConfigGoogle",+ },+ {+ kind: AuthNProviderOIDC,+ decodeSpec: func(data []byte) (any, error) {+ spec := OIDCConfig{}+ if err := json.Unmarshal(data, &spec); err != nil {+ return nil, err+ }+ return spec, nil+ },+ schema: authDomainConfigOIDC{},+ schemaRef: "#/components/schemas/AuthtypesAuthDomainConfigOIDC",+ },+}++type authDomainConfigVariant struct {+ kind AuthNProvider+ decodeSpec func(data []byte) (any, error)+ schema any+ schemaRef string+}++type AuthDomainConfig struct {+ Kind AuthNProvider `json:"kind" required:"true"`+ Spec any `json:"spec" required:"true"`+}++type authDomainConfigSAML struct {+ Kind AuthNProvider `json:"kind" description:"The kind of authn provider." required:"true"`+ Spec SamlConfig `json:"spec" description:"The saml configuration." required:"true"`+}++type authDomainConfigGoogle struct {+ Kind AuthNProvider `json:"kind" description:"The kind of authn provider." required:"true"`+ Spec GoogleConfig `json:"spec" description:"The google auth configuration." required:"true"`+}++type authDomainConfigOIDC struct {+ Kind AuthNProvider `json:"kind" description:"The kind of authn provider." required:"true"`+ Spec OIDCConfig `json:"spec" description:"The oidc configuration." required:"true"`+}++type StorableAuthDomainConfig struct {+ Enabled bool `json:"enabled"`+ Config AuthDomainConfig `json:"config"`+ RoleMapping *RoleMapping `json:"roleMapping"`+}++func (AuthDomainConfig) JSONSchemaOneOf() []any {+ oneOf := make([]any, len(authDomainConfigVariants))+ for i, variant := range authDomainConfigVariants {+ oneOf[i] = variant.schema+ }++ return oneOf+}++func (AuthDomainConfig) PrepareJSONSchema(schema *jsonschema.Schema) error {+ if schema.ExtraProperties == nil {+ schema.ExtraProperties = map[string]any{}+ }++ mapping := make(map[string]string, len(authDomainConfigVariants))+ for _, variant := range authDomainConfigVariants {+ mapping[variant.kind.StringValue()] = variant.schemaRef+ }++ schema.ExtraProperties["x-signoz-discriminator"] = map[string]any{+ "propertyName": "kind",+ "mapping": mapping,+ }++ return nil+}++func (typ *AuthDomainConfig) UnmarshalJSON(data []byte) error {+ var raw map[string]json.RawMessage+ if err := json.Unmarshal(data, &raw); err != nil {+ return errors.Wrapf(err, errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "failed to unmarshal auth domain config")+ }++ kindData, ok := raw["kind"]+ if !ok {+ return errors.Newf(errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "kind is required")+ }++ var kind AuthNProvider+ if err := json.Unmarshal(kindData, &kind); err != nil {+ return errors.Wrapf(err, errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "failed to unmarshal kind")+ }++ specData, ok := raw["spec"]+ if !ok {+ return errors.Newf(errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "spec is required")+ }++ for _, variant := range authDomainConfigVariants {+ if variant.kind != kind {+ continue+ }++ spec, err := variant.decodeSpec(specData)+ if err != nil {+ return err+ }++ typ.Kind = kind+ typ.Spec = spec+ return nil+ }++ return errors.Newf(errors.TypeInvalidInput, ErrCodeAuthDomainInvalidConfig, "invalid authn provider %q", kind.StringValue())+}++func (config AuthDomainConfig) SamlConfig() (SamlConfig, error) {+ spec, ok := config.Spec.(SamlConfig)+ if !ok {+ return SamlConfig{}, errors.Newf(errors.TypeInternal, ErrCodeAuthDomainMismatch, "auth domain config is not saml")+ }++ return spec, nil+}++func (config AuthDomainConfig) GoogleConfig() (GoogleConfig, error) {+ spec, ok := config.Spec.(GoogleConfig)+ if !ok {+ return GoogleConfig{}, errors.Newf(errors.TypeInternal, ErrCodeAuthDomainMismatch, "auth domain config is not google")+ }++ return spec, nil+}++func (config AuthDomainConfig) OIDCConfig() (OIDCConfig, error) {+ spec, ok := config.Spec.(OIDCConfig)+ if !ok {+ return OIDCConfig{}, errors.Newf(errors.TypeInternal, ErrCodeAuthDomainMismatch, "auth domain config is not oidc")+ }++ return spec, nil+}diff --git a/pkg/types/authtypes/domain_test.go b/pkg/types/authtypes/domain_test.gonew file mode 100644index 0000000000..c9184e2664--- /dev/null+++ b/pkg/types/authtypes/domain_test.go@@ -0,0 +1,88 @@+package authtypes++import (+ "encoding/json"+ "testing"++ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require"+)++func TestPostableAuthDomainSpecFields(t *testing.T) {+ testCases := []struct {+ name string+ body string+ expectedKind AuthNProvider+ }{+ {+ name: "SAMLSpec",+ body: `{"name":"a.test","enabled":true,"config":{"kind":"saml","spec":{"entityId":"e","location":"l","certificate":"c"}}}`,+ expectedKind: AuthNProviderSAML,+ },+ {+ name: "SAMLSpecWithAttributeMapping",+ body: `{"name":"a.test","enabled":true,"config":{"kind":"saml","spec":{"entityId":"e","location":"l","certificate":"c","insecureSkipAuthNRequestsSigned":true,"attributeMapping":{"email":"mail"}}}}`,+ expectedKind: AuthNProviderSAML,+ },+ {+ name: "GoogleSpec",+ body: `{"name":"a.test","enabled":true,"config":{"kind":"google","spec":{"clientId":"c","clientSecret":"s","insecureSkipEmailVerified":false}}}`,+ expectedKind: AuthNProviderGoogle,+ },+ {+ name: "GoogleSpecWithWorkspaceGroups",+ body: `{"name":"a.test","enabled":true,"config":{"kind":"google","spec":{"clientId":"c","clientSecret":"s","fetchGroups":true,"serviceAccountJson":"{}","domainToAdminEmail":{"*":"[email protected]"},"fetchTransitiveGroupMembership":true,"allowedGroups":["[email protected]"]}}}`,+ expectedKind: AuthNProviderGoogle,+ },+ {+ name: "OIDCSpec",+ body: `{"name":"a.test","enabled":true,"config":{"kind":"oidc","spec":{"issuer":"https://issuer.a.test","clientId":"c","clientSecret":"s"}}}`,+ expectedKind: AuthNProviderOIDC,+ },+ {+ name: "OIDCFieldsUnderGoogleKindConfigureGoogle",+ body: `{"name":"a.test","enabled":true,"config":{"kind":"google","spec":{"issuer":"https://issuer.a.test","clientId":"c","clientSecret":"s","claimMapping":{"email":"mail"}}}}`,+ expectedKind: AuthNProviderGoogle,+ },+ {+ name: "GoogleOnlyFieldUnderGoogleKindIgnored",+ body: `{"name":"a.test","enabled":true,"config":{"kind":"google","spec":{"clientId":"c","clientSecret":"s","redirectURI":"https://a.test/cb"}}}`,+ expectedKind: AuthNProviderGoogle,+ },+ }++ for _, testCase := range testCases {+ t.Run(testCase.name, func(t *testing.T) {+ postable := new(PostableAuthDomain)+ err := json.Unmarshal([]byte(testCase.body), postable)+ require.NoError(t, err)++ assert.Equal(t, testCase.expectedKind, postable.Config.Kind)+ })+ }+}++// The enforcement toggle and the edit modal both PUT a full replacement, so the update body decodes with the same kind-authoritative rules as the create body.+func TestUpdatableAuthDomainSpecFields(t *testing.T) {+ updatable := new(UpdatableAuthDomain)+ err := json.Unmarshal([]byte(`{"enabled":true,"config":{"kind":"google","spec":{"issuer":"https://issuer.a.test","clientId":"c","clientSecret":"s"}}}`), updatable)+ require.NoError(t, err)++ assert.Equal(t, AuthNProviderGoogle, updatable.Config.Kind)+}++// Reads stay lenient on purpose: a document written by a newer binary has to keep loading after a rollback, and dropping a field must not need a migration.+func TestNewAuthDomainFromStorableAuthDomainKeepsUnknownSpecFields(t *testing.T) {+ storable := &StorableAuthDomain{+ Data: `{"enabled":true,"config":{"kind":"google","spec":{"clientId":"c","clientSecret":"s","fieldFromANewerVersion":"x"}}}`,+ }++ authDomain, err := NewAuthDomainFromStorableAuthDomain(storable)+ require.NoError(t, err)++ google, err := authDomain.Config().GoogleConfig()+ require.NoError(t, err)++ assert.Equal(t, AuthNProviderGoogle, authDomain.Kind())+ assert.Equal(t, "c", google.ClientID)+}diff --git a/pkg/types/authtypes/google.go b/pkg/types/authtypes/google.goindex 5aa8f2a8ca..5e94a134a9 100644--- a/pkg/types/authtypes/google.go+++ b/pkg/types/authtypes/google.go@@ -12,13 +12,10 @@ const wildCardDomain = "*"type GoogleConfig struct {// ClientID is the application's ID. For example, 292085223830.apps.googleusercontent.com.- ClientID string `json:"clientId"`+ ClientID string `json:"clientId" required:"true"`// It is the application's secret.- ClientSecret string `json:"clientSecret"`-- // What is the meaning of this? Should we remove this?- RedirectURI string `json:"redirectURI"`+ ClientSecret string `json:"clientSecret" required:"true" format:"password"`// Whether to fetch the Google workspace groups (required additional API scopes)FetchGroups bool `json:"fetchGroups"`@@ -26,7 +23,7 @@ type GoogleConfig struct {// Service Account creds JSON stored for Google Admin SDK access// This is content of the JSON file stored directly into db as string// Required if FetchGroups is true (unless running on GCE with default credentials)- ServiceAccountJSON string `json:"serviceAccountJson,omitempty"`+ ServiceAccountJSON string `json:"serviceAccountJson,omitempty" format:"password"`// Map of workspace domain to admin email for service account impersonation// The service account will impersonate this admin to call the directory APIdiff --git a/pkg/types/authtypes/oidc.go b/pkg/types/authtypes/oidc.goindex b29232e0a3..d4c4f9bc8d 100644--- a/pkg/types/authtypes/oidc.go+++ b/pkg/types/authtypes/oidc.go@@ -8,7 +8,7 @@ import (type OIDCConfig struct {// It is the URL identifier for the service. For example: "https://accounts.google.com" or "https://login.salesforce.com".- Issuer string `json:"issuer"`+ Issuer string `json:"issuer" required:"true"`// Some offspec providers like Azure, Oracle IDCS have oidc discovery url different from issuer url which causes issuerValidation to fail// This provides a way to override the Issuer url from the .well-known/openid-configuration issuer@@ -16,10 +16,10 @@ type OIDCConfig struct {IssuerAlias string `json:"issuerAlias"`// It is the application's ID.- ClientID string `json:"clientId"`+ ClientID string `json:"clientId" required:"true"`// It is the application's secret.- ClientSecret string `json:"clientSecret"`+ ClientSecret string `json:"clientSecret" required:"true" format:"password"`// Mapping of claims to the corresponding fields in the token.ClaimMapping AttributeMapping `json:"claimMapping"`diff --git a/pkg/types/authtypes/saml.go b/pkg/types/authtypes/saml.goindex be5a28dddd..7f72e0195d 100644--- a/pkg/types/authtypes/saml.go+++ b/pkg/types/authtypes/saml.go@@ -7,14 +7,14 @@ import ()type SamlConfig struct {- // The entityID of the SAML identity provider. It can typically be found in the EntityID attribute of the EntityDescriptor element in the SAML metadata of the identity provider. Example: <md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" entityID="{samlEntity}">- SamlEntity string `json:"samlEntity"`+ // The entityID of the SAML identity provider. It can typically be found in the EntityID attribute of the EntityDescriptor element in the SAML metadata of the identity provider. Example: <md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" entityID="{entityId}">+ EntityID string `json:"entityId" required:"true"`- // The SSO endpoint of the SAML identity provider. It can typically be found in the SingleSignOnService element in the SAML metadata of the identity provider. Example: <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="{samlIdp}"/>- SamlIdp string `json:"samlIdp"`+ // The SSO endpoint of the SAML identity provider. It can typically be found in the Location attribute of the SingleSignOnService element in the SAML metadata of the identity provider. Example: <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="{location}"/>+ Location string `json:"location" required:"true"`- // The certificate of the SAML identity provider. It can typically be found in the X509Certificate element in the SAML metadata of the identity provider. Example: <ds:X509Certificate><ds:X509Certificate>{samlCert}</ds:X509Certificate></ds:X509Certificate>- SamlCert string `json:"samlCert"`+ // The certificate of the SAML identity provider. It can typically be found in the X509Certificate element in the SAML metadata of the identity provider. Example: <ds:X509Certificate><ds:X509Certificate>{certificate}</ds:X509Certificate></ds:X509Certificate>+ Certificate string `json:"certificate" required:"true"`// Whether to skip signing the SAML requests. It can typically be found in the WantAuthnRequestsSigned attribute of the IDPSSODescriptor element in the SAML metadata of the identity provider. Example: <md:IDPSSODescriptor WantAuthnRequestsSigned="false" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">// For providers like jumpcloud, this should be set to true.@@ -33,24 +33,34 @@ func (config *SamlConfig) UnmarshalJSON(data []byte) error {return err}- if temp.SamlEntity == "" {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "samlEntity is required")+ samlConfig := SamlConfig(temp)+ if err := samlConfig.validate(); err != nil {+ return err+ }++ *config = samlConfig+ return nil+}++// validate also assigns the default attribute mapping when none is present.+func (config *SamlConfig) validate() error {+ if config.EntityID == "" {+ return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "entityId is required")}- if temp.SamlIdp == "" {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "samlIdp is required")+ if config.Location == "" {+ return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "location is required")}- if temp.SamlCert == "" {- return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "samlCert is required")+ if config.Certificate == "" {+ return errors.New(errors.TypeInvalidInput, errors.CodeInvalidInput, "certificate is required")}- if temp.AttributeMapping == (AttributeMapping{}) {- if err := json.Unmarshal([]byte("{}"), &temp.AttributeMapping); err != nil {+ if config.AttributeMapping == (AttributeMapping{}) {+ if err := json.Unmarshal([]byte("{}"), &config.AttributeMapping); err != nil {return err}}- *config = SamlConfig(temp)return nil}diff --git a/tests/e2e/helpers/sso.ts b/tests/e2e/helpers/sso.tsnew file mode 100644index 0000000000..68ba6b78b0--- /dev/null+++ b/tests/e2e/helpers/sso.ts@@ -0,0 +1,141 @@+import { expect, type Locator, type Page } from '@playwright/test';++import { authToken } from './common';++// ─── Constants ───────────────────────────────────────────────────────────++export const ORG_SETTINGS_PATH = '/settings/org-settings';++// ─── Types ─────────────────────────────────────────────────────────────────++export interface GoogleAuthDomainSeed {+ /** Domain name (e.g. `sso-edit.example.com`). Keep unique per test. */+ name: string;+ /** Enforce-SSO flag. Defaults to false. */+ enabled?: boolean;+ clientId?: string;+ clientSecret?: string;+ /**+ * Enables Google Workspace group fetching. The backend then requires+ * `serviceAccountJson` and `domainToAdminEmail`, and only with it may+ * `allowedGroups` be set.+ */+ fetchGroups?: boolean;+ serviceAccountJson?: string;+ domainToAdminEmail?: Record<string, string>;+ allowedGroups?: string[];+ roleMapping?: {+ defaultRole?: string;+ groupMappings?: Record<string, string>;+ useRoleAttribute?: boolean;+ };+}++// ─── API helpers ─────────────────────────────────────────────────────────++/**+ * Seed a Google auth domain via POST /api/v2/auth_domains. Returns the new+ * domain ID. Pair with {@link deleteAuthDomainByNameViaApi} for cleanup.+ */+export async function createGoogleAuthDomainViaApi(+ page: Page,+ seed: GoogleAuthDomainSeed,+): Promise<string> {+ const token = await authToken(page);++ const spec: Record<string, unknown> = {+ clientId: seed.clientId ?? 'e2e-client-id.apps.googleusercontent.com',+ clientSecret: seed.clientSecret ?? 'e2e-client-secret',+ fetchGroups: seed.fetchGroups ?? false,+ insecureSkipEmailVerified: false,+ };+ if (seed.serviceAccountJson) {+ spec.serviceAccountJson = seed.serviceAccountJson;+ }+ if (seed.domainToAdminEmail) {+ spec.domainToAdminEmail = seed.domainToAdminEmail;+ }+ if (seed.allowedGroups) {+ spec.allowedGroups = seed.allowedGroups;+ }++ const res = await page.request.post('/api/v2/auth_domains', {+ data: {+ name: seed.name,+ enabled: seed.enabled ?? false,+ config: { kind: 'google', spec },+ roleMapping: seed.roleMapping,+ },+ headers: { Authorization: `Bearer ${token}` },+ });+ if (!res.ok()) {+ throw new Error(+ `POST /api/v2/auth_domains ${res.status()}: ${await res.text()}`,+ );+ }+ const json = (await res.json()) as { data: { id: string } };+ return json.data.id;+}++/** Delete an auth domain by ID (best-effort cleanup). */+async function deleteAuthDomainViaApi(page: Page, id: string): Promise<void> {+ const token = await authToken(page);+ await page.request.delete(`/api/v2/auth_domains/${id}`, {+ headers: { Authorization: `Bearer ${token}` },+ });+}++/**+ * Delete any auth domain named `name`; a no-op when absent. Doubles as the+ * leftover guard before seeding (domain names are unique per org, so a+ * crashed earlier run would otherwise make the seed conflict).+ */+export async function deleteAuthDomainByNameViaApi(+ page: Page,+ name: string,+): Promise<void> {+ const token = await authToken(page);+ const res = await page.request.get('/api/v2/auth_domains', {+ headers: { Authorization: `Bearer ${token}` },+ });+ if (!res.ok()) {+ throw new Error(+ `GET /api/v2/auth_domains ${res.status()}: ${await res.text()}`,+ );+ }+ const json = (await res.json()) as {+ data: Array<{ id: string; name: string }> | null;+ };+ const match = (json.data ?? []).find((domain) => domain.name === name);+ if (match) {+ await deleteAuthDomainViaApi(page, match.id);+ }+}++// ─── Navigation ────────────────────────────────────────────────────────────++/** Open org settings and wait for the Authenticated Domains section. */+export async function gotoAuthDomains(page: Page): Promise<void> {+ await page.goto(ORG_SETTINGS_PATH);+ await expect(page.getByTestId('auth-domain-title')).toBeVisible();+}++/** Locate the list row for the domain named `name`. */+export async function findAuthDomainRow(+ page: Page,+ name: string,+): Promise<Locator> {+ const row = page.getByTestId(`auth-domain-row-${name}`);+ await row.waitFor({ state: 'attached' });+ return row;+}++/** Open the Configure (edit) modal for the domain row named `name`. */+export async function openConfigureAuthDomain(+ page: Page,+ name: string,+): Promise<void> {+ const row = await findAuthDomainRow(page, name);+ await row.getByTestId('auth-domain-configure').click();+ await expect(page.getByTestId('auth-domain-form')).toBeVisible();+}diff --git a/tests/e2e/tests/sso/auth-domains.spec.ts b/tests/e2e/tests/sso/auth-domains.spec.tsnew file mode 100644index 0000000000..c833cd7944--- /dev/null+++ b/tests/e2e/tests/sso/auth-domains.spec.ts@@ -0,0 +1,244 @@+import { expect, test } from '../../fixtures/auth';+import {+ createGoogleAuthDomainViaApi,+ deleteAuthDomainByNameViaApi,+ findAuthDomainRow,+ gotoAuthDomains,+ openConfigureAuthDomain,+ ORG_SETTINGS_PATH,+} from '../../helpers/sso';++test.describe('SSO auth domains', () => {+ // Every test seeds its own uniquely-named domain so the file can run fully+ // parallel. Names are registered here and removed by the afterEach guard.+ const cleanupNames: string[] = [];++ test.afterEach(async ({ authedPage: page }) => {+ for (const name of cleanupNames.splice(0)) {+ await deleteAuthDomainByNameViaApi(page, name);+ }+ });++ test('TC-01 org settings shows the authenticated domains section', async ({+ authedPage: page,+ }) => {+ await page.goto(ORG_SETTINGS_PATH);+ await expect(page.getByTestId('auth-domain-title')).toBeVisible();+ await expect(page.getByTestId('auth-domain-add')).toBeVisible();+ });++ test('TC-02 create a google auth domain via the UI', async ({+ authedPage: page,+ }) => {+ const domain = 'sso-create.example.com';+ cleanupNames.push(domain);++ await gotoAuthDomains(page);+ await page.getByTestId('auth-domain-add').click();+ await page.getByTestId('authn-provider-configure-google').click();++ await page.getByTestId('google-auth-domain').fill(domain);+ await page+ .getByTestId('google-auth-client-id')+ .fill('e2e-client-id.apps.googleusercontent.com');+ await page.getByTestId('google-auth-client-secret').fill('e2e-client-secret');+ await page.getByTestId('auth-domain-save').click();++ await expect(page.getByText('Domain created successfully')).toBeVisible();+ const row = await findAuthDomainRow(page, domain);+ await expect(row.getByTestId('auth-domain-configure')).toHaveText(+ 'Configure Google Auth',+ );+ });++ test('TC-03 editing the client id persists across reopen', async ({+ authedPage: page,+ }) => {+ const domain = 'sso-edit.example.com';+ cleanupNames.push(domain);+ await createGoogleAuthDomainViaApi(page, { name: domain });++ await gotoAuthDomains(page);+ await openConfigureAuthDomain(page, domain);+ await expect(page.getByTestId('google-auth-client-id')).toHaveValue(+ 'e2e-client-id.apps.googleusercontent.com',+ );+ await page+ .getByTestId('google-auth-client-id')+ .fill('rotated-client-id.apps.googleusercontent.com');+ await page.getByTestId('auth-domain-save').click();+ await expect(page.getByText('Domain updated successfully')).toBeVisible();+ await expect(page.getByTestId('auth-domain-form')).toBeHidden();++ await openConfigureAuthDomain(page, domain);+ await expect(page.getByTestId('google-auth-client-id')).toHaveValue(+ 'rotated-client-id.apps.googleusercontent.com',+ );+ });++ test('TC-04 removing a group mapping persists after save', async ({+ authedPage: page,+ }) => {+ const domain = 'sso-rolemap.example.com';+ cleanupNames.push(domain);+ await createGoogleAuthDomainViaApi(page, {+ name: domain,+ roleMapping: {+ defaultRole: 'signoz-viewer',+ groupMappings: {+ engineers: 'signoz-editor',+ support: 'signoz-viewer',+ },+ },+ });++ await gotoAuthDomains(page);+ await openConfigureAuthDomain(page, domain);+ await page.getByTestId('role-mapping-header').click();++ const rows = page.getByTestId('role-mapping-row');+ await expect(rows).toHaveCount(2);+ // Go marshals map keys sorted, so "engineers" is always the first row.+ await expect(rows.nth(0).getByTestId('role-mapping-group-name')).toHaveValue(+ 'engineers',+ );+ await rows.nth(0).getByTestId('role-mapping-remove').click();+ await expect(rows).toHaveCount(1);++ await page.getByTestId('auth-domain-save').click();+ await expect(page.getByText('Domain updated successfully')).toBeVisible();+ await expect(page.getByTestId('auth-domain-form')).toBeHidden();++ await openConfigureAuthDomain(page, domain);+ await page.getByTestId('role-mapping-header').click();+ await expect(rows).toHaveCount(1);+ await expect(rows.getByTestId('role-mapping-group-name')).toHaveValue(+ 'support',+ );+ });++ test('TC-05 disabling fetch groups clears the allowed groups', async ({+ authedPage: page,+ }) => {+ const domain = 'sso-groups.example.com';+ cleanupNames.push(domain);+ await createGoogleAuthDomainViaApi(page, {+ name: domain,+ fetchGroups: true,+ serviceAccountJson: '{"type":"service_account","project_id":"e2e"}',+ domainToAdminEmail: { '*': '[email protected]' },+ allowedGroups: ['[email protected]'],+ });++ await gotoAuthDomains(page);+ await openConfigureAuthDomain(page, domain);+ await page.getByTestId('google-auth-workspace-groups-header').click();++ const fetchGroups = page+ .getByTestId('google-auth-fetch-groups')+ .getByRole('checkbox');+ await expect(fetchGroups).toBeChecked();+ await expect(+ page+ .getByTestId('google-auth-allowed-groups')+ .locator('.ant-select-selection-item'),+ ).toHaveCount(1);+ await fetchGroups.click();+ await expect(fetchGroups).not.toBeChecked();++ await page.getByTestId('auth-domain-save').click();+ await expect(page.getByText('Domain updated successfully')).toBeVisible();+ await expect(page.getByTestId('auth-domain-form')).toBeHidden();++ await openConfigureAuthDomain(page, domain);+ await page.getByTestId('google-auth-workspace-groups-header').click();+ await expect(fetchGroups).not.toBeChecked();+ // Re-enable to reveal the group fields: the allowed-groups list must be+ // empty, not repopulated from the pre-disable state.+ await fetchGroups.click();+ await expect(+ page+ .getByTestId('google-auth-allowed-groups')+ .locator('.ant-select-selection-item'),+ ).toHaveCount(0);+ });++ test('TC-06 enforce sso toggle persists across reload', async ({+ authedPage: page,+ }) => {+ const domain = 'sso-toggle.example.com';+ cleanupNames.push(domain);+ await createGoogleAuthDomainViaApi(page, { name: domain, enabled: false });++ await gotoAuthDomains(page);+ const toggle = (await findAuthDomainRow(page, domain)).getByTestId(+ 'auth-domain-enforce-sso',+ );+ await expect(toggle).not.toBeChecked();++ await toggle.click();+ await expect(toggle).toBeChecked();+ // The switch is disabled while the update is in flight; wait for it to+ // settle before reloading so the reload reads the persisted value.+ await expect(toggle).toBeEnabled();++ await page.reload();+ const reloadedRow = await findAuthDomainRow(page, domain);+ await expect(+ reloadedRow.getByTestId('auth-domain-enforce-sso'),+ ).toBeChecked();+ });++ test('TC-07 delete a domain via the UI', async ({ authedPage: page }) => {+ const removed = 'sso-delete.example.com';+ const kept = 'sso-delete-keep.example.com';+ cleanupNames.push(removed, kept);+ await createGoogleAuthDomainViaApi(page, { name: removed });+ await createGoogleAuthDomainViaApi(page, { name: kept });++ await gotoAuthDomains(page);+ const row = await findAuthDomainRow(page, removed);+ await row.getByTestId('auth-domain-delete').click();+ await page.getByTestId('auth-domain-delete-confirm').click();++ await expect(page.getByText('Domain deleted successfully')).toBeVisible();+ await expect(page.getByTestId(`auth-domain-row-${removed}`)).toHaveCount(0);+ await expect(page.getByTestId(`auth-domain-row-${kept}`)).toHaveCount(1);+ });++ test('TC-08 enforce sso toggle preserves the role mapping', async ({+ authedPage: page,+ }) => {+ const domain = 'sso-toggle-rolemap.example.com';+ cleanupNames.push(domain);+ await createGoogleAuthDomainViaApi(page, {+ name: domain,+ enabled: false,+ roleMapping: {+ defaultRole: 'signoz-editor',+ groupMappings: { engineers: 'signoz-editor', support: 'signoz-viewer' },+ },+ });++ await gotoAuthDomains(page);+ const toggle = (await findAuthDomainRow(page, domain)).getByTestId(+ 'auth-domain-enforce-sso',+ );+ await toggle.click();+ await expect(toggle).toBeChecked();+ await expect(toggle).toBeEnabled();++ await page.reload();+ await openConfigureAuthDomain(page, domain);+ await page.getByTestId('role-mapping-header').click();++ const rows = page.getByTestId('role-mapping-row');+ await expect(rows).toHaveCount(2);+ await expect(rows.nth(0).getByTestId('role-mapping-group-name')).toHaveValue(+ 'engineers',+ );+ await expect(rows.nth(1).getByTestId('role-mapping-group-name')).toHaveValue(+ 'support',+ );+ });+});diff --git a/tests/fixtures/googleidp.py b/tests/fixtures/googleidp.pyindex b7b4c61cd4..641a060b3c 100644--- a/tests/fixtures/googleidp.py+++ b/tests/fixtures/googleidp.py@@ -74,7 +74,7 @@ def perform_google_login(def get_google_domain(signoz: types.SigNoz, admin_token: str) -> dict:response = requests.get(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)diff --git a/tests/fixtures/idp.py b/tests/fixtures/idp.pyindex d567833831..0fb16d3b4b 100644--- a/tests/fixtures/idp.py+++ b/tests/fixtures/idp.py@@ -624,7 +624,7 @@ def _ensure_groups_client_scope(client: KeycloakAdmin) -> None:def get_oidc_domain(signoz: types.SigNoz, admin_token: str) -> dict:response = requests.get(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)@@ -653,7 +653,7 @@ def perform_oidc_login(def get_saml_domain(signoz: types.SigNoz, admin_token: str) -> dict:response = requests.get(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)diff --git a/tests/integration/tests/basepath/01_oidc.py b/tests/integration/tests/basepath/01_oidc.pyindex 29ff50bab7..d4ac0f2777 100644--- a/tests/integration/tests/basepath/01_oidc.py+++ b/tests/integration/tests/basepath/01_oidc.py@@ -50,13 +50,13 @@ def test_create_auth_domain(admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)response = requests.post(- signoz.self.host_configs["8080"].get("/signoz/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/signoz/api/v2/auth_domains"),json={"name": "oidc.basepath.test",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "oidc",- "oidcConfig": {+ "kind": "oidc",+ "spec": {"clientId": settings["client_id"],"clientSecret": settings["client_secret"],# Change the hostname of the issuer to the internal resolvable hostname of the idpdiff --git a/tests/integration/tests/basepath/02_saml.py b/tests/integration/tests/basepath/02_saml.pyindex e34f504598..6f5252386e 100644--- a/tests/integration/tests/basepath/02_saml.py+++ b/tests/integration/tests/basepath/02_saml.py@@ -48,16 +48,16 @@ def test_create_auth_domain(admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)response = requests.post(- signoz.self.host_configs["8080"].get("/signoz/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/signoz/api/v2/auth_domains"),json={"name": "saml.basepath.test",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "samlConfig": {- "samlEntity": settings["entityID"],- "samlIdp": settings["singleSignOnServiceLocation"],- "samlCert": settings["certificate"],+ "kind": "saml",+ "spec": {+ "entityId": settings["entityID"],+ "location": settings["singleSignOnServiceLocation"],+ "certificate": settings["certificate"],},},},diff --git a/tests/integration/tests/callbackauthn/01_domain.py b/tests/integration/tests/callbackauthn/01_domain.pyindex 7f140f0527..ea8cf7d41f 100644--- a/tests/integration/tests/callbackauthn/01_domain.py+++ b/tests/integration/tests/callbackauthn/01_domain.py@@ -1,6 +1,7 @@from collections.abc import Callablefrom http import HTTPStatus+import pytestimport requestsfrom fixtures.auth import USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD@@ -14,30 +15,35 @@ def test_create_and_get_domain():admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)- # Get domains which should be an empty list+ # Reruns against a reused stack find domains from previous runs; drop them+ # all so the suite starts from a clean slate.response = requests.get(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)assert response.status_code == HTTPStatus.OKassert response.json()["status"] == "success"- data = response.json()["data"]- assert len(data) == 0+ for domain in response.json()["data"]:+ response = requests.delete(+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain['id']}"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )+ assert response.status_code == HTTPStatus.NO_CONTENT# Create a domain with google auth configresponse = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": "domain-google.integration.test",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "google_auth",- "googleAuthConfig": {+ "kind": "google",+ "spec": {"clientId": "client-id","clientSecret": "client-secret",- "redirectURI": "redirect-uri",},},},@@ -49,16 +55,16 @@ def test_create_and_get_domain(# Create a domain with saml configresponse = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": "domain-saml.integration.test",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "samlConfig": {- "samlEntity": "saml-entity",- "samlIdp": "saml-idp",- "samlCert": "saml-cert",+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "saml-idp",+ "certificate": "saml-cert",},},},@@ -70,7 +76,7 @@ def test_create_and_get_domain(# List the domainsresponse = requests.get(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)@@ -86,7 +92,7 @@ def test_create_and_get_domain("domain-google.integration.test","domain-saml.integration.test",]- assert domain["config"]["ssoType"] in ["google_auth", "saml"]+ assert domain["config"]["kind"] in ["google", "saml"]def test_create_invalid(@@ -96,15 +102,15 @@ def test_create_invalid():admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)- # Create a domain with type saml and body for oidc, this should fail because oidcConfig is not allowed for saml+ # Create a domain with kind saml and a spec for oidc, this should fail because the spec does not match the kindresponse = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": "domain.integration.test",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "oidcConfig": {+ "kind": "saml",+ "spec": {"clientId": "client-id","clientSecret": "client-secret","issuer": "issuer",@@ -117,18 +123,34 @@ def test_create_invalid(assert response.status_code == HTTPStatus.BAD_REQUEST+ # Create a domain with a kind but no spec+ response = requests.post(+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),+ json={+ "name": "domain.integration.test",+ "enabled": True,+ "config": {+ "kind": "saml",+ },+ },+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )++ assert response.status_code == HTTPStatus.BAD_REQUEST+# Create a domain with invalid nameresponse = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": "$%^invalid",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "samlConfig": {- "samlEntity": "saml-entity",- "samlIdp": "saml-idp",- "samlCert": "saml-cert",+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "saml-idp",+ "certificate": "saml-cert",},},},@@ -140,17 +162,17 @@ def test_create_invalid(# Create a domain with no nameresponse = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "samlConfig": {- "samlEntity": "saml-entity",- "samlIdp": "saml-idp",- "samlCert": "saml-cert",+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "saml-idp",+ "certificate": "saml-cert",},- }+ },},headers={"Authorization": f"Bearer {admin_token}"},timeout=2,@@ -160,7 +182,7 @@ def test_create_invalid(# Create a domain with no configresponse = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": "domain.integration.test",},@@ -180,21 +202,21 @@ def test_create_invalid_role_mapping(# Create domain with invalid defaultRoleresponse = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": "invalid-role-test.integration.test",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "samlConfig": {- "samlEntity": "saml-entity",- "samlIdp": "saml-idp",- "samlCert": "saml-cert",- },- "roleMapping": {- "defaultRole": "SUPERADMIN", # Invalid role+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "saml-idp",+ "certificate": "saml-cert",},},+ "roleMapping": {+ "defaultRole": "SUPERADMIN", # Invalid role+ },},headers={"Authorization": f"Bearer {admin_token}"},timeout=2,@@ -204,22 +226,22 @@ def test_create_invalid_role_mapping(# Create domain with invalid role in groupMappingsresponse = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": "invalid-group-role.integration.test",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "samlConfig": {- "samlEntity": "saml-entity",- "samlIdp": "saml-idp",- "samlCert": "saml-cert",+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "saml-idp",+ "certificate": "saml-cert",},- "roleMapping": {- "defaultRole": "VIEWER",- "groupMappings": {- "admins": "SUPERUSER", # Invalid role- },+ },+ "roleMapping": {+ "defaultRole": "VIEWER",+ "groupMappings": {+ "admins": "SUPERUSER", # Invalid role},},},@@ -231,28 +253,411 @@ def test_create_invalid_role_mapping(# Valid role mapping should succeedresponse = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": "valid-role-mapping.integration.test",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "samlConfig": {- "samlEntity": "saml-entity",- "samlIdp": "saml-idp",- "samlCert": "saml-cert",+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "saml-idp",+ "certificate": "saml-cert",},- "roleMapping": {- "defaultRole": "VIEWER",- "groupMappings": {- "signoz-admins": "ADMIN",- "signoz-editors": "EDITOR",+ },+ "roleMapping": {+ "defaultRole": "VIEWER",+ "groupMappings": {+ "signoz-admins": "ADMIN",+ "signoz-editors": "EDITOR",+ },+ },+ },+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )++ assert response.status_code == HTTPStatus.CREATED+++ ("config", "role_mapping", "expected_config", "expected_role_mapping"),+ [+ pytest.param(+ {+ "kind": "google",+ "spec": {"clientId": "client-id", "clientSecret": "client-secret"},+ },+ None,+ {+ "kind": "google",+ "spec": {+ "clientId": "client-id",+ "clientSecret": "client-secret",+ "fetchGroups": False,+ "insecureSkipEmailVerified": False,+ },+ },+ None,+ id="google_minimal",+ ),+ pytest.param(+ {+ "kind": "google",+ "spec": {+ "clientId": "client-id",+ "clientSecret": "client-secret",+ "fetchGroups": True,+ "serviceAccountJson": '{"type": "service_account"}',+ "domainToAdminEmail": {+ "roundtrip.integration.test": "[email protected]",+ "*": "[email protected]",},+ "fetchTransitiveGroupMembership": True,+ "allowedGroups": ["group-one", "group-two"],+ "insecureSkipEmailVerified": True,+ },+ },+ None,+ {+ "kind": "google",+ "spec": {+ "clientId": "client-id",+ "clientSecret": "client-secret",+ "fetchGroups": True,+ "serviceAccountJson": '{"type": "service_account"}',+ "domainToAdminEmail": {+ "roundtrip.integration.test": "[email protected]",+ "*": "[email protected]",+ },+ "fetchTransitiveGroupMembership": True,+ "allowedGroups": ["group-one", "group-two"],+ "insecureSkipEmailVerified": True,+ },+ },+ None,+ id="google_full",+ ),+ pytest.param(+ {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "https://idp.integration.test/sso",+ "certificate": "saml-cert",+ },+ },+ None,+ {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "https://idp.integration.test/sso",+ "certificate": "saml-cert",+ "insecureSkipAuthNRequestsSigned": False,+ "attributeMapping": {"email": "email", "name": "name", "groups": "groups", "role": "role"},+ },+ },+ None,+ id="saml_minimal",+ ),+ pytest.param(+ {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "https://idp.integration.test/sso",+ "certificate": "saml-cert",+ "insecureSkipAuthNRequestsSigned": True,+ "attributeMapping": {"email": "mail"},+ },+ },+ None,+ {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "https://idp.integration.test/sso",+ "certificate": "saml-cert",+ "insecureSkipAuthNRequestsSigned": True,+ "attributeMapping": {"email": "mail", "name": "name", "groups": "groups", "role": "role"},+ },+ },+ None,+ id="saml_partial_attribute_mapping",+ ),+ pytest.param(+ {+ "kind": "oidc",+ "spec": {+ "issuer": "https://issuer.integration.test",+ "clientId": "client-id",+ "clientSecret": "client-secret",+ },+ },+ None,+ {+ "kind": "oidc",+ "spec": {+ "issuer": "https://issuer.integration.test",+ "issuerAlias": "",+ "clientId": "client-id",+ "clientSecret": "client-secret",+ "claimMapping": {"email": "email", "name": "name", "groups": "groups", "role": "role"},+ "insecureSkipEmailVerified": False,+ "getUserInfo": False,+ },+ },+ None,+ id="oidc_minimal",+ ),+ pytest.param(+ {+ "kind": "oidc",+ "spec": {+ "issuer": "https://issuer.integration.test",+ "issuerAlias": "https://alias.integration.test",+ "clientId": "client-id",+ "clientSecret": "client-secret",+ "claimMapping": {"email": "eml", "name": "nm", "groups": "grps", "role": "rl"},+ "insecureSkipEmailVerified": True,+ "getUserInfo": True,+ },+ },+ None,+ {+ "kind": "oidc",+ "spec": {+ "issuer": "https://issuer.integration.test",+ "issuerAlias": "https://alias.integration.test",+ "clientId": "client-id",+ "clientSecret": "client-secret",+ "claimMapping": {"email": "eml", "name": "nm", "groups": "grps", "role": "rl"},+ "insecureSkipEmailVerified": True,+ "getUserInfo": True,+ },+ },+ None,+ id="oidc_full",+ ),+ pytest.param(+ {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "https://idp.integration.test/sso",+ "certificate": "saml-cert",+ },+ },+ {+ "defaultRole": "EDITOR",+ "groupMappings": {"platform-team": "ADMIN"},+ "useRoleAttribute": False,+ },+ {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "https://idp.integration.test/sso",+ "certificate": "saml-cert",+ "insecureSkipAuthNRequestsSigned": False,+ "attributeMapping": {"email": "email", "name": "name", "groups": "groups", "role": "role"},+ },+ },+ {+ "defaultRole": "signoz-editor",+ "groupMappings": {"platform-team": "signoz-admin"},+ "useRoleAttribute": False,+ },+ id="role_mapping_names_normalized",+ ),+ pytest.param(+ {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "https://idp.integration.test/sso",+ "certificate": "saml-cert",},},+ {"defaultRole": "VIEWER", "useRoleAttribute": True},+ {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "https://idp.integration.test/sso",+ "certificate": "saml-cert",+ "insecureSkipAuthNRequestsSigned": False,+ "attributeMapping": {"email": "email", "name": "name", "groups": "groups", "role": "role"},+ },+ },+ {"defaultRole": "signoz-viewer", "groupMappings": None, "useRoleAttribute": True},+ id="role_mapping_null_group_mappings",+ ),+ ],+)+def test_domain_roundtrip( # pylint: disable=too-many-arguments,too-many-positional-arguments+ signoz: SigNoz,+ create_user_admin: Operation, # pylint: disable=unused-argument+ get_token: Callable[[str, str], str],+ config: dict,+ role_mapping: dict | None,+ expected_config: dict,+ expected_role_mapping: dict | None,+):+ admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)++ # Drop a same-named leftover so reruns against a reused stack stay green.+ response = requests.get(+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )+ assert response.status_code == HTTPStatus.OK+ for domain in response.json()["data"]:+ if domain["name"] == "roundtrip.integration.test":+ response = requests.delete(+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain['id']}"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )+ assert response.status_code == HTTPStatus.NO_CONTENT++ response = requests.post(+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),+ json={+ "name": "roundtrip.integration.test",+ "enabled": True,+ "config": config,+ "roleMapping": role_mapping,},headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)+ assert response.status_code == HTTPStatus.CREATED+ domain_id = response.json()["data"]["id"]+ # Clients (e.g. the terraform provider) read state back with a follow-up+ # GET after every write, so posted values must round-trip exactly; the+ # server-side defaulting and role-name normalization pinned here are part+ # of that contract.+ response = requests.get(+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain_id}"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )+ assert response.status_code == HTTPStatus.OK+ data = response.json()["data"]++ assert data["name"] == "roundtrip.integration.test"+ assert data["enabled"] is True+ assert data["config"] == expected_config+ assert data["roleMapping"] == expected_role_mapping++ response = requests.delete(+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain_id}"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )+ assert response.status_code == HTTPStatus.NO_CONTENT+++def test_update_enabled(+ signoz: SigNoz,+ create_user_admin: Operation, # pylint: disable=unused-argument+ get_token: Callable[[str, str], str],+):+ admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)++ # Drop a same-named leftover so reruns against a reused stack stay green.+ response = requests.get(+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )+ assert response.status_code == HTTPStatus.OK+ for domain in response.json()["data"]:+ if domain["name"] == "update-enabled.integration.test":+ response = requests.delete(+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain['id']}"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )+ assert response.status_code == HTTPStatus.NO_CONTENT++ role_mapping = {+ "defaultRole": "signoz-editor",+ "groupMappings": {"admin-group": "signoz-admin", "dev-team": "signoz-editor"},+ "useRoleAttribute": False,+ }++ response = requests.post(+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),+ json={+ "name": "update-enabled.integration.test",+ "enabled": True,+ "config": {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "saml-idp",+ "certificate": "saml-cert",+ },+ },+ "roleMapping": role_mapping,+ },+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )assert response.status_code == HTTPStatus.CREATED+ domain_id = response.json()["data"]["id"]++ # Flipping enforcement goes through the same full update as any other+ # change; the echoed provider config and role mapping must both survive the+ # round trip, since the UI resends them verbatim on every toggle.+ response = requests.put(+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain_id}"),+ json={+ "enabled": False,+ "config": {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "saml-idp",+ "certificate": "saml-cert",+ },+ },+ "roleMapping": role_mapping,+ },+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )+ assert response.status_code == HTTPStatus.NO_CONTENT++ response = requests.get(+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain_id}"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )+ assert response.status_code == HTTPStatus.OK+ data = response.json()["data"]++ assert data["enabled"] is False+ assert data["config"] == {+ "kind": "saml",+ "spec": {+ "entityId": "saml-entity",+ "location": "saml-idp",+ "certificate": "saml-cert",+ "insecureSkipAuthNRequestsSigned": False,+ "attributeMapping": {"email": "email", "name": "name", "groups": "groups", "role": "role"},+ },+ }+ assert data["roleMapping"] == role_mapping++ response = requests.delete(+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain_id}"),+ headers={"Authorization": f"Bearer {admin_token}"},+ timeout=2,+ )+ assert response.status_code == HTTPStatus.NO_CONTENTdiff --git a/tests/integration/tests/callbackauthn/02_saml.py b/tests/integration/tests/callbackauthn/02_saml.pyindex 8e78b7f9fb..421fa2a5af 100644--- a/tests/integration/tests/callbackauthn/02_saml.py+++ b/tests/integration/tests/callbackauthn/02_saml.py@@ -52,16 +52,16 @@ def test_create_auth_domain(admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)response = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": "saml.integration.test",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "samlConfig": {- "samlEntity": settings["entityID"],- "samlIdp": settings["singleSignOnServiceLocation"],- "samlCert": settings["certificate"],+ "kind": "saml",+ "spec": {+ "entityId": settings["entityID"],+ "location": settings["singleSignOnServiceLocation"],+ "certificate": settings["certificate"],},},},@@ -73,7 +73,7 @@ def test_create_auth_domain(# Get the domains from signozresponse = requests.get(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)@@ -176,30 +176,30 @@ def test_saml_update_domain_with_group_mappings(# update the existing saml domain to have role mappings alsoresponse = requests.put(- signoz.self.host_configs["8080"].get(f"/api/v1/domains/{domain['id']}"),+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain['id']}"),json={+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "samlConfig": {- "samlEntity": settings["entityID"],- "samlIdp": settings["singleSignOnServiceLocation"],- "samlCert": settings["certificate"],+ "kind": "saml",+ "spec": {+ "entityId": settings["entityID"],+ "location": settings["singleSignOnServiceLocation"],+ "certificate": settings["certificate"],"attributeMapping": {"name": "givenName","groups": "groups","role": "signoz_role",},},- "roleMapping": {- "defaultRole": "VIEWER",- "groupMappings": {- "signoz-admins": "ADMIN",- "signoz-editors": "EDITOR",- "signoz-viewers": "VIEWER",- },- "useRoleAttribute": False,+ },+ "roleMapping": {+ "defaultRole": "VIEWER",+ "groupMappings": {+ "signoz-admins": "ADMIN",+ "signoz-editors": "EDITOR",+ "signoz-viewers": "VIEWER",},+ "useRoleAttribute": False,},},headers={"Authorization": f"Bearer {admin_token}"},@@ -331,29 +331,29 @@ def test_saml_update_domain_with_use_role_claim(settings = get_saml_settings()response = requests.put(- signoz.self.host_configs["8080"].get(f"/api/v1/domains/{domain['id']}"),+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain['id']}"),json={+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "saml",- "samlConfig": {- "samlEntity": settings["entityID"],- "samlIdp": settings["singleSignOnServiceLocation"],- "samlCert": settings["certificate"],+ "kind": "saml",+ "spec": {+ "entityId": settings["entityID"],+ "location": settings["singleSignOnServiceLocation"],+ "certificate": settings["certificate"],"attributeMapping": {"name": "displayName","groups": "groups","role": "signoz_role",},},- "roleMapping": {- "defaultRole": "VIEWER",- "groupMappings": {- "signoz-admins": "ADMIN",- "signoz-editors": "EDITOR",- },- "useRoleAttribute": True,+ },+ "roleMapping": {+ "defaultRole": "VIEWER",+ "groupMappings": {+ "signoz-admins": "ADMIN",+ "signoz-editors": "EDITOR",},+ "useRoleAttribute": True,},},headers={"Authorization": f"Bearer {admin_token}"},diff --git a/tests/integration/tests/callbackauthn/03_oidc.py b/tests/integration/tests/callbackauthn/03_oidc.pyindex 900d6918fe..efcbc990aa 100644--- a/tests/integration/tests/callbackauthn/03_oidc.py+++ b/tests/integration/tests/callbackauthn/03_oidc.py@@ -49,13 +49,13 @@ def test_create_auth_domain(admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)response = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": "oidc.integration.test",+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "oidc",- "oidcConfig": {+ "kind": "oidc",+ "spec": {"clientId": settings["client_id"],"clientSecret": settings["client_secret"],# Change the hostname of the issuer to the internal resolvable hostname of the idp@@ -122,12 +122,12 @@ def test_oidc_update_domain_with_group_mappings(settings = get_oidc_settings(client_id)response = requests.put(- signoz.self.host_configs["8080"].get(f"/api/v1/domains/{domain['id']}"),+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain['id']}"),json={+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "oidc",- "oidcConfig": {+ "kind": "oidc",+ "spec": {"clientId": settings["client_id"],"clientSecret": settings["client_secret"],"issuer": f"{idp.container.container_configs['6060'].get(urlparse(settings['issuer']).path)}",@@ -140,15 +140,15 @@ def test_oidc_update_domain_with_group_mappings("role": "signoz_role",},},- "roleMapping": {- "defaultRole": "VIEWER",- "groupMappings": {- "signoz-admins": "ADMIN",- "signoz-editors": "EDITOR",- "signoz-viewers": "VIEWER",- },- "useRoleAttribute": False,+ },+ "roleMapping": {+ "defaultRole": "VIEWER",+ "groupMappings": {+ "signoz-admins": "ADMIN",+ "signoz-editors": "EDITOR",+ "signoz-viewers": "VIEWER",},+ "useRoleAttribute": False,},},headers={"Authorization": f"Bearer {admin_token}"},@@ -279,12 +279,12 @@ def test_oidc_update_domain_with_use_role_claim(settings = get_oidc_settings(client_id)response = requests.put(- signoz.self.host_configs["8080"].get(f"/api/v1/domains/{domain['id']}"),+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain['id']}"),json={+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "oidc",- "oidcConfig": {+ "kind": "oidc",+ "spec": {"clientId": settings["client_id"],"clientSecret": settings["client_secret"],"issuer": f"{idp.container.container_configs['6060'].get(urlparse(settings['issuer']).path)}",@@ -297,14 +297,14 @@ def test_oidc_update_domain_with_use_role_claim("role": "signoz_role",},},- "roleMapping": {- "defaultRole": "VIEWER",- "groupMappings": {- "signoz-admins": "ADMIN",- "signoz-editors": "EDITOR",- },- "useRoleAttribute": True,+ },+ "roleMapping": {+ "defaultRole": "VIEWER",+ "groupMappings": {+ "signoz-admins": "ADMIN",+ "signoz-editors": "EDITOR",},+ "useRoleAttribute": True,},},headers={"Authorization": f"Bearer {admin_token}"},diff --git a/tests/integration/tests/callbackauthn/04_google.py b/tests/integration/tests/callbackauthn/04_google.pyindex e4f26a2d87..c06b10ea3e 100644--- a/tests/integration/tests/callbackauthn/04_google.py+++ b/tests/integration/tests/callbackauthn/04_google.py@@ -30,20 +30,20 @@ def test_create_auth_domain(domain = get_google_domain(signoz, admin_token)if domain:response = requests.delete(- signoz.self.host_configs["8080"].get(f"/api/v1/domains/{domain['id']}"),+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain['id']}"),headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)assert response.status_code == HTTPStatus.NO_CONTENTresponse = requests.post(- signoz.self.host_configs["8080"].get("/api/v1/domains"),+ signoz.self.host_configs["8080"].get("/api/v2/auth_domains"),json={"name": GOOGLE_DOMAIN,+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "google_auth",- "googleAuthConfig": {+ "kind": "google",+ "spec": {"clientId": GOOGLE_CLIENT_ID,"clientSecret": GOOGLE_CLIENT_SECRET,},@@ -121,12 +121,12 @@ def test_google_authn_unverified_email(domain = get_google_domain(signoz, admin_token)response = requests.put(- signoz.self.host_configs["8080"].get(f"/api/v1/domains/{domain['id']}"),+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain['id']}"),json={+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "google_auth",- "googleAuthConfig": {+ "kind": "google",+ "spec": {"clientId": GOOGLE_CLIENT_ID,"clientSecret": GOOGLE_CLIENT_SECRET,"insecureSkipEmailVerified": True,@@ -156,18 +156,18 @@ def test_google_role_mapping_default_role(domain = get_google_domain(signoz, admin_token)response = requests.put(- signoz.self.host_configs["8080"].get(f"/api/v1/domains/{domain['id']}"),+ signoz.self.host_configs["8080"].get(f"/api/v2/auth_domains/{domain['id']}"),json={+ "enabled": True,"config": {- "ssoEnabled": True,- "ssoType": "google_auth",- "googleAuthConfig": {+ "kind": "google",+ "spec": {"clientId": GOOGLE_CLIENT_ID,"clientSecret": GOOGLE_CLIENT_SECRET,},- "roleMapping": {- "defaultRole": "EDITOR",- },+ },+ "roleMapping": {+ "defaultRole": "EDITOR",},},headers={"Authorization": f"Bearer {admin_token}"},