Skip to content

Commit

Permalink
implement requirePushedAuthorizationRequests parameter #2712
Browse files Browse the repository at this point in the history
  • Loading branch information
bibash28 committed Jun 10, 2024
1 parent 5c8bcef commit 4ef05d9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
14 changes: 11 additions & 3 deletions lib/oidc4vc/get_authorization_uri_for_issuer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ Future<void> getAuthorizationUriForIssuer({

late Uri authorizationUri;

final (authorizationEndpoint, authorizationRequestParemeters) =
await oidc4vc.getAuthorizationData(
final (
authorizationEndpoint,
authorizationRequestParemeters,
openIdConfiguration
) = await oidc4vc.getAuthorizationData(
selectedCredentials: selectedCredentials,
clientId: clientId,
clientSecret: clientSecret,
Expand All @@ -98,7 +101,12 @@ Future<void> getAuthorizationUriForIssuer({
dio: client.dio,
);

if (secureAuthorizedFlow) {
final requirePushedAuthorizationRequests =
openIdConfiguration.requirePushedAuthorizationRequests;

if ((requirePushedAuthorizationRequests != null &&
requirePushedAuthorizationRequests) ||
(requirePushedAuthorizationRequests == null && secureAuthorizedFlow)) {
final headers = <String, dynamic>{
'Content-Type': 'application/x-www-form-urlencoded',
};
Expand Down
4 changes: 4 additions & 0 deletions packages/oidc4vc/lib/src/models/openid_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class OpenIdConfiguration extends Equatable {
this.credentialManifests,
this.issuer,
this.jwksUri,
this.requirePushedAuthorizationRequests,
this.grantTypesSupported,
});

Expand Down Expand Up @@ -60,6 +61,8 @@ class OpenIdConfiguration extends Equatable {
final String? issuer;
@JsonKey(name: 'jwks_uri')
final String? jwksUri;
@JsonKey(name: 'require_pushed_authorization_requests')
final bool? requirePushedAuthorizationRequests;
@JsonKey(name: 'grant_types_supported')
final List<String>? grantTypesSupported;

Expand All @@ -83,6 +86,7 @@ class OpenIdConfiguration extends Equatable {
credentialManifests,
issuer,
jwksUri,
requirePushedAuthorizationRequests,
grantTypesSupported,
];
}
Expand Down
12 changes: 9 additions & 3 deletions packages/oidc4vc/lib/src/oidc4vc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ class OIDC4VC {
/// Received JWT is already filtered on required members
/// Received JWT keys are already sorted in lexicographic order
/// authorization endpoint, authorizationRequestParemeters
Future<(String, Map<String, dynamic>)> getAuthorizationData({
/// authorization endpoint, authorizationRequestParemeters,
/// OpenIdConfiguration
Future<(String, Map<String, dynamic>, OpenIdConfiguration)>
getAuthorizationData({
required List<dynamic> selectedCredentials,
required String? clientId,
required String? clientSecret,
Expand Down Expand Up @@ -185,7 +187,11 @@ class OIDC4VC {
secureAuthorizedFlow: secureAuthorizedFlow,
);

return (authorizationEndpoint, authorizationRequestParemeters);
return (
authorizationEndpoint,
authorizationRequestParemeters,
openIdConfiguration,
);
} catch (e) {
throw Exception('NOT_A_VALID_OPENID_URL');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/oidc4vc/test/src/oidc4vc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ void main() {
(request) => request.reply(200, jsonDecode(openIdConfiguration)),
);

final (authorizationEndpoint, authorizationRequestParemeters) =
final (authorizationEndpoint, authorizationRequestParemeters, _) =
await oidc4vc.getAuthorizationData(
selectedCredentials: selectedCredentials,
clientId: clientId,
Expand Down

0 comments on commit 4ef05d9

Please sign in to comment.