Skip to content

Commit 145b39e

Browse files
refactor(auth): remove billing_id validation from transaction and invoice RPCs
Remove ensureBillingAccountBelongToOrg checks from authorization interceptors for 4 RPCs: - ListBillingTransactions - TotalDebitedTransactions - ListInvoices - GetUpcomingInvoice Since billing_id is now always inferred from org_id by handlers, the separate validation that billing_id belongs to org_id is redundant.
1 parent 7817b12 commit 145b39e

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

pkg/server/connect_interceptors/authorization.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -907,32 +907,20 @@ var authorizationValidationMap = map[string]func(ctx context.Context, handler *v
907907
},
908908
"/raystack.frontier.v1beta1.FrontierService/ListBillingTransactions": func(ctx context.Context, handler *v1beta1connect.ConnectHandler, req connect.AnyRequest) error {
909909
pbReq := req.(*connect.Request[frontierv1beta1.ListBillingTransactionsRequest])
910-
if err := ensureBillingAccountBelongToOrg(ctx, handler, pbReq.Msg.GetOrgId(), pbReq.Msg.GetBillingId()); err != nil {
911-
return err
912-
}
913910
return handler.IsAuthorized(ctx, relation.Object{Namespace: schema.OrganizationNamespace, ID: pbReq.Msg.GetOrgId()}, schema.GetPermission, req)
914911
},
915912
"/raystack.frontier.v1beta1.FrontierService/TotalDebitedTransactions": func(ctx context.Context, handler *v1beta1connect.ConnectHandler, req connect.AnyRequest) error {
916913
pbReq := req.(*connect.Request[frontierv1beta1.TotalDebitedTransactionsRequest])
917-
if err := ensureBillingAccountBelongToOrg(ctx, handler, pbReq.Msg.GetOrgId(), pbReq.Msg.GetBillingId()); err != nil {
918-
return err
919-
}
920914
return handler.IsAuthorized(ctx, relation.Object{Namespace: schema.OrganizationNamespace, ID: pbReq.Msg.GetOrgId()}, schema.GetPermission, req)
921915
},
922916

923917
// invoice
924918
"/raystack.frontier.v1beta1.FrontierService/ListInvoices": func(ctx context.Context, handler *v1beta1connect.ConnectHandler, req connect.AnyRequest) error {
925919
pbReq := req.(*connect.Request[frontierv1beta1.ListInvoicesRequest])
926-
if err := ensureBillingAccountBelongToOrg(ctx, handler, pbReq.Msg.GetOrgId(), pbReq.Msg.GetBillingId()); err != nil {
927-
return err
928-
}
929920
return handler.IsAuthorized(ctx, relation.Object{Namespace: schema.OrganizationNamespace, ID: pbReq.Msg.GetOrgId()}, schema.UpdatePermission, req)
930921
},
931922
"/raystack.frontier.v1beta1.FrontierService/GetUpcomingInvoice": func(ctx context.Context, handler *v1beta1connect.ConnectHandler, req connect.AnyRequest) error {
932923
pbReq := req.(*connect.Request[frontierv1beta1.GetUpcomingInvoiceRequest])
933-
if err := ensureBillingAccountBelongToOrg(ctx, handler, pbReq.Msg.GetOrgId(), pbReq.Msg.GetBillingId()); err != nil {
934-
return err
935-
}
936924
return handler.IsAuthorized(ctx, relation.Object{Namespace: schema.OrganizationNamespace, ID: pbReq.Msg.GetOrgId()}, schema.UpdatePermission, req)
937925
},
938926

0 commit comments

Comments
 (0)