Skip to content
Closed
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: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ TAG := $(shell git rev-list --tags --max-count=1)
VERSION := $(shell git describe --tags ${TAG})
.PHONY: build check fmt lint test test-race vet test-cover-html help install proto ui
.DEFAULT_GOAL := build
PROTON_COMMIT := "eb24a09e48f7f746b07006daae47f9434ef70ec4"
PROTON_COMMIT := "4c0454a0e55cd15750d3e007d5cc06ca6e186b6e"

ui:
@echo " > generating ui build"
Expand Down
1 change: 1 addition & 0 deletions core/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const (

PolicyCreatedEvent EventName = "app.policy.created"
PolicyDeletedEvent EventName = "app.policy.deleted"
PolicyReplaceEvent EventName = "app.policy.replaced"

OrgCreatedEvent EventName = "app.organization.created"
OrgUpdatedEvent EventName = "app.organization.updated"
Expand Down
9 changes: 9 additions & 0 deletions core/policy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package policy

import (
"context"
"errors"

"github.com/raystack/frontier/pkg/utils"

Expand Down Expand Up @@ -74,6 +75,14 @@ func (s Service) Delete(ctx context.Context, id string) error {
return s.repository.Delete(ctx, id)
}

func (s Service) Replace(ctx context.Context, existingID string, pol Policy) (Policy, error) {
if err := s.Delete(ctx, existingID); err != nil && !errors.Is(err, ErrNotExist) {
return Policy{}, err
}
pol.ID = existingID
return s.Create(ctx, pol)
}

// AssignRole Note: ideally this should be in a single transaction
// read more about how user defined roles work in spicedb https://authzed.com/blog/user-defined-roles
func (s Service) AssignRole(ctx context.Context, pol Policy) error {
Expand Down
Loading