From 951f34e0ccc9bc56bc48cc321c2acb5d0da72bbc Mon Sep 17 00:00:00 2001 From: amentis Date: Fri, 12 Jan 2024 15:57:38 +0200 Subject: [PATCH] fix notification, inapp notification permissions --- .../InAppNotificationController.java | 4 +--- .../src/main/resources/config/permissions.yml | 20 +++++++++++++++++++ .../target/classes/config/permissions.yml | 20 +++++++++++++++++++ .../authorization/Permission.java | 4 ++++ .../censorship/InAppNotificationCensor.java | 2 +- .../InAppNotificationServiceImpl.java | 4 ++-- .../notification/NotificationServiceImpl.java | 2 +- .../contact-content.component.html | 5 ++--- .../contact-content.component.scss | 4 ++++ ...p-notification-listing-dialog.component.ts | 4 +++- 10 files changed, 58 insertions(+), 11 deletions(-) diff --git a/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/controllers/InAppNotificationController.java b/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/controllers/InAppNotificationController.java index a703dd88b..90d7ad22e 100644 --- a/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/controllers/InAppNotificationController.java +++ b/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/controllers/InAppNotificationController.java @@ -44,7 +44,6 @@ public class InAppNotificationController { private final BuilderFactory builderFactory; private final AuditService auditService; - private final NotificationService notificationService; private final CensorFactory censorFactory; private final QueryFactory queryFactory; private final MessageSource messageSource; @@ -61,7 +60,6 @@ public class InAppNotificationController { InAppNotificationService inAppNotificationService, UserScope userScope, ErrorThesaurusProperties errors) { this.builderFactory = builderFactory; this.auditService = auditService; - this.notificationService = notificationService; this.censorFactory = censorFactory; this.queryFactory = queryFactory; this.messageSource = messageSource; @@ -159,7 +157,7 @@ public class InAppNotificationController { public void Delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException { logger.debug(new MapLogEntry("deleting" + Notification.class.getSimpleName()).And("id", id)); - this.notificationService.deleteAndSave(id); + this.inAppNotificationService.deleteAndSave(id); this.auditService.track(AuditableAction.InApp_Notification_Delete, "id", id); diff --git a/dmp-backend/notification-service/notification-web/src/main/resources/config/permissions.yml b/dmp-backend/notification-service/notification-web/src/main/resources/config/permissions.yml index c7b20e4ca..e93f4f3af 100644 --- a/dmp-backend/notification-service/notification-web/src/main/resources/config/permissions.yml +++ b/dmp-backend/notification-service/notification-web/src/main/resources/config/permissions.yml @@ -85,6 +85,12 @@ permissions: clients: [ ] allowAnonymous: true allowAuthenticated: false + DeleteNotification: + roles: + - Admin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false #Tenant Configuration BrowseTenantConfiguration: roles: @@ -154,6 +160,20 @@ permissions: allowAnonymous: false allowAuthenticated: false DeleteNotificationTemplate: + roles: + - Admin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + + # In App Notification Permissions + BrowseInAppNotification: + roles: + - Admin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + DeleteInAppNotification: roles: - Admin clients: [ ] diff --git a/dmp-backend/notification-service/notification-web/target/classes/config/permissions.yml b/dmp-backend/notification-service/notification-web/target/classes/config/permissions.yml index c7b20e4ca..e93f4f3af 100644 --- a/dmp-backend/notification-service/notification-web/target/classes/config/permissions.yml +++ b/dmp-backend/notification-service/notification-web/target/classes/config/permissions.yml @@ -85,6 +85,12 @@ permissions: clients: [ ] allowAnonymous: true allowAuthenticated: false + DeleteNotification: + roles: + - Admin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false #Tenant Configuration BrowseTenantConfiguration: roles: @@ -154,6 +160,20 @@ permissions: allowAnonymous: false allowAuthenticated: false DeleteNotificationTemplate: + roles: + - Admin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + + # In App Notification Permissions + BrowseInAppNotification: + roles: + - Admin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + DeleteInAppNotification: roles: - Admin clients: [ ] diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/authorization/Permission.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/authorization/Permission.java index bd4f8494b..59b247dec 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/authorization/Permission.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/authorization/Permission.java @@ -34,6 +34,10 @@ public final class Permission { public static String EditNotificationTemplate = "EditNotificationTemplate"; public static String DeleteNotificationTemplate = "DeleteNotificationTemplate"; + //InApp Notification + public static final String BrowseInAppNotification = "BrowseInAppNotification"; + public static String DeleteInAppNotification = "DeleteInAppNotification"; + // UI Pages public static String ViewTenantConfigurationPage = "ViewTenantConfigurationPage"; public static String ViewNotificationPage = "ViewNotificationPage"; diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/censorship/InAppNotificationCensor.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/censorship/InAppNotificationCensor.java index bb1451d8e..d20a14b4c 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/censorship/InAppNotificationCensor.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/model/censorship/InAppNotificationCensor.java @@ -27,6 +27,6 @@ public class InAppNotificationCensor extends BaseCensor { public void censor(FieldSet fields) { logger.debug(new DataLogEntry("censoring fields", fields)); if (this.isEmpty(fields)) return; - this.authService.authorizeForce(Permission.BrowseNotification); + this.authService.authorizeForce(Permission.BrowseInAppNotification); } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java index 9640fc0ef..3086fee5b 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java @@ -86,8 +86,8 @@ public class InAppNotificationServiceImpl implements InAppNotificationService{ public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException { - logger.debug("deleting tenant: {}", id); - this.authService.authorizeForce(Permission.DeleteNotification); + logger.debug("deleting inapp notification: {}", id); + this.authService.authorizeForce(Permission.DeleteInAppNotification); this.deleterFactory.deleter(InAppNotificationDeleter.class).deleteAndSaveByIds(List.of(id)); } } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/notification/NotificationServiceImpl.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/notification/NotificationServiceImpl.java index 26dc42061..a8b5fff5b 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/notification/NotificationServiceImpl.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/notification/NotificationServiceImpl.java @@ -181,7 +181,7 @@ public class NotificationServiceImpl implements NotificationService { @Override public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException { - logger.debug("deleting tenant: {}", id); + logger.debug("deleting notification: {}", id); this.authService.authorizeForce(Permission.DeleteNotification); this.deleterFactory.deleter(NotificationDeleter.class).deleteAndSaveByIds(List.of(id)); } diff --git a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html index 611c28e7a..372ab5990 100644 --- a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html +++ b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html @@ -7,8 +7,7 @@
- - + {{formGroup.get('subject').getError('backendError').message}} @@ -17,7 +16,7 @@
- + {{formGroup.get('description').getError('backendError').message}} diff --git a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.scss b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.scss index 13a78e08f..0db19b4f4 100644 --- a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.scss +++ b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.scss @@ -23,6 +23,10 @@ img { padding-right: 1em; } +.mat-form-field { + width: 100%; +} + .send-btn { background: #ffffff 0% 0% no-repeat padding-box; border: 1px solid var(--primary-color); diff --git a/dmp-frontend/src/app/ui/inapp-notification/listing-dialog/mine-inapp-notification-listing-dialog.component.ts b/dmp-frontend/src/app/ui/inapp-notification/listing-dialog/mine-inapp-notification-listing-dialog.component.ts index 23a224bc8..ee2a1a835 100644 --- a/dmp-frontend/src/app/ui/inapp-notification/listing-dialog/mine-inapp-notification-listing-dialog.component.ts +++ b/dmp-frontend/src/app/ui/inapp-notification/listing-dialog/mine-inapp-notification-listing-dialog.component.ts @@ -12,6 +12,7 @@ import { InAppNotificationLookup } from '@app/core/query/inapp-notification.look import { InAppNotificationService } from '@app/core/services/inapp-notification/inapp-notification.service'; import { takeUntil } from 'rxjs/operators'; import { nameof } from 'ts-simple-nameof'; +import { IsActive } from '@app/core/common/enum/is-active.enum'; @Component({ selector: 'app-mine-inapp-notification-listing-dialog', @@ -44,8 +45,9 @@ export class MineInAppNotificationListingDialogComponent extends BaseComponent i nameof(x => x.trackingState), ] }; - lookup.page = { offset: 0, size: 10 }; + lookup.page = { offset: 0, size: 10 }; lookup.order = { items: ['-' + nameof(x => x.createdAt)] }; + lookup.isActive = [IsActive.Active]; this.inappNotificationService.query(lookup) .pipe(takeUntil(this._destroyed)) .subscribe(