Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: APKAM keys expiry feature changes in at_commons #658

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/at_commons/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
## 4.1.2
- feat: Add "expiry" enroll params to support apkam keys to auto expiry after specified time duration
## 4.1.1
- feat: Add "delete" operation to the enroll verb to allow deletion of denied enrollments
## 4.1.0
Expand Down
5 changes: 4 additions & 1 deletion packages/at_commons/lib/src/verb/enroll_params.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:at_commons/at_commons.dart';
import 'package:json_annotation/json_annotation.dart';

import 'package:at_commons/at_commons.dart';
part 'enroll_params.g.dart';

@JsonSerializable()
Expand All @@ -15,7 +15,10 @@ class EnrollParams {
String? encryptedAPKAMSymmetricKey;
String? apkamPublicKey;
List<EnrollmentStatus>? enrollmentStatusFilter;
Duration? apkamKeysExpiryDuration;

EnrollParams();

factory EnrollParams.fromJson(Map<String, dynamic> json) =>
_$EnrollParamsFromJson(json);

Expand Down
8 changes: 6 additions & 2 deletions packages/at_commons/lib/src/verb/enroll_params.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/at_commons/lib/src/verb/enroll_verb_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class EnrollVerbBuilder extends AbstractVerbBuilder {
/// Accepts a list of enrollment statuses. Defaults to all EnrollmentStatuses
List<EnrollmentStatus>? enrollmentStatusFilter;

Duration? apkamKeysExpiryDuration;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a test in enroll verb builder for this param


@override
String buildCommand() {
var sb = StringBuffer();
Expand All @@ -64,7 +66,8 @@ class EnrollVerbBuilder extends AbstractVerbBuilder {
encryptedDefaultEncryptionPrivateKey
..encryptedDefaultSelfEncryptionKey = encryptedDefaultSelfEncryptionKey
..encryptedAPKAMSymmetricKey = encryptedAPKAMSymmetricKey
..enrollmentStatusFilter = enrollmentStatusFilter;
..enrollmentStatusFilter = enrollmentStatusFilter
..apkamKeysExpiryDuration = apkamKeysExpiryDuration;

Map<String, dynamic> enrollParamsJson = enrollParams.toJson();
enrollParamsJson.removeWhere(_removeElements);
Expand Down
3 changes: 1 addition & 2 deletions packages/at_commons/lib/src/verb/notify_verb_builder.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import 'package:at_commons/src/keystore/at_key.dart';
import 'package:at_commons/src/verb/abstract_verb_builder.dart';
import 'package:at_commons/src/utils/string_utils.dart';
import 'package:at_commons/src/verb/abstract_verb_builder.dart';
import 'package:uuid/uuid.dart';

import '../at_constants.dart';

import 'operation_enum.dart';
import 'verb_util.dart';

Expand Down
2 changes: 1 addition & 1 deletion packages/at_commons/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: at_commons
description: A library of Dart and Flutter utility classes that are used across other components of the atPlatform.
version: 4.1.1
version: 4.1.2
repository: https://github.com/atsign-foundation/at_libraries
homepage: https://atsign.dev

Expand Down
5 changes: 3 additions & 2 deletions packages/at_commons/test/enroll_verb_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ void main() {
..enrollmentId = '1234'
..encryptedAPKAMSymmetricKey = 'dummy_pkam_sym_key'
..encryptedDefaultEncryptionPrivateKey = 'dummy_encrypted_private_key'
..encryptedDefaultSelfEncryptionKey = 'dummy_self_encryption_key';
..encryptedDefaultSelfEncryptionKey = 'dummy_self_encryption_key'
..apkamKeysExpiryDuration = Duration(minutes: 1);
var command = enrollVerbBuilder.buildCommand();
expect(command,
'enroll:request:{"enrollmentId":"1234","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw","__manage":"r"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234"}\n');
'enroll:request:{"enrollmentId":"1234","appName":"wavi","deviceName":"pixel","namespaces":{"wavi":"rw","__manage":"r"},"encryptedDefaultEncryptionPrivateKey":"dummy_encrypted_private_key","encryptedDefaultSelfEncryptionKey":"dummy_self_encryption_key","encryptedAPKAMSymmetricKey":"dummy_pkam_sym_key","apkamPublicKey":"abcd1234","apkamKeysExpiryInMillis":60000}\n');
});

test('A test to verify enroll approve operation', () {
Expand Down