Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the authentication property to the well known #1812

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions MatrixSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -2705,6 +2709,8 @@
9274AFE71EE580240009BEB6 /* MXCallKitAdapter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MXCallKitAdapter.m; sourceTree = "<group>"; };
A0A23978295202930001F722 /* MXAggregatedPollsUpdater.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXAggregatedPollsUpdater.swift; sourceTree = "<group>"; };
A0B1217E295306F700E704C2 /* MXAggregatedPollsUpdaterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXAggregatedPollsUpdaterTests.swift; sourceTree = "<group>"; };
A75CAD682A9796DE00F06072 /* MXWellKnownAuthentication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MXWellKnownAuthentication.m; sourceTree = "<group>"; };
A75CAD6B2A97970500F06072 /* MXWellKnownAuthentication.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MXWellKnownAuthentication.h; sourceTree = "<group>"; };
A780624C27B2CE74005780C0 /* FileManager+Backup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FileManager+Backup.swift"; sourceTree = "<group>"; };
A780624D27B2CE74005780C0 /* FileManager+AppGroupContainer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "FileManager+AppGroupContainer.swift"; sourceTree = "<group>"; };
A816247B25F60C7700A46F05 /* MXDeviceListOperationsPoolUnitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MXDeviceListOperationsPoolUnitTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3608,6 +3614,8 @@
32CF439C2371AF9500907C56 /* MXWellknownIntegrations.m */,
180F858227A2AF3000F4E5A5 /* MXWellKnownTileServerConfig.h */,
180F858327A2AF3000F4E5A5 /* MXWellKnownTileServerConfig.m */,
A75CAD682A9796DE00F06072 /* MXWellKnownAuthentication.m */,
A75CAD6B2A97970500F06072 /* MXWellKnownAuthentication.h */,
);
path = AutoDiscovery;
sourceTree = "<group>";
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
3 changes: 3 additions & 0 deletions MatrixSDK/JSONModels/AutoDiscovery/MXWellKnown.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import "MXWellKnownBaseConfig.h"
#import "MXWellknownIntegrations.h"
#import "MXWellKnownTileServerConfig.h"
#import "MXWellKnownAuthentication.h"

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -45,6 +46,8 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, nullable) MXWellKnownTileServerConfig *tileServer;

@property (nonatomic, nullable) MXWellKnownAuthentication *authentication;

@end

NS_ASSUME_NONNULL_END
5 changes: 5 additions & 0 deletions MatrixSDK/JSONModels/AutoDiscovery/MXWellKnown.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
{
Expand Down Expand Up @@ -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;
Expand All @@ -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"];
}

Expand Down
38 changes: 38 additions & 0 deletions MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h
Original file line number Diff line number Diff line change
@@ -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 <Foundation/Foundation.h>

#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<NSCoding>

@property (nonatomic, readonly) NSString *issuer;
@property (nonatomic, readonly, nullable) NSString *account;

@end

NS_ASSUME_NONNULL_END
68 changes: 68 additions & 0 deletions MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions changelog.d/pr-1812.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added the authentication property to the well known.
Loading