From 97ae3b1c26eb58765907c1f6f11bdb07c923154d Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Thu, 24 Aug 2023 16:35:03 +0200 Subject: [PATCH 1/2] added the authentication property to the well known --- MatrixSDK.xcodeproj/project.pbxproj | 12 ++++ .../JSONModels/AutoDiscovery/MXWellKnown.h | 3 + .../JSONModels/AutoDiscovery/MXWellKnown.m | 5 ++ .../AutoDiscovery/MXWellKnownAuthentication.h | 38 +++++++++++ .../AutoDiscovery/MXWellKnownAuthentication.m | 68 +++++++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h create mode 100644 MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m diff --git a/MatrixSDK.xcodeproj/project.pbxproj b/MatrixSDK.xcodeproj/project.pbxproj index e2df01a296..e24eca391a 100644 --- a/MatrixSDK.xcodeproj/project.pbxproj +++ b/MatrixSDK.xcodeproj/project.pbxproj @@ -744,6 +744,10 @@ A0A2397A295202930001F722 /* MXAggregatedPollsUpdater.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0A23978295202930001F722 /* MXAggregatedPollsUpdater.swift */; }; A0B1217F295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0B1217E295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift */; }; A0B12180295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A0B1217E295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift */; }; + A75CAD692A9796DE00F06072 /* MXWellKnownAuthentication.m in Sources */ = {isa = PBXBuildFile; fileRef = A75CAD682A9796DE00F06072 /* MXWellKnownAuthentication.m */; }; + A75CAD6A2A9796DE00F06072 /* MXWellKnownAuthentication.m in Sources */ = {isa = PBXBuildFile; fileRef = A75CAD682A9796DE00F06072 /* MXWellKnownAuthentication.m */; }; + A75CAD6C2A979AC500F06072 /* MXWellKnownAuthentication.h in Headers */ = {isa = PBXBuildFile; fileRef = A75CAD6B2A97970500F06072 /* MXWellKnownAuthentication.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A75CAD6D2A979AC600F06072 /* MXWellKnownAuthentication.h in Headers */ = {isa = PBXBuildFile; fileRef = A75CAD6B2A97970500F06072 /* MXWellKnownAuthentication.h */; settings = {ATTRIBUTES = (Public, ); }; }; A780624E27B2CE74005780C0 /* FileManager+Backup.swift in Sources */ = {isa = PBXBuildFile; fileRef = A780624C27B2CE74005780C0 /* FileManager+Backup.swift */; }; A780624F27B2CE74005780C0 /* FileManager+Backup.swift in Sources */ = {isa = PBXBuildFile; fileRef = A780624C27B2CE74005780C0 /* FileManager+Backup.swift */; }; A780625027B2CE74005780C0 /* FileManager+AppGroupContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A780624D27B2CE74005780C0 /* FileManager+AppGroupContainer.swift */; }; @@ -2705,6 +2709,8 @@ 9274AFE71EE580240009BEB6 /* MXCallKitAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCallKitAdapter.m; sourceTree = ""; }; A0A23978295202930001F722 /* MXAggregatedPollsUpdater.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXAggregatedPollsUpdater.swift; sourceTree = ""; }; A0B1217E295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXAggregatedPollsUpdaterTests.swift; sourceTree = ""; }; + A75CAD682A9796DE00F06072 /* MXWellKnownAuthentication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXWellKnownAuthentication.m; sourceTree = ""; }; + A75CAD6B2A97970500F06072 /* MXWellKnownAuthentication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXWellKnownAuthentication.h; sourceTree = ""; }; A780624C27B2CE74005780C0 /* FileManager+Backup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FileManager+Backup.swift"; sourceTree = ""; }; A780624D27B2CE74005780C0 /* FileManager+AppGroupContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FileManager+AppGroupContainer.swift"; sourceTree = ""; }; A816247B25F60C7700A46F05 /* MXDeviceListOperationsPoolUnitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXDeviceListOperationsPoolUnitTests.swift; sourceTree = ""; }; @@ -3608,6 +3614,8 @@ 32CF439C2371AF9500907C56 /* MXWellknownIntegrations.m */, 180F858227A2AF3000F4E5A5 /* MXWellKnownTileServerConfig.h */, 180F858327A2AF3000F4E5A5 /* MXWellKnownTileServerConfig.m */, + A75CAD682A9796DE00F06072 /* MXWellKnownAuthentication.m */, + A75CAD6B2A97970500F06072 /* MXWellKnownAuthentication.h */, ); path = AutoDiscovery; sourceTree = ""; @@ -6152,6 +6160,7 @@ 3287164F23C4C11F00D720CA /* MXKeyVerificationManager_Private.h in Headers */, 32F634AB1FC5E3480054EF49 /* MXEventDecryptionResult.h in Headers */, 32999DE322DCD1AD004FF987 /* MXPusherData.h in Headers */, + A75CAD6C2A979AC500F06072 /* MXWellKnownAuthentication.h in Headers */, 3284A5A01DB7C00600A09972 /* MXCryptoStore.h in Headers */, 32442FB121EDD21300D2411B /* MXKeyBackupPassword.h in Headers */, 3259CD531DF860C300186944 /* MXRealmCryptoStore.h in Headers */, @@ -6518,6 +6527,7 @@ EC8A53DD25B1BCC6004E0802 /* MXThirdPartyProtocol.h in Headers */, ECF29BDF264195320053E6D6 /* MXAssertedIdentityModel.h in Headers */, B14EF31A2397E90400758AF0 /* MXScanRealmProvider.h in Headers */, + A75CAD6D2A979AC600F06072 /* MXWellKnownAuthentication.h in Headers */, 32549AFA23F2E2790002576B /* MXKeyVerificationReady.h in Headers */, B14EF31B2397E90400758AF0 /* MXEventUnsignedData.h in Headers */, B14EF31C2397E90400758AF0 /* MXEventEditsListener.h in Headers */, @@ -7191,6 +7201,7 @@ A780625027B2CE74005780C0 /* FileManager+AppGroupContainer.swift in Sources */, 9274AFE91EE580240009BEB6 /* MXCallKitAdapter.m in Sources */, 3274538C23FD918800438328 /* MXKeyVerificationByToDeviceRequest.m in Sources */, + A75CAD692A9796DE00F06072 /* MXWellKnownAuthentication.m in Sources */, ED6DAC1828C799E300ECDCB6 /* MXRoomKeyResult.swift in Sources */, ECB6FA952683811800A941E4 /* MXiOSAudioOutputRouter.swift in Sources */, EC131B0A2758D56600712964 /* MXThreadNotificationsCount.swift in Sources */, @@ -7862,6 +7873,7 @@ A780625127B2CE74005780C0 /* FileManager+AppGroupContainer.swift in Sources */, B14EF23B2397E90400758AF0 /* MXKeyBackupData.m in Sources */, B14EF23C2397E90400758AF0 /* MXJSONModels.m in Sources */, + A75CAD6A2A9796DE00F06072 /* MXWellKnownAuthentication.m in Sources */, EC8A538E25B1BC77004E0802 /* MXCallSessionDescription.m in Sources */, ED6DAC1928C799E300ECDCB6 /* MXRoomKeyResult.swift in Sources */, EC131B0B2758D56600712964 /* MXThreadNotificationsCount.swift in Sources */, diff --git a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnown.h b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnown.h index b4a5d5ab3d..50ade7611a 100644 --- a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnown.h +++ b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnown.h @@ -20,6 +20,7 @@ #import "MXWellKnownBaseConfig.h" #import "MXWellknownIntegrations.h" #import "MXWellKnownTileServerConfig.h" +#import "MXWellKnownAuthentication.h" NS_ASSUME_NONNULL_BEGIN @@ -45,6 +46,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, nullable) MXWellKnownTileServerConfig *tileServer; +@property (nonatomic, nullable) MXWellKnownAuthentication *authentication; + @end NS_ASSUME_NONNULL_END diff --git a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnown.m b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnown.m index fd4fde1686..181418d603 100644 --- a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnown.m +++ b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnown.m @@ -23,6 +23,8 @@ static NSString *const kMXTileServerKey = @"m.tile_server"; static NSString *const kMXTileServerMSC3488Key = @"org.matrix.msc3488.tile_server"; +static NSString *const kMXAuthenticationKey = @"org.matrix.msc2965.authentication"; + @interface MXWellKnown() { // The original dictionary to store extented data @@ -46,6 +48,7 @@ + (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary MXJSONModelSetMXJSONModel(wellknown.identityServer, MXWellKnownBaseConfig, JSONDictionary[kMXIdentityServerKey]); MXJSONModelSetMXJSONModel(wellknown.integrations, MXWellknownIntegrations, JSONDictionary[kMXIntegrationsKey]); + MXJSONModelSetMXJSONModel(wellknown.authentication, MXWellKnownAuthentication, JSONDictionary[kMXAuthenticationKey]) if (JSONDictionary[kMXTileServerKey]) { @@ -84,6 +87,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder _identityServer = [aDecoder decodeObjectForKey:kMXIdentityServerKey]; _integrations = [aDecoder decodeObjectForKey:kMXIntegrationsKey]; _tileServer = [aDecoder decodeObjectForKey:kMXTileServerKey]; + _authentication = [aDecoder decodeObjectForKey:kMXAuthenticationKey]; JSONDictionary = [aDecoder decodeObjectForKey:@"JSONDictionary"]; } return self; @@ -95,6 +99,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder [aCoder encodeObject:_identityServer forKey:kMXIdentityServerKey]; [aCoder encodeObject:_integrations forKey:kMXIntegrationsKey]; [aCoder encodeObject:_tileServer forKey:kMXTileServerKey]; + [aCoder encodeObject:_authentication forKey:kMXAuthenticationKey]; [aCoder encodeObject:JSONDictionary forKey:@"JSONDictionary"]; } diff --git a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h new file mode 100644 index 0000000000..b224edf4ef --- /dev/null +++ b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h @@ -0,0 +1,38 @@ +// +// Copyright 2023 The Matrix.org Foundation C.I.C +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import + +#import "MXJSONModel.h" + +NS_ASSUME_NONNULL_BEGIN + +/** + MSC2965: OIDC Authentication + "org.matrix.msc2965.authentication": { + "issuer": "https://example.com/", + "account": "https://example.com/account" + } + */ + +@interface MXWellKnownAuthentication : MXJSONModel + +@property (nonatomic, readonly) NSString *issuer; +@property (nonatomic, readonly, nullable) NSString *account; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m new file mode 100644 index 0000000000..2cce0def79 --- /dev/null +++ b/MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m @@ -0,0 +1,68 @@ +// +// Copyright 2023 The Matrix.org Foundation C.I.C +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#import "MXWellKnownAuthentication.h" + +static NSString *const kMXIssuer = @"issuer"; +static NSString *const kMXAccount = @"account"; + +@interface MXWellKnownAuthentication () + +@property (nonatomic, readwrite) NSString *issuer; +@property (nonatomic, readwrite, nullable) NSString *account; + +@end + +@implementation MXWellKnownAuthentication + ++ (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary +{ + MXWellKnownAuthentication *wellKnownAuthentication; + + NSString *issuer; + MXJSONModelSetString(issuer, JSONDictionary[kMXIssuer]); + + if (issuer) + { + wellKnownAuthentication = [[MXWellKnownAuthentication alloc] init]; + wellKnownAuthentication.issuer = issuer; + MXJSONModelSetString(wellKnownAuthentication.account, JSONDictionary[kMXAccount]) + } + + return wellKnownAuthentication; +} + + +#pragma mark - NSCoding + +- (id)initWithCoder:(NSCoder *)aDecoder +{ + self = [super init]; + if (self) + { + _issuer = [aDecoder decodeObjectForKey:kMXIssuer]; + _account = [aDecoder decodeObjectForKey: kMXAccount]; + } + return self; +} + +- (void)encodeWithCoder:(NSCoder *)aCoder +{ + [aCoder encodeObject:_issuer forKey:kMXIssuer]; + [aCoder encodeObject:_account forKey:kMXAccount]; +} + +@end From 099bc056d4d3a68203fdae3291778259c9833b23 Mon Sep 17 00:00:00 2001 From: Mauro Romito Date: Thu, 24 Aug 2023 17:16:07 +0200 Subject: [PATCH 2/2] changelog --- changelog.d/pr-1812.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/pr-1812.feature diff --git a/changelog.d/pr-1812.feature b/changelog.d/pr-1812.feature new file mode 100644 index 0000000000..fcdc1871db --- /dev/null +++ b/changelog.d/pr-1812.feature @@ -0,0 +1 @@ +Added the authentication property to the well known. \ No newline at end of file