-
Notifications
You must be signed in to change notification settings - Fork 221
Support multiple SSO Identity Providers (MSC2858) #965
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9e8265f
Add MXLoginSSOIdentityProvider that represents a SSO Identity Provide…
SBiOSoftWhare 635ca87
Add MXLoginSSOFlow that represents a SSO login or a register flow sup…
SBiOSoftWhare fdddd1c
MXAuthenticationSession: Add MXLoginSSOFlow class support in `flows` …
SBiOSoftWhare 5e1c2b5
Add MXAuthenticationSessionTests to perform parsing tests with new SS…
SBiOSoftWhare f1d97ed
Update pbxproj
SBiOSoftWhare 6d3a643
Update changes
SBiOSoftWhare 4af2f04
MXLoginSSOFlow: Improve inheritance.
SBiOSoftWhare ba27f33
MXLoginSSOIdentityProvider: Update JSON parsing method.
SBiOSoftWhare 2be16f6
Update changes
SBiOSoftWhare d4421d6
Merge branch 'develop' into element_3846
SBiOSoftWhare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,37 @@ | ||
// | ||
// Copyright 2020 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 "MXJSONModels.h" | ||
#import "MXLoginSSOIdentityProvider.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
extern NSString *const MXLoginSSOFlowIdentityProvidersKey; | ||
|
||
/** | ||
`MXLoginSSOFlow` represents a SSO login or a register flow supported by the home server (See MSC2858 https://github.com/matrix-org/matrix-doc/pull/2858). | ||
*/ | ||
@interface MXLoginSSOFlow : MXLoginFlow | ||
|
||
/** | ||
List of all SSO Identity Providers supported | ||
*/ | ||
@property (nonatomic, readonly) NSArray<MXLoginSSOIdentityProvider*> *identityProviders; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains hidden or 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,58 @@ | ||
// | ||
// Copyright 2020 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 "MXLoginSSOFlow.h" | ||
|
||
NSString *const MXLoginSSOFlowIdentityProvidersKey = @"identity_providers"; | ||
|
||
@interface MXLoginSSOFlow() | ||
|
||
@property (nonatomic, readwrite) NSArray<MXLoginSSOIdentityProvider*> *identityProviders; | ||
|
||
@end | ||
|
||
@implementation MXLoginSSOFlow | ||
|
||
+ (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary | ||
{ | ||
MXLoginSSOFlow *loginFlow = [super modelFromJSON:JSONDictionary]; | ||
|
||
if (loginFlow) | ||
{ | ||
NSArray *jsonIdentityProdivers; | ||
|
||
MXJSONModelSetArray(jsonIdentityProdivers, JSONDictionary[MXLoginSSOFlowIdentityProvidersKey]); | ||
|
||
NSArray<MXLoginSSOIdentityProvider*> *identityProviders; | ||
|
||
if (jsonIdentityProdivers) | ||
{ | ||
identityProviders = [MXLoginSSOIdentityProvider modelsFromJSON:jsonIdentityProdivers]; | ||
} | ||
|
||
if (!identityProviders) | ||
{ | ||
identityProviders = [NSArray new]; | ||
} | ||
|
||
loginFlow.identityProviders = identityProviders; | ||
|
||
} | ||
|
||
return loginFlow; | ||
} | ||
|
||
@end |
This file contains hidden or 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,44 @@ | ||
// | ||
// Copyright 2020 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 | ||
|
||
/** | ||
`MXLoginSSOIdentityProvider` represents a SSO Identity Provider as described in MSC2858 (See https://github.com/matrix-org/matrix-doc/pull/2858) | ||
*/ | ||
@interface MXLoginSSOIdentityProvider : MXJSONModel | ||
|
||
/** | ||
The identifier field (id field in JSON) is the Identity Provider identifier used for the SSO Web page redirection `/login/sso/redirect/{idp_id}`. | ||
*/ | ||
@property (nonatomic, readonly) NSString *identifier; | ||
|
||
/** | ||
The name field is a human readable string intended to be printed by the client. | ||
*/ | ||
@property (nonatomic, readonly) NSString *name; | ||
|
||
/** | ||
The icon field is an optional field that points to an icon representing the identity provider. If present then it must be an HTTPS URL to an image resource. | ||
*/ | ||
@property (nonatomic, readonly, nullable) NSString *icon; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains hidden or 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,51 @@ | ||
// | ||
// Copyright 2020 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 "MXLoginSSOIdentityProvider.h" | ||
|
||
@interface MXLoginSSOIdentityProvider() | ||
|
||
@property (nonatomic, readwrite) NSString *identifier; | ||
@property (nonatomic, readwrite) NSString *name; | ||
@property (nonatomic, readwrite, nullable) NSString *icon; | ||
|
||
@end | ||
|
||
@implementation MXLoginSSOIdentityProvider | ||
|
||
+ (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary | ||
{ | ||
NSString *identifier; | ||
NSString *name; | ||
|
||
MXJSONModelSetString(identifier, JSONDictionary[@"id"]); | ||
MXJSONModelSetString(name, JSONDictionary[@"name"]); | ||
|
||
MXLoginSSOIdentityProvider *identityProvider; | ||
|
||
if (identifier && name) | ||
{ | ||
identityProvider = [MXLoginSSOIdentityProvider new]; | ||
|
||
identityProvider.identifier = identifier; | ||
identityProvider.name = name; | ||
MXJSONModelSetString(identityProvider.icon, JSONDictionary[@"icon"]); | ||
} | ||
|
||
return identityProvider; | ||
} | ||
|
||
@end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very comfortable with the existence of this class and deciding that a flow is SSO or not by class check. Why don't we reuse
MXLoginFlow
for that? And maybe a method like-(BOOL) isSSo
, which checks the type.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the same as Web implementation only expose relevant properties for dedicated flow. It's not a really good idea either to expose a lot of properties that can be nil or not and used in only one case.
In MXLoginSSOFlow case we expose the identity providers list can't be nil. And you know that is useful only in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Web implementation here https://github.com/matrix-org/matrix-react-sdk/blob/8593845e3d1120bb8d9f7f9744f4d9a3a809a578/src/Login.ts#L42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's continue as is then. thanks for the explanation.