mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-23 20:39:26 +00:00
feat: 支持自定义认证 backend;统一其他认证方式的信号触发逻辑;
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import os
|
||||
from django.conf import settings
|
||||
import inspect
|
||||
from django.utils.module_loading import import_string
|
||||
from common.utils import get_logger
|
||||
from django.contrib.auth import get_user_model
|
||||
@@ -15,6 +13,9 @@ logger = get_logger(__file__)
|
||||
class CustomAuthBackend(JMSModelBackend):
|
||||
custom_auth_method_path = 'data.auth.main.authenticate'
|
||||
|
||||
def load_authenticate_method(self):
|
||||
return import_string(self.custom_auth_method_path)
|
||||
|
||||
def is_enabled(self):
|
||||
try:
|
||||
self.load_authenticate_method()
|
||||
@@ -35,9 +36,6 @@ class CustomAuthBackend(JMSModelBackend):
|
||||
)
|
||||
return user, created
|
||||
|
||||
def load_authenticate_method(self):
|
||||
return import_string(self.custom_auth_method_path)
|
||||
|
||||
def authenticate(self, request, username=None, password=None, **kwargs):
|
||||
try:
|
||||
authenticate = self.load_authenticate_method()
|
||||
|
Reference in New Issue
Block a user