NOISSUE - Rename Admin to SuperAdmin role

Signed-off-by: dusan <borovcanindusan1@gmail.com>
This commit is contained in:
dusan
2026-03-11 16:52:34 +01:00
parent 28ae84286e
commit df2446c2cc
10 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -354,7 +354,7 @@ func (am *authorizationMiddleware) authorize(ctx context.Context, session authn.
}
func (am *authorizationMiddleware) checkSuperAdmin(ctx context.Context, session authn.Session) error {
if session.Role != authn.AdminRole {
if session.Role != authn.SuperAdminRole {
return svcerr.ErrSuperAdminAction
}
if err := am.authz.Authorize(ctx, smqauthz.PolicyReq{
+1 -1
View File
@@ -291,7 +291,7 @@ func (am *authorizationMiddleware) authorize(ctx context.Context, session authn.
}
func (am *authorizationMiddleware) checkSuperAdmin(ctx context.Context, session authn.Session) error {
if session.Role != authn.AdminRole {
if session.Role != authn.SuperAdminRole {
return svcerr.ErrSuperAdminAction
}
if err := am.authz.Authorize(ctx, smqauthz.PolicyReq{
+1 -1
View File
@@ -261,7 +261,7 @@ func (am *authorizationMiddleware) checkAdmin(ctx context.Context, session authn
}
func (am *authorizationMiddleware) checkSuperAdmin(ctx context.Context, session authn.Session) error {
if session.Role != authn.AdminRole {
if session.Role != authn.SuperAdminRole {
return svcerr.ErrSuperAdminAction
}
if err := am.authz.Authorize(ctx, smqauthz.PolicyReq{
+1 -1
View File
@@ -367,7 +367,7 @@ func (am *authorizationMiddleware) ListChildrenGroups(ctx context.Context, sessi
}
func (am *authorizationMiddleware) checkSuperAdmin(ctx context.Context, session authn.Session) error {
if session.Role != authn.AdminRole {
if session.Role != authn.SuperAdminRole {
return svcerr.ErrSuperAdminAction
}
if err := am.authz.Authorize(ctx, smqauthz.PolicyReq{
+1 -1
View File
@@ -264,7 +264,7 @@ func (h *handler) authenticate(ctx context.Context, authType, token, domainID st
if err != nil {
return "", "", err
}
if authnSession.Role == smqauthn.AdminRole {
if authnSession.Role == smqauthn.SuperAdminRole {
return authnSession.UserID, authnSession.UserID, nil
}
return authnSession.UserID, policies.EncodeDomainUserID(domainID, authnSession.UserID), nil
+2 -2
View File
@@ -227,7 +227,7 @@ func TestAuthPublish(t *testing.T) {
domainID: domainID,
clientID: userID,
superAdmin: true,
authNRes1: smqauthn.Session{UserID: userID, Role: smqauthn.AdminRole},
authNRes1: smqauthn.Session{UserID: userID, Role: smqauthn.SuperAdminRole},
authNErr: nil,
authZRes: &grpcChannelsV1.AuthzRes{Authorized: true},
err: nil,
@@ -536,7 +536,7 @@ func TestAuthSubscribe(t *testing.T) {
domainID: domainID,
clientID: userID,
superAdmin: true,
authNRes1: smqauthn.Session{UserID: userID, Role: smqauthn.AdminRole},
authNRes1: smqauthn.Session{UserID: userID, Role: smqauthn.SuperAdminRole},
authNErr: nil,
authZRes: &grpcChannelsV1.AuthzRes{Authorized: true},
err: nil,
+1 -1
View File
@@ -36,7 +36,7 @@ type Role uint32
const (
UserRole Role = iota + 1
AdminRole
SuperAdminRole
)
type Session struct {
+2 -2
View File
@@ -138,7 +138,7 @@ func (a *authnMiddleware) Middleware() func(http.Handler) http.Handler {
return
}
if resp.Type == AccessToken && !opts.allowUnverifiedUser && resp.Role != AdminRole && !resp.Verified {
if resp.Type == AccessToken && !opts.allowUnverifiedUser && resp.Role != SuperAdminRole && !resp.Verified {
encodeError(w, apiutil.ErrEmailNotVerified, http.StatusUnauthorized)
return
}
@@ -151,7 +151,7 @@ func (a *authnMiddleware) Middleware() func(http.Handler) http.Handler {
}
resp.DomainID = domain
switch resp.Role {
case AdminRole:
case SuperAdminRole:
resp.DomainUserID = resp.UserID
case UserRole:
resp.DomainUserID = policies.EncodeDomainUserID(domain, resp.UserID)
+1 -1
View File
@@ -1772,7 +1772,7 @@ func TestUpdateProfilePicture(t *testing.T) {
},
contentType: contentType,
token: validToken,
authnRes: smqauthn.Session{UserID: validID, DomainID: domainID, Role: smqauthn.AdminRole},
authnRes: smqauthn.Session{UserID: validID, DomainID: domainID, Role: smqauthn.SuperAdminRole},
status: http.StatusOK,
err: nil,
},
+1 -1
View File
@@ -190,7 +190,7 @@ func (am *authorizationMiddleware) OAuthAddUserPolicy(ctx context.Context, user
}
func (am *authorizationMiddleware) checkSuperAdmin(ctx context.Context, session authn.Session) error {
if session.Role != authn.AdminRole {
if session.Role != authn.SuperAdminRole {
return svcerr.ErrSuperAdminAction
}
if err := am.authz.Authorize(ctx, smqauthz.PolicyReq{