From 82f2b117f6a41ff8f89ea82a640305d7bdf94d71 Mon Sep 17 00:00:00 2001 From: Vikash Singh Date: Mon, 3 Oct 2022 22:41:05 +0530 Subject: [PATCH] fix: fix guardian issues (#295) * fix: fix guardian issues * chore: resolve feedback * chore: use appeals.updated_at for grants.created_at value * fix: fix format Co-authored-by: Rahmat Hidayat --- api/handler/v1beta1/adapter.go | 1 + api/handler/v1beta1/grant.go | 1 - core/grant/service.go | 2 +- go.sum | 4 ---- .../postgres/migrations/000007_create_grants_table.up.sql | 4 ++-- .../migrations/000008_move-access-management-to-grant.up.sql | 2 +- jobs/grant_expiration_reminder.go | 1 - 7 files changed, 5 insertions(+), 10 deletions(-) diff --git a/api/handler/v1beta1/adapter.go b/api/handler/v1beta1/adapter.go index f18ce6423..baf12e02b 100644 --- a/api/handler/v1beta1/adapter.go +++ b/api/handler/v1beta1/adapter.go @@ -428,6 +428,7 @@ func (a *adapter) ToPolicyAppealConfigProto(p *domain.Policy) *guardianv1beta1.P } } policyAppealConfigProto.DurationOptions = durationOptions + policyAppealConfigProto.AllowOnBehalf = p.AppealConfig.AllowOnBehalf return policyAppealConfigProto } diff --git a/api/handler/v1beta1/grant.go b/api/handler/v1beta1/grant.go index 648fdbab9..73beb22ee 100644 --- a/api/handler/v1beta1/grant.go +++ b/api/handler/v1beta1/grant.go @@ -3,7 +3,6 @@ package v1beta1 import ( "context" "errors" - guardianv1beta1 "github.com/odpf/guardian/api/proto/odpf/guardian/v1beta1" "github.com/odpf/guardian/core/grant" "github.com/odpf/guardian/domain" diff --git a/core/grant/service.go b/core/grant/service.go index 1df4cb5a0..a6fb57e4d 100644 --- a/core/grant/service.go +++ b/core/grant/service.go @@ -38,7 +38,7 @@ type notifier interface { } type grantCreation struct { - AppealStatus string `validate:"required,eq=active"` + AppealStatus string `validate:"required,eq=approved"` AccountID string `validate:"required"` AccountType string `validate:"required"` ResourceID string `validate:"required"` diff --git a/go.sum b/go.sum index 80402e928..a579963f1 100644 --- a/go.sum +++ b/go.sum @@ -971,10 +971,6 @@ github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba/go.mod h1: github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/odpf/salt v0.0.0-20220530022224-80e391d2e38a h1:c0jaoXLGTITEqmROjOIeiaRyk08gjxd9R3WhqAaxyvw= -github.com/odpf/salt v0.0.0-20220530022224-80e391d2e38a/go.mod h1:ZY9yXIHZYlYbQGKV5WSGmyYnw+NtQEzl6z0Tj0dto8M= -github.com/odpf/salt v0.0.0-20220820210649-284059fe57e6 h1:mzEt6On7rWj7fzKZs0ZdOcuHQFxB3MxurhbA2JHr1YI= -github.com/odpf/salt v0.0.0-20220820210649-284059fe57e6/go.mod h1:iH1ZB+lBmI5E5DgSCu9HjMmNcSvUe0zCusZJzOF2Yfk= github.com/odpf/salt v0.1.1-0.20220821030850-77ce10e39145 h1:MML18OvRZhDDdh/m9u3LGutieRnPZPuGOJMtKkbSl+I= github.com/odpf/salt v0.1.1-0.20220821030850-77ce10e39145/go.mod h1:iH1ZB+lBmI5E5DgSCu9HjMmNcSvUe0zCusZJzOF2Yfk= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= diff --git a/internal/store/postgres/migrations/000007_create_grants_table.up.sql b/internal/store/postgres/migrations/000007_create_grants_table.up.sql index ccde171eb..6445838d0 100644 --- a/internal/store/postgres/migrations/000007_create_grants_table.up.sql +++ b/internal/store/postgres/migrations/000007_create_grants_table.up.sql @@ -55,8 +55,8 @@ SELECT "revoked_at", "revoke_reason", "created_by", - NOW() AS "created_at", - NOW() AS "updated_at" + "updated_at" AS "created_at", + "updated_at" FROM "appeals" WHERE diff --git a/internal/store/postgres/migrations/000008_move-access-management-to-grant.up.sql b/internal/store/postgres/migrations/000008_move-access-management-to-grant.up.sql index 0cc5b0031..03377e9c9 100644 --- a/internal/store/postgres/migrations/000008_move-access-management-to-grant.up.sql +++ b/internal/store/postgres/migrations/000008_move-access-management-to-grant.up.sql @@ -3,7 +3,7 @@ UPDATE SET "status" = 'approved' WHERE - "status" = 'terminated'; + "status" in ('terminated', 'active'); ALTER TABLE "appeals" DROP COLUMN IF EXISTS "revoked_by", diff --git a/jobs/grant_expiration_reminder.go b/jobs/grant_expiration_reminder.go index 7f076df4f..9543d78bf 100644 --- a/jobs/grant_expiration_reminder.go +++ b/jobs/grant_expiration_reminder.go @@ -53,7 +53,6 @@ func (h *handler) GrantExpirationReminder(ctx context.Context) error { for _, err1 := range errs { h.logger.Error("failed to send notifications", "error", err1) } - return nil } }