feat(server): mobile oauth with custom scheme redirect uri (#1204)

* feat(server): support providers without support for custom schemas

* chore: unit tests

* chore: test mobile override

* chore: add details to the docs
This commit is contained in:
Jason Rasmussen
2022-12-29 15:47:30 -05:00
committed by GitHub
parent 0b65bb7e9a
commit 6974d4068b
22 changed files with 459 additions and 188 deletions

View File

@@ -157,6 +157,39 @@ class OAuthApi {
return null;
}
/// Performs an HTTP 'GET /oauth/mobile-redirect' operation and returns the [Response].
Future<Response> mobileRedirectWithHttpInfo() async {
// ignore: prefer_const_declarations
final path = r'/oauth/mobile-redirect';
// ignore: prefer_final_locals
Object? postBody;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
const contentTypes = <String>[];
return apiClient.invokeAPI(
path,
'GET',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
);
}
Future<void> mobileRedirect() async {
final response = await mobileRedirectWithHttpInfo();
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
}
/// Performs an HTTP 'POST /oauth/unlink' operation and returns the [Response].
Future<Response> unlinkWithHttpInfo() async {
// ignore: prefer_const_declarations

View File

@@ -20,6 +20,8 @@ class SystemConfigOAuthDto {
required this.scope,
required this.buttonText,
required this.autoRegister,
required this.mobileOverrideEnabled,
required this.mobileRedirectUri,
});
bool enabled;
@@ -36,6 +38,10 @@ class SystemConfigOAuthDto {
bool autoRegister;
bool mobileOverrideEnabled;
String mobileRedirectUri;
@override
bool operator ==(Object other) => identical(this, other) || other is SystemConfigOAuthDto &&
other.enabled == enabled &&
@@ -44,7 +50,9 @@ class SystemConfigOAuthDto {
other.clientSecret == clientSecret &&
other.scope == scope &&
other.buttonText == buttonText &&
other.autoRegister == autoRegister;
other.autoRegister == autoRegister &&
other.mobileOverrideEnabled == mobileOverrideEnabled &&
other.mobileRedirectUri == mobileRedirectUri;
@override
int get hashCode =>
@@ -55,10 +63,12 @@ class SystemConfigOAuthDto {
(clientSecret.hashCode) +
(scope.hashCode) +
(buttonText.hashCode) +
(autoRegister.hashCode);
(autoRegister.hashCode) +
(mobileOverrideEnabled.hashCode) +
(mobileRedirectUri.hashCode);
@override
String toString() => 'SystemConfigOAuthDto[enabled=$enabled, issuerUrl=$issuerUrl, clientId=$clientId, clientSecret=$clientSecret, scope=$scope, buttonText=$buttonText, autoRegister=$autoRegister]';
String toString() => 'SystemConfigOAuthDto[enabled=$enabled, issuerUrl=$issuerUrl, clientId=$clientId, clientSecret=$clientSecret, scope=$scope, buttonText=$buttonText, autoRegister=$autoRegister, mobileOverrideEnabled=$mobileOverrideEnabled, mobileRedirectUri=$mobileRedirectUri]';
Map<String, dynamic> toJson() {
final _json = <String, dynamic>{};
@@ -69,6 +79,8 @@ class SystemConfigOAuthDto {
_json[r'scope'] = scope;
_json[r'buttonText'] = buttonText;
_json[r'autoRegister'] = autoRegister;
_json[r'mobileOverrideEnabled'] = mobileOverrideEnabled;
_json[r'mobileRedirectUri'] = mobileRedirectUri;
return _json;
}
@@ -98,6 +110,8 @@ class SystemConfigOAuthDto {
scope: mapValueOfType<String>(json, r'scope')!,
buttonText: mapValueOfType<String>(json, r'buttonText')!,
autoRegister: mapValueOfType<bool>(json, r'autoRegister')!,
mobileOverrideEnabled: mapValueOfType<bool>(json, r'mobileOverrideEnabled')!,
mobileRedirectUri: mapValueOfType<String>(json, r'mobileRedirectUri')!,
);
}
return null;
@@ -154,6 +168,8 @@ class SystemConfigOAuthDto {
'scope',
'buttonText',
'autoRegister',
'mobileOverrideEnabled',
'mobileRedirectUri',
};
}