From 32f8545082280e0afdc9f3c3ebf1d01e34b7cf96 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Thu, 17 Jun 2021 14:10:14 +0200 Subject: [PATCH] fix: label policy fixes (#1886) * fix: check correct permission for label policy in console policy grid * fix: add next steps for label policy detail * fix: add label policy link in console home * fix: i18n of EN features * fix: set font color on preview * fix: handle label policy remove in write model * fix: add more content-types for font upload * fix: add label policy link in console home * fix: dont return error when bucket does not exists * fix: iam access pref * fix: EN i18n for apply button --- .../preview/preview.component.html | 12 ++++++------ .../private-labeling-policy.component.ts | 19 ++++++++++++++++++- .../policy-grid/policy-grid.component.html | 13 +++---------- .../src/app/pages/home/home.component.html | 6 +++++- console/src/assets/i18n/de.json | 2 ++ console/src/assets/i18n/en.json | 8 +++++--- internal/api/assets/login_policy.go | 4 ++-- internal/command/org_policy_label_model.go | 3 +++ internal/static/s3/minio.go | 6 +++++- 9 files changed, 49 insertions(+), 24 deletions(-) diff --git a/console/src/app/modules/policies/private-labeling-policy/preview/preview.component.html b/console/src/app/modules/policies/private-labeling-policy/preview/preview.component.html index 56d79f8716..49aa0ce6fd 100644 --- a/console/src/app/modules/policies/private-labeling-policy/preview/preview.component.html +++ b/console/src/app/modules/policies/private-labeling-policy/preview/preview.component.html @@ -3,14 +3,14 @@
- \ No newline at end of file + diff --git a/console/src/app/modules/policies/private-labeling-policy/private-labeling-policy.component.ts b/console/src/app/modules/policies/private-labeling-policy/private-labeling-policy.component.ts index 19d6bbe852..66594e6a9c 100644 --- a/console/src/app/modules/policies/private-labeling-policy/private-labeling-policy.component.ts +++ b/console/src/app/modules/policies/private-labeling-policy/private-labeling-policy.component.ts @@ -25,7 +25,14 @@ import { StorageService } from 'src/app/services/storage.service'; import { ToastService } from 'src/app/services/toast.service'; import { CnslLinks } from '../../links/links.component'; -import { IAM_COMPLEXITY_LINK, IAM_LOGIN_POLICY_LINK, IAM_POLICY_LINK } from '../../policy-grid/policy-links'; +import { + IAM_COMPLEXITY_LINK, + IAM_LOGIN_POLICY_LINK, + IAM_POLICY_LINK, + ORG_COMPLEXITY_LINK, + ORG_IAM_POLICY_LINK, + ORG_LOGIN_POLICY_LINK, +} from '../../policy-grid/policy-links'; import { PolicyComponentServiceType } from '../policy-component-types.enum'; export enum Theme { @@ -114,9 +121,19 @@ export class PrivateLabelingPolicyComponent implements OnDestroy { switch (this.serviceType) { case PolicyComponentServiceType.MGMT: this.service = this.injector.get(ManagementService as Type); + this.nextLinks = [ + ORG_IAM_POLICY_LINK, + ORG_LOGIN_POLICY_LINK, + ORG_COMPLEXITY_LINK, + ]; break; case PolicyComponentServiceType.ADMIN: this.service = this.injector.get(AdminService as Type); + this.nextLinks = [ + IAM_POLICY_LINK, + IAM_LOGIN_POLICY_LINK, + IAM_COMPLEXITY_LINK, + ]; break; } diff --git a/console/src/app/modules/policy-grid/policy-grid.component.html b/console/src/app/modules/policy-grid/policy-grid.component.html index 49bf5b799d..93b7554c36 100644 --- a/console/src/app/modules/policy-grid/policy-grid.component.html +++ b/console/src/app/modules/policy-grid/policy-grid.component.html @@ -56,18 +56,11 @@

{{'POLICY.IAM_POLICY.DESCRIPTION' | translate}}

- - {{'FEATURES.NOTAVAILABLE' | translate: ({value: - 'password_complexity_policy'})}} -
@@ -75,7 +68,7 @@
- +
@@ -98,7 +91,7 @@
- + @@ -133,4 +126,4 @@
-
\ No newline at end of file + diff --git a/console/src/app/pages/home/home.component.html b/console/src/app/pages/home/home.component.html index 4671bca621..25e02fbb22 100644 --- a/console/src/app/pages/home/home.component.html +++ b/console/src/app/pages/home/home.component.html @@ -72,6 +72,8 @@ | translate}} {{'HOME.IAM_POLICY_LOGIN' | translate}} + {{'HOME.IAM_POLICY_LABEL' | + translate}}
@@ -134,6 +136,8 @@ translate}} {{'HOME.ORG_POLICY_LOGIN' | translate}} + {{'HOME.ORG_POLICY_LABEL' | + translate}}
@@ -176,4 +180,4 @@

