From be00e3861a95ada736a551dc5cf338c6ba97c694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20M=C3=B6hlmann?= Date: Tue, 16 Apr 2024 11:34:38 +0300 Subject: [PATCH] fix(oidc): make device auth audience and scope nullable (#7777) This fixes the projection of events that have a null audience or scope. As audience was added in v2.50, legacy events do not have an audience, this made replay of the old events not possible after an upgrade. --- internal/query/device_auth_test.go | 16 ++++++++-------- internal/query/projection/device_auth.go | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/query/device_auth_test.go b/internal/query/device_auth_test.go index de123a3a78..d9773cdc7f 100644 --- a/internal/query/device_auth_test.go +++ b/internal/query/device_auth_test.go @@ -169,15 +169,15 @@ func TestQueries_DeviceAuthByDeviceCode(t *testing.T) { const ( expectedDeviceAuthQueryC = `SELECT` + - ` projections.device_auth_requests1.client_id,` + - ` projections.device_auth_requests1.device_code,` + - ` projections.device_auth_requests1.user_code,` + - ` projections.device_auth_requests1.scopes,` + - ` projections.device_auth_requests1.audience` + - ` FROM projections.device_auth_requests1` + ` projections.device_auth_requests2.client_id,` + + ` projections.device_auth_requests2.device_code,` + + ` projections.device_auth_requests2.user_code,` + + ` projections.device_auth_requests2.scopes,` + + ` projections.device_auth_requests2.audience` + + ` FROM projections.device_auth_requests2` expectedDeviceAuthWhereUserCodeQueryC = expectedDeviceAuthQueryC + - ` WHERE projections.device_auth_requests1.instance_id = $1` + - ` AND projections.device_auth_requests1.user_code = $2` + ` WHERE projections.device_auth_requests2.instance_id = $1` + + ` AND projections.device_auth_requests2.user_code = $2` ) var ( diff --git a/internal/query/projection/device_auth.go b/internal/query/projection/device_auth.go index 88cc127f05..4fd3be5510 100644 --- a/internal/query/projection/device_auth.go +++ b/internal/query/projection/device_auth.go @@ -11,7 +11,7 @@ import ( ) const ( - DeviceAuthRequestProjectionTable = "projections.device_auth_requests1" + DeviceAuthRequestProjectionTable = "projections.device_auth_requests2" DeviceAuthRequestColumnClientID = "client_id" DeviceAuthRequestColumnDeviceCode = "device_code" @@ -44,8 +44,8 @@ func (*deviceAuthRequestProjection) Init() *old_handler.Check { handler.NewColumn(DeviceAuthRequestColumnClientID, handler.ColumnTypeText), handler.NewColumn(DeviceAuthRequestColumnDeviceCode, handler.ColumnTypeText), handler.NewColumn(DeviceAuthRequestColumnUserCode, handler.ColumnTypeText), - handler.NewColumn(DeviceAuthRequestColumnScopes, handler.ColumnTypeTextArray), - handler.NewColumn(DeviceAuthRequestColumnAudience, handler.ColumnTypeTextArray), + handler.NewColumn(DeviceAuthRequestColumnScopes, handler.ColumnTypeTextArray, handler.Nullable()), + handler.NewColumn(DeviceAuthRequestColumnAudience, handler.ColumnTypeTextArray, handler.Nullable()), handler.NewColumn(DeviceAuthRequestColumnCreationDate, handler.ColumnTypeTimestamp), handler.NewColumn(DeviceAuthRequestColumnChangeDate, handler.ColumnTypeTimestamp), handler.NewColumn(DeviceAuthRequestColumnSequence, handler.ColumnTypeInt64),