NOISSUE - Fix publisher id on message published by user (#3312)

Signed-off-by: Felix Gateru <felix.gateru@gmail.com>
This commit is contained in:
Felix Gateru
2026-01-15 19:34:11 +03:00
committed by GitHub
parent 927230dbb4
commit 551d44d58e
+10 -10
View File
@@ -230,7 +230,7 @@ func (h *handler) authAccess(ctx context.Context, username, password, domainID,
clientType = policies.ClientType
}
id, err := h.authenticate(ctx, clientType, token, domainID)
id, subject, err := h.authenticate(ctx, clientType, token, domainID)
if err != nil {
return "", mgate.NewHTTPProxyError(http.StatusUnauthorized, errors.Wrap(svcerr.ErrAuthentication, err))
}
@@ -242,7 +242,7 @@ func (h *handler) authAccess(ctx context.Context, username, password, domainID,
ar := &grpcChannelsV1.AuthzReq{
Type: uint32(msgType),
ClientId: id,
ClientId: subject,
ClientType: clientType,
ChannelId: chanID,
DomainId: domainID,
@@ -258,29 +258,29 @@ func (h *handler) authAccess(ctx context.Context, username, password, domainID,
return id, nil
}
func (h *handler) authenticate(ctx context.Context, authType, token, domainID string) (string, error) {
func (h *handler) authenticate(ctx context.Context, authType, token, domainID string) (string, string, error) {
switch authType {
case policies.UserType:
authnSession, err := h.authn.Authenticate(ctx, token)
if err != nil {
return "", err
return "", "", err
}
if authnSession.Role == smqauthn.AdminRole {
return authnSession.UserID, nil
return authnSession.UserID, authnSession.UserID, nil
}
return policies.EncodeDomainUserID(domainID, authnSession.UserID), nil
return authnSession.UserID, policies.EncodeDomainUserID(domainID, authnSession.UserID), nil
case policies.ClientType:
authnRes, err := h.clients.Authenticate(ctx, &grpcClientsV1.AuthnReq{Token: token})
if err != nil {
return "", err
return "", "", err
}
if !authnRes.Authenticated {
return "", svcerr.ErrAuthentication
return "", "", svcerr.ErrAuthentication
}
return authnRes.GetId(), nil
return authnRes.GetId(), authnRes.GetId(), nil
default:
return "", errInvalidClientType
return "", "", errInvalidClientType
}
}