- \ No newline at end of file + diff --git a/console/src/assets/i18n/de.json b/console/src/assets/i18n/de.json index f2730b4cc2..e4311ef2da 100644 --- a/console/src/assets/i18n/de.json +++ b/console/src/assets/i18n/de.json @@ -46,9 +46,11 @@ "ORG_POLICY_COMPLEXITY": "Passwort Komplexität", "ORG_POLICY_IAM": "Organisation Zugangseinstellungen", "ORG_POLICY_LOGIN": "Login Richtlinie", + "ORG_POLICY_LABEL": "Private Label Richtlinie", "IAM_POLICY_COMPLEXITY": "Systemweite Passwort Komplexität", "IAM_POLICY_IAM": "Systemweite Zugangseinstellungen", "IAN_POLICY_LOGIN": "Systemweite Login Richtlinie", + "IAN_POLICY_LABEL": "Systemweite Private Label Richtlinie", "USERS": "Erstelle und verwalte Deine Benutzer.", "USERS_DESC": "Überwache Dein Rollenkonzept in Echtzeit. Ergreife sofort Massnahmen.", "USERS_HUMANS": "Zeige Benutzer", diff --git a/console/src/assets/i18n/en.json b/console/src/assets/i18n/en.json index 17a76cb612..90c9f9c271 100644 --- a/console/src/assets/i18n/en.json +++ b/console/src/assets/i18n/en.json @@ -45,10 +45,12 @@ "ORG_POLICY_COMPLEXITY": "Password Complexity Settings", "ORG_POLICY_IAM": "Organisation Access Properties", "ORG_POLICY_LOGIN": "Login Policy", + "ORG_POLICY_LABEL": "Private Label Policy", "IAM_CREATE_ORG": "Create organisation", "IAM_POLICY_COMPLEXITY": "System Password Complexity Settings", "IAM_POLICY_IAM": "System Access Properties", "IAM_POLICY_LOGIN": "System Login Policy", + "IAM_POLICY_LABEL": "System Private Label Policy", "USERS": "Create and Manage Your Users", "USERS_DESC": "Monitor your role concept in real time. Take immediate action.", "USERS_HUMANS": "Show human users", @@ -623,8 +625,8 @@ "LOGINPOLICYFACTORS": "Login Policy: Multifactors - custom", "LOGINPOLICYPASSWORDLESS": "Login Policy: Passwordless Authentication - custom", "LOGINPOLICYCOMPLEXITYPOLICY": "Password Complexity Policy - custom", - "LABELPOLICYPRIVATELABEL": "Label Richtlinie - benutzerdefiniert", - "LABELPOLICYWATERMARK": "Label Richtlinie - Wasserzeichen", + "LABELPOLICYPRIVATELABEL": "Label Policy - custom", + "LABELPOLICYWATERMARK": "Label Policy - watermark", "CUSTOMDOMAIN": "Domain Verification - available", "CUSTOMTEXT": "Custom texts" }, @@ -653,7 +655,7 @@ "DESCRIPTION":"Give the login your personalized style and modify its behavior.", "PREVIEW_DESCRIPTION":"Changes of the policy will automatically deployed to preview environment.", "BTN":"Select File", - "ACTIVATEPREVIEW":"Set preview as current configuration", + "ACTIVATEPREVIEW":"Apply configuration", "DARK":"Dark Mode", "LIGHT":"Lighg Mode", "CHANGEVIEW":"Change View", diff --git a/internal/api/assets/login_policy.go b/internal/api/assets/login_policy.go index 8219030826..586ec43e96 100644 --- a/internal/api/assets/login_policy.go +++ b/internal/api/assets/login_policy.go @@ -268,11 +268,11 @@ func (l *labelPolicyIconDownloader) BucketName(ctx context.Context, id string) s } func (h *Handler) UploadDefaultLabelPolicyFont() Uploader { - return &labelPolicyFontUploader{h.idGenerator, true, []string{"font/"}, 1 << 19} + return &labelPolicyFontUploader{h.idGenerator, true, []string{"font/", "application/octet-stream"}, 1 << 19} } func (h *Handler) UploadOrgLabelPolicyFont() Uploader { - return &labelPolicyFontUploader{h.idGenerator, false, []string{"font/"}, 1 << 19} + return &labelPolicyFontUploader{h.idGenerator, false, []string{"font/", "application/octet-stream"}, 1 << 19} } type labelPolicyFontUploader struct { diff --git a/internal/command/org_policy_label_model.go b/internal/command/org_policy_label_model.go index bf7cd986aa..a6b82c8e98 100644 --- a/internal/command/org_policy_label_model.go +++ b/internal/command/org_policy_label_model.go @@ -30,6 +30,8 @@ func (wm *OrgLabelPolicyWriteModel) AppendEvents(events ...eventstore.EventReade wm.LabelPolicyWriteModel.AppendEvents(&e.LabelPolicyAddedEvent) case *org.LabelPolicyChangedEvent: wm.LabelPolicyWriteModel.AppendEvents(&e.LabelPolicyChangedEvent) + case *org.LabelPolicyRemovedEvent: + wm.LabelPolicyWriteModel.AppendEvents(&e.LabelPolicyRemovedEvent) case *org.LabelPolicyLogoAddedEvent: wm.LabelPolicyWriteModel.AppendEvents(&e.LabelPolicyLogoAddedEvent) case *org.LabelPolicyLogoRemovedEvent: @@ -65,6 +67,7 @@ func (wm *OrgLabelPolicyWriteModel) Query() *eventstore.SearchQueryBuilder { EventTypes( org.LabelPolicyAddedEventType, org.LabelPolicyChangedEventType, + org.LabelPolicyRemovedEventType, org.LabelPolicyLogoAddedEventType, org.LabelPolicyLogoRemovedEventType, org.LabelPolicyIconAddedEventType, diff --git a/internal/static/s3/minio.go b/internal/static/s3/minio.go index f80e787e3e..94f6b4054d 100644 --- a/internal/static/s3/minio.go +++ b/internal/static/s3/minio.go @@ -162,8 +162,12 @@ func (m *Minio) RemoveObjects(ctx context.Context, bucketName, path string, recu defer close(objectsCh) objects, cancel := m.listObjects(ctx, bucketName, path, recursive) for object := range objects { - if object.Err != nil { + if err := object.Err; err != nil { cancel() + if errResp := minio.ToErrorResponse(err); errResp.StatusCode == http.StatusNotFound { + logging.LogWithFields("MINIO-ss8va", "bucketName", bucketName, "path", path).Warn("list objects for remove failed with not found") + continue + } return caos_errs.ThrowInternal(object.Err, "MINIO-WQF32", "Errors.Assets.Object.ListFailed") } objectsCh <- object