-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the authentication property to the well known
- Loading branch information
Showing
5 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
68
MatrixSDK/JSONModels/AutoDiscovery/MXWellKnownAuthentication.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |