Skip to content

Commit 1d3a65b

Browse files
committed
refactor: remove REST users/ACLs/quotas after Connect Query migration (UX-1199)
The frontend already calls dataplane.v1.UserService, ACLService, and QuotaService directly via Connect Query. The REST handlers and their backend-api.ts callers were dead code still being served but no longer consumed. Remove them along with the now-orphaned ConsoleSvc methods. Backend - Delete handle_users.go (GET/POST/DELETE /api/users) - Delete handle_quotas.go (GET /api/quotas) - Drop handleCreateACL / handleDeleteACLs from handle_acls.go and the POST/DELETE /api/acls route registrations; keep GET /api/acls — still used by the frontend Zustand store for isAuthorizerEnabled detection (Phase 2 will remove the route once detection switches to RPC error codes; tracked under UX-1210) - Drop CreateACL / DeleteACLs / DescribeQuotas from the Servicer interface and the corresponding methods/types from create_acl.go, delete_acls.go, describe_quotas.go (kept the *Kafka / *Client variants that the Connect handlers still call) Frontend - Strip refresh/createServiceAccount/deleteServiceAccount, refreshQuotas, createACL/deleteACLs from backend-api.ts and the matching response types from rest-interfaces.ts - Drop legacy ACL conversion helpers from react-query/api/acl.tsx - Fix useCreateACLMutation invalidating listACLs with cardinality 'infinite' while the actual query uses useQuery (finite) — the invalidation silently no-op'd, leaving a stale ACL list after every successful create - Guard ACL create/update navigation on mutation success so the form stops navigating away on failed submits (regression surfaced by the new e2e suite — UX-1218) Cross-repo: apps/redpanda-connect-api/tenant/api.go in cloudv2 has already been migrated off these REST endpoints; tests/e2e-billing/... is the only remaining REST caller (test-only, lower impact).
1 parent 910adb5 commit 1d3a65b

16 files changed

Lines changed: 17 additions & 1176 deletions

File tree

backend/pkg/api/handle_acls.go

Lines changed: 0 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package api
1111

1212
import (
13-
"errors"
1413
"fmt"
1514
"net/http"
1615

@@ -97,155 +96,3 @@ func (api *API) handleGetACLsOverview() http.HandlerFunc {
9796
rest.SendResponse(w, r, api.Logger, http.StatusOK, res)
9897
}
9998
}
100-
101-
type deleteAclsRequest struct {
102-
// The resource type.
103-
ResourceType kmsg.ACLResourceType `schema:"resourceType"`
104-
105-
// The resource name, or null to match any resource name.
106-
ResourceName *string `schema:"resourceName"`
107-
108-
// The resource pattern to match.
109-
ResourcePatternType kmsg.ACLResourcePatternType `schema:"resourcePatternType"`
110-
111-
// The principal to match, or null to match any principal.
112-
Principal *string `schema:"principal"`
113-
114-
// The host to match, or null to match any host.
115-
Host *string `schema:"host"`
116-
117-
// The operation to match.
118-
Operation kmsg.ACLOperation `schema:"operation"`
119-
120-
// The permission type to match.
121-
PermissionType kmsg.ACLPermissionType `schema:"permissionType"`
122-
}
123-
124-
// ToKafkaRequest returns a request struct that complies with the expected request object for the Kafka library
125-
func (g *deleteAclsRequest) ToKafkaRequest() kmsg.DeleteACLsRequestFilter {
126-
reqFilter := kmsg.NewDeleteACLsRequestFilter()
127-
reqFilter.PermissionType = g.PermissionType
128-
reqFilter.Operation = g.Operation
129-
reqFilter.Host = g.Host
130-
reqFilter.Principal = g.Principal
131-
reqFilter.ResourcePatternType = g.ResourcePatternType
132-
reqFilter.ResourceName = g.ResourceName
133-
reqFilter.ResourceType = g.ResourceType
134-
135-
return reqFilter
136-
}
137-
138-
func (api *API) handleDeleteACLs() http.HandlerFunc {
139-
return func(w http.ResponseWriter, r *http.Request) {
140-
// Parse request from body
141-
var req deleteAclsRequest
142-
restErr := rest.Decode(w, r, &req)
143-
if restErr != nil {
144-
rest.SendRESTError(w, r, api.Logger, restErr)
145-
return
146-
}
147-
148-
aclDeleteRes, restErr := api.ConsoleSvc.DeleteACLs(r.Context(), req.ToKafkaRequest())
149-
if restErr != nil {
150-
rest.SendRESTError(w, r, api.Logger, restErr)
151-
return
152-
}
153-
154-
rest.SendResponse(w, r, api.Logger, http.StatusOK, aclDeleteRes)
155-
}
156-
}
157-
158-
// CreateACLRequest defines the HTTP request payload for creating Kafka ACLs.
159-
type CreateACLRequest struct {
160-
// ResourceType is the type of resource this acl entry will be on.
161-
// It is invalid to use UNKNOWN or ANY.
162-
ResourceType kmsg.ACLResourceType `schema:"resourceType"`
163-
164-
// ResourceName is the name of the resource this acl entry will be on.
165-
// For CLUSTER, this must be "kafka-cluster".
166-
ResourceName string `schema:"resourceName"`
167-
168-
// ResourcePatternType is the pattern type to use for the resource name.
169-
// This cannot be UNKNOWN or MATCH (i.e. this must be LITERAL or PREFIXED).
170-
// The default for pre-Kafka 2.0.0 is effectively LITERAL.
171-
ResourcePatternType kmsg.ACLResourcePatternType `schema:"resourcePatternType"`
172-
173-
// Principal is the user to apply this acl for. With the Kafka simple
174-
// authorizer, this must begin with "User:".
175-
Principal string `schema:"principal"`
176-
177-
// Host is the host address to use for this acl. Each host to allow
178-
// the principal access from must be specified as a new creation. KIP-252
179-
// might solve this someday. The special wildcard host "*" allows all hosts.
180-
Host string `schema:"host"`
181-
182-
// Operation is the operation this acl is for. This must not be UNKNOWN or
183-
// ANY.
184-
Operation kmsg.ACLOperation `schema:"operation"`
185-
186-
// PermissionType is the permission of this acl. This must be either ALLOW
187-
// or DENY.
188-
PermissionType kmsg.ACLPermissionType `schema:"permissionType"`
189-
}
190-
191-
// OK validates the user input for the create acl request.
192-
func (c *CreateACLRequest) OK() error {
193-
if c.ResourceType == kmsg.ACLResourceTypeAny {
194-
return fmt.Errorf("acl resource type must not be any (1), but found: %q", c.ResourceType)
195-
}
196-
197-
// Check Resource pattern type - must be LITERAL (3) or PREFIXED (4)
198-
switch c.ResourcePatternType {
199-
case kmsg.ACLResourcePatternTypeLiteral, kmsg.ACLResourcePatternTypePrefixed:
200-
default:
201-
return errors.New("resourcePatternType is invalid, must be either LITERAL (3) or PREFIXED (4)")
202-
}
203-
204-
// Check Operation - must not be Any (1)
205-
if c.Operation == kmsg.ACLOperationAny {
206-
return errors.New("operation type any (1) is not allowed for creating a new ACL")
207-
}
208-
209-
// Permission type must be either 'deny' (2) or 'any' (1)
210-
switch c.PermissionType {
211-
case kmsg.ACLPermissionTypeDeny, kmsg.ACLPermissionTypeAllow:
212-
default:
213-
return errors.New("given permission type is invalid, it must be either allow (3) or deny (2)")
214-
}
215-
216-
return nil
217-
}
218-
219-
// ToKafkaRequest returns a request struct that complies with the expected request object for the Kafka library
220-
func (c *CreateACLRequest) ToKafkaRequest() kmsg.CreateACLsRequestCreation {
221-
reqFilter := kmsg.NewCreateACLsRequestCreation()
222-
reqFilter.PermissionType = c.PermissionType
223-
reqFilter.Operation = c.Operation
224-
reqFilter.Host = c.Host
225-
reqFilter.Principal = c.Principal
226-
reqFilter.ResourcePatternType = c.ResourcePatternType
227-
reqFilter.ResourceName = c.ResourceName
228-
reqFilter.ResourceType = c.ResourceType
229-
230-
return reqFilter
231-
}
232-
233-
func (api *API) handleCreateACL() http.HandlerFunc {
234-
return func(w http.ResponseWriter, r *http.Request) {
235-
// Parse request from url parameters & validate it as part of Decode()
236-
var req CreateACLRequest
237-
restErr := rest.Decode(w, r, &req)
238-
if restErr != nil {
239-
rest.SendRESTError(w, r, api.Logger, restErr)
240-
return
241-
}
242-
243-
restErr = api.ConsoleSvc.CreateACL(r.Context(), req.ToKafkaRequest())
244-
if restErr != nil {
245-
rest.SendRESTError(w, r, api.Logger, restErr)
246-
return
247-
}
248-
249-
rest.SendResponse(w, r, api.Logger, http.StatusOK, nil)
250-
}
251-
}

backend/pkg/api/handle_quotas.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

backend/pkg/api/handle_users.go

Lines changed: 0 additions & 207 deletions
This file was deleted.

0 commit comments

Comments
 (0)