From 32da3a16b51005adf9468c6db2822974f89e491a Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sat, 15 Dec 2018 02:48:34 -0500 Subject: [PATCH] pkce factories injected --- lib/src/pkce.dart | 8 ++++++++ lib/src/server.dart | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/src/pkce.dart b/lib/src/pkce.dart index f2c710f7..35bae15a 100644 --- a/lib/src/pkce.dart +++ b/lib/src/pkce.dart @@ -64,4 +64,12 @@ class Pkce { ); } } + + /// Creates a JSON-serializable representation of this instance. + Map toJson() { + return { + 'code_challenge': codeChallenge, + 'code_challenge_method': codeChallengeMethod + }; + } } diff --git a/lib/src/server.dart b/lib/src/server.dart index 712c74c7..c8aa690e 100644 --- a/lib/src/server.dart +++ b/lib/src/server.dart @@ -215,6 +215,10 @@ abstract class AuthorizationServer { state = query['state']?.toString() ?? ''; var responseType = await _getParam(req, 'response_type', state); + req.container.registerLazySingleton((_) { + return new Pkce.fromJson(req.queryParameters, state: state); + }); + if (responseType == 'code') { // Ensure client ID // TODO: Handle confidential clients @@ -339,6 +343,10 @@ abstract class AuthorizationServer { state = body['state']?.toString() ?? ''; + req.container.registerLazySingleton((_) { + return new Pkce.fromJson(req.bodyAsMap, state: state); + }); + var grantType = await _getParam(req, 'grant_type', state, body: true, throwIfEmpty: false);