Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tal-mi committed Jun 3, 2024
2 parents 7f4f103 + 9254082 commit 6017a06
Show file tree
Hide file tree
Showing 17 changed files with 149 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.0.6
1.0.6

* Added "getAuthCode" interface used to obtain a session exchange code with WebSDK.

# 1.0.5
1.0.5

Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,29 @@ To initiate the SSO request flow, run the following snippet.
});
```

**Note:**
When using mobile SSO (single sign-on using the central login page), logging out using the SDK's logout method will only log the user out of the current API key used.
The user will not be logged out of the other group sites.

## Session Exchange Between Mobile & WebView

Applications (mobile/web) within the same site group are now able to share a session from the mobile application to a web page running the JS SDK.

Follow these steps to allow session exchange:

1. Use the “getAuthCode” interface. This call will provide you with the required code that the web page will require for the exchange.
```dart
final String? result = await widget.sdk.getAuthCode();
```

2. Add these URL parameters to your hosted page/website URL using the provided code:
*** https://page-url?authCode=code&gig_actions=sso.login ***

3. Make sure that the WebView element you are using to open the URL has JavaScript enabled.

4. Once the page is loaded, the JS SDK will exchange the token provided for a valid session.


## FIDO/WebAuthn Authentication
FIDO is a passwordless authentication method that allows password-only logins to be replaced with secure and fast login experiences across websites and apps.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class GigyaFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, Scre
"biometricOptOut" -> sdk.biometricOptOut(call.arguments, result)
"biometricLockSession" -> sdk.biometricLockSession(result)
"biometricUnlockSession" -> sdk.biometricUnlockSession (call.arguments, result)
"getAuthCode" -> sdk.getAuthCode(result)
else -> result.notImplemented()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ import com.gigya.android.sdk.api.IApiRequestFactory
import com.gigya.android.sdk.auth.GigyaAuth
import com.gigya.android.sdk.auth.GigyaOTPCallback
import com.gigya.android.sdk.auth.resolvers.IGigyaOtpResult
import com.gigya.android.sdk.containers.GigyaContainer
import com.gigya.android.sdk.interruption.IPendingRegistrationResolver
import com.gigya.android.sdk.interruption.link.ILinkAccountsResolver
import com.gigya.android.sdk.biometric.GigyaBiometric
import com.gigya.android.sdk.biometric.GigyaPromptInfo
import com.gigya.android.sdk.biometric.IGigyaBiometricCallback
import com.gigya.android.sdk.interruption.IPendingRegistrationResolver
import com.gigya.android.sdk.interruption.link.ILinkAccountsResolver
import com.gigya.android.sdk.network.GigyaError
import com.gigya.android.sdk.session.SessionInfo
import com.gigya.android.sdk.ui.plugin.GigyaPluginEvent
import com.gigya.android.sdk.ui.plugin.GigyaWebBridge
import com.gigya.android.sdk.ui.plugin.IGigyaWebBridge
import com.gigya.android.sdk.utils.CustomGSONDeserializer
import com.google.gson.GsonBuilder
Expand Down Expand Up @@ -667,7 +665,24 @@ class GigyaSDKWrapper<T : GigyaAccount>(application: Application, accountObj: Cl
})
}

fun getAuthCode(channelResult: MethodChannel.Result) {
sdk.getAuthCode(object : GigyaCallback<String>() {
override fun onSuccess(code: String) {
channelResult.success(code)
}

override fun onError(error: GigyaError) {
channelResult.error(
error.errorCode.toString(),
error.localizedMessage,
mapJson(error.data)
)
}
})
}

//endregion

//region SCREENSETS

/**
Expand Down
28 changes: 14 additions & 14 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
PODS:
- AppAuth (1.6.2):
- AppAuth/Core (= 1.6.2)
- AppAuth/ExternalUserAgent (= 1.6.2)
- AppAuth/Core (1.6.2)
- AppAuth/ExternalUserAgent (1.6.2):
- AppAuth (1.7.5):
- AppAuth/Core (= 1.7.5)
- AppAuth/ExternalUserAgent (= 1.7.5)
- AppAuth/Core (1.7.5)
- AppAuth/ExternalUserAgent (1.7.5):
- AppAuth/Core
- Flutter (1.0.0)
- Gigya (1.5.8)
- Gigya (1.6.2)
- gigya_flutter_plugin (1.0.0):
- Flutter
- Gigya (>= 1.5.8)
- GigyaAuth (>= 1.1.1)
- GigyaAuth (1.1.1):
- Gigya (>= 1.2.0)
- Gigya (>= 1.6.2)
- GigyaAuth (>= 1.1.2)
- GigyaAuth (1.1.2):
- Gigya (>= 1.6.0)
- google_sign_in_ios (0.0.1):
- Flutter
- GoogleSignIn (~> 6.2)
Expand Down Expand Up @@ -48,11 +48,11 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/google_sign_in_ios/ios"

SPEC CHECKSUMS:
AppAuth: 3bb1d1cd9340bd09f5ed189fb00b1cc28e1e8570
AppAuth: 501c04eda8a8d11f179dbe8637b7a91bb7e5d2fa
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Gigya: 8e698005fa73eea2f45755f40967277620764f72
gigya_flutter_plugin: 4c7df0b8bcb69f72ab53bc200d10d17c4fd8f837
GigyaAuth: 0ffdf8aea1f562fc09d34ded9930b57e41308fd7
Gigya: 0e6fa3447def67739461c489305cd1a82278857d
gigya_flutter_plugin: d0b75ee89ad68a01978c349d96e238e6582579d3
GigyaAuth: 32cd49aa9eb380275ad10d85543a90ce326fe4fb
google_sign_in_ios: 1256ff9d941db546373826966720b0c24804bcdd
GoogleSignIn: 5651ce3a61e56ca864160e79b484cd9ed3f49b7a
GTMAppAuth: 0ff230db599948a9ad7470ca667337803b3fc4dd
Expand Down
36 changes: 36 additions & 0 deletions example/lib/routes/account_information_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ class _AccountInformationPageState extends State<AccountInformationPage>
padding: const EdgeInsets.all(8.0),
child: _buildRevokePasskeyButton(),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: _buildGetAuthCodeButton(),
),
],
),
);
Expand Down Expand Up @@ -200,6 +204,38 @@ class _AccountInformationPageState extends State<AccountInformationPage>
);
}

Widget _buildGetAuthCodeButton() {
return ElevatedButton(
onPressed: () async {
setState(() {
_inProgress = true;
});

try {
final String? result =
await widget.sdk.getAuthCode();

print('GetAuth code $result');

if (mounted) {
setState(() {
_inProgress = false;
});
}
} catch (error) {
print('GetAuth error: $error');

if (mounted) {
setState(() {
_inProgress = false;
});
}
}
},
child: const Text('Get Auth Code'),
);
}

@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.4"
version: "1.0.5"
google_sign_in:
dependency: "direct main"
description:
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: gigya_flutter_plugin_example
description: Demonstrates how to use the gigya_flutter_plugin plugin.
version: 1.0.5
version: 1.0.6
homepage: https://www.sap.com
publish_to: none

Expand Down
3 changes: 2 additions & 1 deletion ios/Classes/GigyaSdkMethods.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public enum GigyaSdkMethods: String {

// Login using a Social Provider / Single-Sign-On.
case socialLogin
case sso
case sso
case getAuthCode

// Web Authentication.
case webAuthnLogin
Expand Down
17 changes: 16 additions & 1 deletion ios/Classes/GigyaSdkWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {

init(accountSchema: T.Type) {
// Initializing the Gigya SDK instance.
GigyaDefinitions.versionPrefix = "flutter_1.0.5_"
GigyaDefinitions.versionPrefix = "flutter_1.0.6_"
sdk = Gigya.sharedInstance(accountSchema)
GigyaAuth.shared.register(scheme: accountSchema)
}
Expand Down Expand Up @@ -335,6 +335,21 @@ public class GigyaSdkWrapper<T: GigyaAccountProtocol> :GigyaInstanceProtocol {
}
}
}

/*
Get Auth Code
*/
func getAuthCode(result: @escaping FlutterResult) {
sdk?.getAuthCode() { res in
switch res {
case .success(let code):
result(code)
case .failure(let error):
result(PluginErrors.wrapNetworkError(error: error))
}
}
}


func addConnection(arguments: [String: Any], result: @escaping FlutterResult) {
guard let viewController = getDisplayedViewController()
Expand Down
3 changes: 3 additions & 0 deletions ios/Classes/SwiftGigyaFlutterPluginTyped.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public class SwiftGigyaFlutterPluginTyped<T: GigyaAccountProtocol> : NSObject, F
case .biometricUnlockSession:
sdk?.biometricUnlockSession(result: result)
return
case .getAuthCode:
sdk?.getAuthCode(result: result)
return
default:
break
}
Expand Down
2 changes: 1 addition & 1 deletion ios/gigya_flutter_plugin.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.dependency 'Gigya', '>= 1.6.0'
s.dependency 'Gigya', '>= 1.6.2'
s.dependency 'GigyaAuth', '>= 1.1.2'
s.platform = :ios, '13.0'

Expand Down
5 changes: 5 additions & 0 deletions lib/gigya_flutter_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,9 @@ class GigyaSdk {
}) {
return GigyaFlutterPluginPlatform.instance.sso(parameters: parameters);
}

/// Request authentication code required for web session exchange (group sites).
Future<String?> getAuthCode() {
return GigyaFlutterPluginPlatform.instance.getAuthCode();
}
}
5 changes: 4 additions & 1 deletion lib/src/models/enums/methods.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ enum Methods {
socialLogin('socialLogin'),

/// The method that starts Single-Sign-On.
sso('sso');
sso('sso'),

/// Get session exchange authentication code.
getAuthCode('getAuthCode');

/// The default constructor.
const Methods(this.methodName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ class MethodChannelGigyaFlutterPlugin extends GigyaFlutterPluginPlatform {
@override
Future<void> dismissScreenSet() async {
try {
await methodChannel.invokeMethod<void>(Methods.dismissScreenSet.methodName);
await methodChannel
.invokeMethod<void>(Methods.dismissScreenSet.methodName);
} on PlatformException catch (exception) {
throw GigyaError.fromPlatformException(exception);
}
Expand Down Expand Up @@ -433,4 +434,15 @@ class MethodChannelGigyaFlutterPlugin extends GigyaFlutterPluginPlatform {
throw GigyaError.fromPlatformException(exception);
}
}

@override
Future<String?> getAuthCode() async {
try {
final String? result = await methodChannel
.invokeMethod<String>(Methods.getAuthCode.methodName);
return result;
} on PlatformException catch (exception) {
throw GigyaError.fromPlatformException(exception);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,8 @@ abstract class GigyaFlutterPluginPlatform extends PlatformInterface {
}) {
throw UnimplementedError('sso() is not implemented.');
}

/// Request authentication code required for web session exchange (group sites).
Future<String?> getAuthCode() async =>
throw UnimplementedError('socialLogin() is not implemented.');
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: gigya_flutter_plugin
description: SAP Gigya Flutter plugin
version: 1.0.5
version: 1.0.6
homepage: https://github.com/SAP/gigya-flutter-plugin

environment:
Expand Down

0 comments on commit 6017a06

Please sign in to comment.