From 7fe0b69413bb98075a3870f6c789e3b83cd50cea Mon Sep 17 00:00:00 2001 From: Newman Chow Date: Wed, 17 Apr 2024 19:17:29 +0800 Subject: [PATCH] Support x_authentication_flow_group in authz request --- lib/src/client.dart | 7 +++++++ lib/src/container.dart | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/src/client.dart b/lib/src/client.dart index bbfd1e91..7dda1ffc 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -22,6 +22,7 @@ class OIDCAuthenticationRequest { final AuthenticationPage? page; final String? wechatRedirectURI; final SettingsAction? settingsAction; + final String? xAuthenticationFlowGroup; OIDCAuthenticationRequest({ required this.clientID, @@ -40,6 +41,7 @@ class OIDCAuthenticationRequest { this.page, this.wechatRedirectURI, this.settingsAction, + this.xAuthenticationFlowGroup, }); Map toQueryParameters() { @@ -122,6 +124,11 @@ class OIDCAuthenticationRequest { q["x_settings_action"] = settingsAction.value; } + final xAuthenticationFlowGroup = this.xAuthenticationFlowGroup; + if (xAuthenticationFlowGroup != null) { + q["x_authentication_flow_group"] = xAuthenticationFlowGroup; + } + return q; } } diff --git a/lib/src/container.dart b/lib/src/container.dart index a12d9707..8c3e12f0 100644 --- a/lib/src/container.dart +++ b/lib/src/container.dart @@ -53,6 +53,7 @@ class AuthenticateOptions { final ColorScheme? colorScheme; final String? wechatRedirectURI; final AuthenticationPage? page; + final String? xAuthenticationFlowGroup; AuthenticateOptions({ required this.redirectURI, @@ -64,6 +65,7 @@ class AuthenticateOptions { this.colorScheme, this.wechatRedirectURI, this.page, + this.xAuthenticationFlowGroup, }); OIDCAuthenticationRequest toRequest(String clientID, CodeVerifier verifier) { @@ -85,6 +87,7 @@ class AuthenticateOptions { state: state, loginHint: loginHint, wechatRedirectURI: wechatRedirectURI, + xAuthenticationFlowGroup: xAuthenticationFlowGroup, ); } } @@ -97,6 +100,7 @@ class ReauthenticateOptions { final ColorScheme? colorScheme; final String? wechatRedirectURI; final int? maxAge; + final String? xAuthenticationFlowGroup; ReauthenticateOptions({ required this.redirectURI, @@ -106,6 +110,7 @@ class ReauthenticateOptions { this.colorScheme, this.wechatRedirectURI, this.maxAge, + this.xAuthenticationFlowGroup, }); OIDCAuthenticationRequest toRequest( @@ -125,6 +130,7 @@ class ReauthenticateOptions { idTokenHint: idTokenHint, maxAge: maxAge, wechatRedirectURI: wechatRedirectURI, + xAuthenticationFlowGroup: xAuthenticationFlowGroup, ); return oidcRequest; } @@ -287,6 +293,7 @@ class Authgear implements AuthgearHttpClientDelegate { AuthenticationPage? page, String? state, String? wechatRedirectURI, + String? xAuthenticationFlowGroup, }) async { final authRequest = await internalCreateAuthenticateRequest(AuthenticateOptions( @@ -298,6 +305,7 @@ class Authgear implements AuthgearHttpClientDelegate { colorScheme: colorScheme, wechatRedirectURI: wechatRedirectURI, page: page, + xAuthenticationFlowGroup: xAuthenticationFlowGroup, )); if (wechatRedirectURI != null) { @@ -339,6 +347,7 @@ class Authgear implements AuthgearHttpClientDelegate { String? wechatRedirectURI, BiometricOptionsIOS? biometricIOS, BiometricOptionsAndroid? biometricAndroid, + String? xAuthenticationFlowGroup, }) async { final biometricEnabled = await isBiometricEnabled(); if (biometricEnabled && biometricIOS != null && biometricAndroid != null) { @@ -361,6 +370,7 @@ class Authgear implements AuthgearHttpClientDelegate { colorScheme: colorScheme, wechatRedirectURI: wechatRedirectURI, maxAge: maxAge, + xAuthenticationFlowGroup: xAuthenticationFlowGroup, ); final request =