feat: support rbac SSO token

pull/15707/head
Ewall555 2025-07-08 03:18:51 +00:00 committed by 老广
parent 4bf337b2b4
commit 9a446c118b
2 changed files with 5 additions and 3 deletions

View File

@ -14,7 +14,6 @@ from rest_framework.response import Response
from authentication.errors import ACLError from authentication.errors import ACLError
from common.api import JMSGenericViewSet from common.api import JMSGenericViewSet
from common.const.http import POST, GET from common.const.http import POST, GET
from common.permissions import OnlySuperUser
from common.serializers import EmptySerializer from common.serializers import EmptySerializer
from common.utils import reverse, safe_next_url from common.utils import reverse, safe_next_url
from common.utils.timezone import utc_now from common.utils.timezone import utc_now
@ -38,8 +37,11 @@ class SSOViewSet(AuthMixin, JMSGenericViewSet):
'login_url': SSOTokenSerializer, 'login_url': SSOTokenSerializer,
'login': EmptySerializer 'login': EmptySerializer
} }
rbac_perms = {
'login_url': 'authentication.add_ssotoken',
}
@action(methods=[POST], detail=False, permission_classes=[OnlySuperUser], url_path='login-url') @action(methods=[POST], detail=False, url_path='login-url')
def login_url(self, request, *args, **kwargs): def login_url(self, request, *args, **kwargs):
if not settings.AUTH_SSO: if not settings.AUTH_SSO:
raise SSOAuthClosed() raise SSOAuthClosed()

View File

@ -24,7 +24,6 @@ exclude_permissions = (
('authentication', 'privatetoken', '*', '*'), ('authentication', 'privatetoken', '*', '*'),
('authentication', 'connectiontoken', 'delete,change', 'connectiontoken'), ('authentication', 'connectiontoken', 'delete,change', 'connectiontoken'),
('authentication', 'connectiontoken', 'view', 'connectiontokensecret'), ('authentication', 'connectiontoken', 'view', 'connectiontokensecret'),
('authentication', 'ssotoken', '*', '*'),
('authentication', 'superconnectiontoken', 'change,delete', 'superconnectiontoken'), ('authentication', 'superconnectiontoken', 'change,delete', 'superconnectiontoken'),
('authentication', 'temptoken', 'delete', 'temptoken'), ('authentication', 'temptoken', 'delete', 'temptoken'),
('users', 'userpasswordhistory', '*', '*'), ('users', 'userpasswordhistory', '*', '*'),
@ -156,6 +155,7 @@ only_system_permissions = (
('authentication', 'superconnectiontoken', '*', '*'), ('authentication', 'superconnectiontoken', '*', '*'),
('authentication', 'temptoken', '*', '*'), ('authentication', 'temptoken', '*', '*'),
('authentication', 'passkey', '*', '*'), ('authentication', 'passkey', '*', '*'),
('authentication', 'ssotoken', '*', '*'),
('tickets', '*', '*', '*'), ('tickets', '*', '*', '*'),
('orgs', 'organization', 'view', 'rootorg'), ('orgs', 'organization', 'view', 'rootorg'),
('terminal', 'applet', '*', '*'), ('terminal', 'applet', '*', '*'),