mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 06:30:22 +00:00
NOISSUE - Rename Admin to SuperAdmin role
Signed-off-by: dusan <borovcanindusan1@gmail.com>
This commit is contained in:
@@ -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{
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
@@ -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
@@ -36,7 +36,7 @@ type Role uint32
|
||||
|
||||
const (
|
||||
UserRole Role = iota + 1
|
||||
AdminRole
|
||||
SuperAdminRole
|
||||
)
|
||||
|
||||
type Session struct {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user