feat(api): ldap and OAuth2.0

This commit is contained in:
pycook
2023-12-14 19:49:31 +08:00
parent 21bc6631f9
commit e7dfe6c573
7 changed files with 31 additions and 13 deletions

View File

@@ -11,6 +11,8 @@ from flask import session
from flask_login import login_user
from flask_login import logout_user
from api.lib.common_setting.common_data import AuthenticateDataCRUD
from api.lib.common_setting.const import AuthenticateType
from api.lib.decorator import args_required
from api.lib.decorator import args_validate
from api.lib.perm.acl.acl import ACLManager
@@ -36,7 +38,8 @@ class LoginView(APIView):
username = request.values.get("username") or request.values.get("email")
password = request.values.get("password")
_role = None
if current_app.config.get('LDAP', {}).get('enabled'):
config = AuthenticateDataCRUD(AuthenticateType.LDAP).get()
if config.get('LDAP', {}).get('enabled'):
from api.lib.perm.authentication.ldap import authenticate_with_ldap
user, authenticated = authenticate_with_ldap(username, password)
else: