-
Notifications
You must be signed in to change notification settings - Fork 226
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
Changes from 6 commits
9e8265f
635ca87
fdddd1c
5e1c2b5
f1d97ed
6d3a643
4af2f04
ba27f33
2be16f6
d4421d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, let's continue as is then. thanks for the explanation. |
||
|
|
||
| /** | ||
| List of all SSO Identity Providers supported | ||
| */ | ||
| @property (nonatomic, readonly) NSArray<MXLoginSSOIdentityProvider*> *identityProviders; | ||
|
|
||
| @end | ||
|
|
||
| NS_ASSUME_NONNULL_END | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // | ||
| // 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 | ||
|
|
||
| + (id)modelFromJSON:(NSDictionary *)JSONDictionary | ||
| { | ||
| MXLoginSSOFlow *loginFlow = [MXLoginSSOFlow new]; | ||
| if (loginFlow) | ||
| { | ||
| MXJSONModelSetString(loginFlow.type, JSONDictionary[@"type"]); | ||
| MXJSONModelSetArray(loginFlow.stages, JSONDictionary[@"stages"]); | ||
|
||
|
|
||
| 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 | ||
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // | ||
| // 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 | ||
|
|
||
| + (id)modelFromJSON:(NSDictionary *)JSONDictionary | ||
| { | ||
| NSString *identifier; | ||
| NSString *name; | ||
|
|
||
| MXJSONModelSetString(identifier, JSONDictionary[@"id"]); | ||
| MXJSONModelSetString(name, JSONDictionary[@"name"]); | ||
|
|
||
| MXLoginSSOIdentityProvider *identityProvider = [MXLoginSSOIdentityProvider new]; | ||
|
|
||
| if (identityProvider && identifier && name) | ||
|
||
| { | ||
| identityProvider.identifier = identifier; | ||
| identityProvider.name = name; | ||
| MXJSONModelSetString(identityProvider.icon, JSONDictionary[@"icon"]); | ||
| } | ||
|
|
||
| return identityProvider; | ||
| } | ||
|
|
||
| @end | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
We usually use the API changes section for api breaks.
It will be annoying if we start to describe every new api here.
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 agree this