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

Support multiple SSO Identity Providers (MSC2858) #965

Merged
merged 10 commits into from
Dec 8, 2020

Conversation

SBiOSoftWhare
Copy link
Contributor

CHANGES.rst Outdated

🐛 Bugfix
*

⚠️ API Changes
*
* Add MXLoginSSOFlow which represents a SSO login flow and offers multiple SSO Identity Providers through MXLoginSSOIdentityProvider class.
Copy link
Contributor

@manuroe manuroe Dec 4, 2020

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this

Comment on lines 34 to 35
MXJSONModelSetString(loginFlow.type, JSONDictionary[@"type"]);
MXJSONModelSetArray(loginFlow.stages, JSONDictionary[@"stages"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we delegate this parsing to the superclass? I mean with another method like parseJSON: in MXLoginfFlow. My concern is that If another property added to MXLoginFlow, we'll have to maintain this one also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes he have an architecture problem. Here the class method is not really convenient. Member method like other libs would help to make calls to super implementation.
In MXLoginSSOFlow Now we can do something like:

+ (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary
{
    MXLoginSSOFlow *loginFlow = [super modelFromJSON:JSONDictionary];

And in MXLoginFlow we should have:

+ (instancetype)modelFromJSON:(NSDictionary *)JSONDictionary
{
    MXLoginSSOFlow *loginFlow = [self new];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this seems better.


MXLoginSSOIdentityProvider *identityProvider = [MXLoginSSOIdentityProvider new];

if (identityProvider && identifier && name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have two concerns.

  1. We're declaring that identifier and name will be non-nil with NS_ASSUME_NONNULL_BEGIN, but if they are nil after parsing, we still return them nil here.
  2. This introduces some logic in a model class, which doesn't seem to be a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I should return nil in this case. In the MSC identifier && name have to be non optional.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks.


NSString *type;

MXJSONModelSetString(type, JSONDictionary[@"type"]);
Copy link
Contributor

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 exposing the name of type field outside of MXLoginFlow class. Maybe we can define an extern variable for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be avoided after #965 (comment)

/**
`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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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.


if let ssoFlow = flows.first(where: { $0.type == kMXLoginFlowTypeSSO }) {

if let loginSSOFlow = ssoFlow as? MXLoginSSOFlow {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what i wanted to avoid on above comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He have to differentiate m.login.sso from m.login.cas they are both the same kind of flow but not exactly the same :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will continue as the same, explained in #965 (comment)

@SBiOSoftWhare SBiOSoftWhare merged commit 1dbdab6 into develop Dec 8, 2020
@SBiOSoftWhare SBiOSoftWhare deleted the element_3846 branch December 8, 2020 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants