Skip to content

Commit f777361

Browse files
committed
feat: replace Redpanda Admin API with Kafka SCRAM API for user management
Replace all Redpanda Admin API calls in the user service (v1, v1alpha2, and REST handlers) with Kafka SCRAM protocol operations (DescribeUserSCRAMCredentials / AlterUserSCRAMCredentials). This removes the dependency on the Redpanda Admin API for user management, making the user service work across Redpanda and non-Redpanda Kafka clusters. - Add DescribeUserSCRAMCredentials and AlterUserSCRAMs to console servicer - Add NewConnectErrorFromKafkaError helper for Kafka error translation - ListUsers now uses DescribeUserSCRAMCredentials and returns mechanism - CreateUser/UpdateUser use AlterUserSCRAMs with UpsertSCRAM - DeleteUser describes credentials first, then deletes all mechanisms - REST handlers no longer gate behind RedpandaClientProvider - Remove HasRedpandaAPI from user endpoint compatibility checks - Update proto annotations from API_REDPANDA_ADMIN to API_KAFKA - Add unit tests using kfake and update integration tests
1 parent 24cd265 commit f777361

File tree

18 files changed

+1114
-386
lines changed

18 files changed

+1114
-386
lines changed

backend/pkg/api/connect/errors/kafka.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ import (
2121
v1alpha2 "github.com/redpanda-data/console/backend/pkg/protogen/redpanda/api/dataplane/v1alpha2"
2222
)
2323

24+
// NewConnectErrorFromKafkaError creates a connect.Error from a Kafka error.
25+
// If the error is a *kerr.Error it delegates to NewConnectErrorFromKafkaErrorCode;
26+
// otherwise it wraps the error as CodeInternal.
27+
func NewConnectErrorFromKafkaError(err error) *connect.Error {
28+
if kafkaErr, ok := errors.AsType[*kerr.Error](err); ok {
29+
return NewConnectErrorFromKafkaErrorCode(kafkaErr.Code, nil)
30+
}
31+
return NewConnectError(
32+
connect.CodeInternal,
33+
err,
34+
NewErrorInfo(v1alpha2.Reason_REASON_KAFKA_API_ERROR.String()),
35+
)
36+
}
37+
2438
// NewConnectErrorFromKafkaErrorCode creates a new connect.Error for a given Kafka error code.
2539
// Kafka error codes are described in the franz-go kerr package.
2640
func NewConnectErrorFromKafkaErrorCode(code int16, msg *string) *connect.Error {
@@ -78,8 +92,7 @@ func KeyValsFromKafkaError(err error) []KeyVal {
7892
return []KeyVal{}
7993
}
8094

81-
var kafkaErr *kerr.Error
82-
if errors.As(err, &kafkaErr) {
95+
if kafkaErr, ok := errors.AsType[*kerr.Error](err); ok {
8396
return []KeyVal{
8497
{
8598
Key: "kafka_error_code",

0 commit comments

Comments
 (0)