mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-06 18:00:57 +00:00
Fix rbac (#7713)
* fix: token 系统用户增加 protocol * fix: 修复清除orphan session时同时清除对应的 session_task * perf: 修改 connection token api * fix: 修复无法获取系统角色绑定的问题 * perf: 增加 db terminal 及 magnus 组件 * perf: 修改 migrations * fix: 修复AUTHENTICATION_BACKENDS相关的逻辑 * fix: 修改判断backend认证逻辑 * fix: 修复资产账号查看密码跳过mfa * fix: 修复用户组授权权限错误 * feat: 支持COS对象存储 * feat: 升级依赖 jms_storage==0.0.42 * fix: 修复 koko api 问题 * feat: 修改存储翻译信息 * perf: 修改 ticket 权限 * fix: 修复获取资产授权系统用户 get_queryset * perf: 抽取 ticket * perf: 修改 cmd filter 的权限 * fix: 修改 ticket perm * fix: 修复oidc依赖问题 Co-authored-by: Eric <xplzv@126.com> Co-authored-by: ibuler <ibuler@qq.com> Co-authored-by: 小冯 <xiaofeng@xiaofengdeMacBook-Pro.local> Co-authored-by: feng626 <1304903146@qq.com>
This commit is contained in:
@@ -79,61 +79,9 @@ class Setting(models.Model):
|
||||
item.refresh_setting()
|
||||
|
||||
def refresh_setting(self):
|
||||
if hasattr(self.__class__, f'refresh_{self.name}'):
|
||||
getattr(self.__class__, f'refresh_{self.name}')()
|
||||
else:
|
||||
setattr(settings, self.name, self.cleaned_value)
|
||||
setattr(settings, self.name, self.cleaned_value)
|
||||
self.refresh_keycloak_to_openid_if_need()
|
||||
|
||||
@classmethod
|
||||
def refresh_authentications(cls, name):
|
||||
setting = cls.objects.filter(name=name).first()
|
||||
if not setting:
|
||||
return
|
||||
|
||||
backends_map = {
|
||||
'AUTH_LDAP': [settings.AUTH_BACKEND_LDAP],
|
||||
'AUTH_OPENID': [settings.AUTH_BACKEND_OIDC_CODE, settings.AUTH_BACKEND_OIDC_PASSWORD],
|
||||
'AUTH_RADIUS': [settings.AUTH_BACKEND_RADIUS],
|
||||
'AUTH_CAS': [settings.AUTH_BACKEND_CAS],
|
||||
'AUTH_SAML2': [settings.AUTH_BACKEND_SAML2],
|
||||
}
|
||||
setting_backends = backends_map[name]
|
||||
auth_backends = settings.AUTHENTICATION_BACKENDS
|
||||
|
||||
for backend in setting_backends:
|
||||
has = backend in auth_backends
|
||||
|
||||
# 添加
|
||||
if setting.cleaned_value and not has:
|
||||
logger.debug('Add auth backend: {}'.format(name))
|
||||
settings.AUTHENTICATION_BACKENDS.insert(1, backend)
|
||||
|
||||
# 去掉
|
||||
if not setting.cleaned_value and has:
|
||||
index = auth_backends.index(backend)
|
||||
logger.debug('Pop auth backend: {}'.format(name))
|
||||
auth_backends.pop(index)
|
||||
|
||||
# 设置内存值
|
||||
setattr(settings, name, setting.cleaned_value)
|
||||
|
||||
@classmethod
|
||||
def refresh_AUTH_CAS(cls):
|
||||
cls.refresh_authentications('AUTH_CAS')
|
||||
|
||||
@classmethod
|
||||
def refresh_AUTH_LDAP(cls):
|
||||
cls.refresh_authentications('AUTH_LDAP')
|
||||
|
||||
@classmethod
|
||||
def refresh_AUTH_OPENID(cls):
|
||||
cls.refresh_authentications('AUTH_OPENID')
|
||||
|
||||
@classmethod
|
||||
def refresh_AUTH_SAML2(cls):
|
||||
cls.refresh_authentications('AUTH_SAML2')
|
||||
|
||||
def refresh_keycloak_to_openid_if_need(self):
|
||||
watch_config_names = [
|
||||
'AUTH_OPENID', 'AUTH_OPENID_REALM_NAME', 'AUTH_OPENID_SERVER_URL',
|
||||
@@ -170,10 +118,6 @@ class Setting(models.Model):
|
||||
setattr(settings, key, value)
|
||||
self.__class__.update_or_create(key, value, encrypted=False, category=self.category)
|
||||
|
||||
@classmethod
|
||||
def refresh_AUTH_RADIUS(cls):
|
||||
cls.refresh_authentications('AUTH_RADIUS')
|
||||
|
||||
@classmethod
|
||||
def update_or_create(cls, name='', value='', encrypted=False, category=''):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user