mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 23:32:41 +00:00
Authentication: Create a way to filter and prioritise flows (with handleSupportedFlowsInAuthenticationSession).
This commit is contained in:
parent
2e86379b2a
commit
76923cae11
2 changed files with 53 additions and 0 deletions
|
@ -3,6 +3,7 @@ Changes in 0.9.3 (2019-09-10)
|
||||||
|
|
||||||
Improvements:
|
Improvements:
|
||||||
* Support Riot configuration link to customise HS and IS (#2703).
|
* Support Riot configuration link to customise HS and IS (#2703).
|
||||||
|
* Authentication: Create a way to filter and prioritise flows (with handleSupportedFlowsInAuthenticationSession).
|
||||||
|
|
||||||
Changes in 0.9.2 (2019-08-08)
|
Changes in 0.9.2 (2019-08-08)
|
||||||
===============================================
|
===============================================
|
||||||
|
|
|
@ -497,9 +497,61 @@
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Filter and prioritise flows supported by the app.
|
||||||
|
|
||||||
|
@param authSession the auth session coming from the HS.
|
||||||
|
@return a new auth session
|
||||||
|
*/
|
||||||
|
- (MXAuthenticationSession*)handleSupportedFlowsInAuthenticationSession:(MXAuthenticationSession *)authSession
|
||||||
|
{
|
||||||
|
MXLoginFlow *ssoFlow;
|
||||||
|
NSMutableArray *supportedFlows = [NSMutableArray array];
|
||||||
|
|
||||||
|
for (MXLoginFlow *flow in authSession.flows)
|
||||||
|
{
|
||||||
|
// Remove known flows we do not support
|
||||||
|
if (![flow.type isEqualToString:kMXLoginFlowTypeToken])
|
||||||
|
{
|
||||||
|
NSLog(@"[AuthenticationVC] handleSupportedFlowsInAuthenticationSession: Filter out flow %@", flow.type);
|
||||||
|
[supportedFlows addObject:flow];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prioritise SSO over other flows
|
||||||
|
if ([flow.type isEqualToString:kMXLoginFlowTypeSSO]
|
||||||
|
|| [flow.type isEqualToString:kMXLoginFlowTypeCAS])
|
||||||
|
{
|
||||||
|
NSLog(@"[AuthenticationVC] handleSupportedFlowsInAuthenticationSession: Prioritise flow %@", flow.type);
|
||||||
|
ssoFlow = flow;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ssoFlow)
|
||||||
|
{
|
||||||
|
[supportedFlows removeAllObjects];
|
||||||
|
[supportedFlows addObject:ssoFlow];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (supportedFlows.count != authSession.flows.count)
|
||||||
|
{
|
||||||
|
MXAuthenticationSession *updatedAuthSession = [[MXAuthenticationSession alloc] init];
|
||||||
|
updatedAuthSession.session = authSession.session;
|
||||||
|
updatedAuthSession.params = authSession.params;
|
||||||
|
updatedAuthSession.flows = supportedFlows;
|
||||||
|
return updatedAuthSession;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return authSession;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)handleAuthenticationSession:(MXAuthenticationSession *)authSession
|
- (void)handleAuthenticationSession:(MXAuthenticationSession *)authSession
|
||||||
{
|
{
|
||||||
|
// Make some cleaning from the server response according to what the app supports
|
||||||
|
authSession = [self handleSupportedFlowsInAuthenticationSession:authSession];
|
||||||
|
|
||||||
[super handleAuthenticationSession:authSession];
|
[super handleAuthenticationSession:authSession];
|
||||||
|
|
||||||
AuthInputsView *authInputsview;
|
AuthInputsView *authInputsview;
|
||||||
|
|
Loading…
Reference in a new issue