repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
jumpserver | apps/authentication/backends/token.py | .py | from django.utils import timezone
from django.conf import settings
from django.core.exceptions import PermissionDenied
from authentication.models import TempToken
from .base import JMSBaseAuthBackend
class TempTokenAuthBackend(JMSBaseAuthBackend):
model = TempToken
@staticmethod
def is_enabled():
... | 30 | 883 |
jumpserver | apps/authentication/backends/custom.py | .py | from django.conf import settings
from django.contrib.auth import get_user_model
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy as _
from common.utils import get_logger
from .base import JMSBaseAuthBackend
logger = get_logger(__file__)
custom_authenticate_metho... | 54 | 1,945 |
jumpserver | apps/authentication/backends/ldap.py | .py | # coding:utf-8
#
import abc
import ldap
from django.conf import settings
from django.core.cache import cache
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django_auth_ldap.backend import _LDAPUser, LDAPBackend, valid_cache_key
from django_auth_ldap.config import _LDAPConfig, LDAPSearc... | 284 | 10,337 |
jumpserver | apps/authentication/backends/sso.py | .py | from django.conf import settings
from .base import JMSBaseAuthBackend
class SSOAuthentication(JMSBaseAuthBackend):
@staticmethod
def is_enabled():
return settings.AUTH_SSO
def authenticate(self):
pass
class CustomSSOAuthentication(JMSBaseAuthBackend):
@staticmethod
def is_enabl... | 69 | 1,307 |
jumpserver | apps/authentication/backends/drf.py | .py | # -*- coding: utf-8 -*-
#
import os
from django.contrib.auth import get_user_model
from django.core.cache import cache
from django.utils import timezone
from django.utils.translation import gettext as _
from rest_framework import authentication, exceptions
from accounts.models import IntegrationApplication
from commo... | 185 | 6,343 |
jumpserver | apps/authentication/backends/pubkey.py | .py | # -*- coding: utf-8 -*-
#
from django.conf import settings
from django.contrib.auth import get_user_model
from common.permissions import ServiceAccountSignaturePermission
from .base import JMSBaseAuthBackend
UserModel = get_user_model()
__all__ = ['PublicKeyAuthBackend']
class PublicKeyAuthBackend(JMSBaseAuthBacke... | 43 | 1,313 |
jumpserver | apps/authentication/backends/base.py | .py | from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend
from common.utils import get_logger
from users.models import User
from authentication.signals import backend_auth_failed
from authentication.errors import reason_choices, reason_user_invalid
UserModel = get_user_model... | 84 | 3,097 |
jumpserver | apps/authentication/backends/oauth2_provider/utils.py | .py | from django.conf import settings
from django.core.cache import cache
from oauth2_provider.models import get_application_model
from common.utils import get_logger
logger = get_logger(__name__)
def get_or_create_jumpserver_client_application():
"""Auto get or create OAuth2 JumpServer Client application."""
App... | 31 | 1,115 |
jumpserver | apps/authentication/backends/oauth2_provider/views.py | .py | from django.views.generic import View
from django.http import JsonResponse
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from django.views.decorators.csrf import csrf_exempt
from django.conf import settings
from django.urls import reverse
from oauth2_provider.... | 77 | 3,494 |
jumpserver | apps/authentication/backends/oauth2_provider/urls.py | .py | # -*- coding: utf-8 -*-
#
from django.urls import path
from oauth2_provider import views as op_views
from . import views
urlpatterns = [
path("authorize/", op_views.AuthorizationView.as_view(), name="authorize"),
path("token/", op_views.TokenView.as_view(), name="token"),
path("revoke/", op_views.RevokeT... | 15 | 497 |
jumpserver | apps/authentication/backends/oauth2_provider/signal_handlers.py | .py | from django.db.models.signals import post_delete
from django.dispatch import receiver
from django.conf import settings
from oauth2_provider.models import get_application_model
from common.signals import django_ready
from .utils import clear_oauth2_authorization_server_view_cache
__all__ = [
'on_django_ready_clea... | 28 | 841 |
jumpserver | apps/authentication/backends/oidc/middleware.py | .py | import time
import requests
import requests.exceptions
from django.conf import settings
from django.contrib import auth
from django.core.exceptions import MiddlewareNotUsed
from common.utils import get_logger
from .decorator import ssl_verification
from .utils import validate_and_return_id_token
logger = get_logger(... | 111 | 4,506 |
jumpserver | apps/authentication/backends/oidc/utils.py | .py | """
OpenID Connect relying party (RP) utilities
===========================================
This modules defines utilities allowing to manipulate ID tokens and other common helpers.
"""
import datetime as dt
from calendar import timegm
from urllib.parse import urlparse
from django.conf import settings
f... | 113 | 4,721 |
jumpserver | apps/authentication/backends/oidc/backends.py | .py | """
OpenID Connect relying party (RP) authentication backends
=========================================================
This modules defines backends allowing to authenticate a user using a specific token endpoint
of an OpenID Connect provider (OP).
"""
import base64
import requests
from django.conf... | 307 | 13,223 |
jumpserver | apps/authentication/backends/oidc/decorator.py | .py | # coding: utf-8
#
import warnings
import contextlib
import requests
import inspect
from functools import wraps
from django.conf import settings
from urllib3.exceptions import InsecureRequestWarning
from .utils import get_logger
__all__ = ['ssl_verification']
old_merge_environment_settings = requests.Session.merge... | 64 | 1,845 |
jumpserver | apps/authentication/backends/oidc/views.py | .py | """
OpenID Connect relying party (RP) views
=======================================
This modules defines views allowing to start the authorization and authentication process in
order to authenticate a specific user. The most important views are: the "login" allowing to
authenticate the users using ... | 258 | 11,861 |
jumpserver | apps/authentication/backends/oidc/signals.py | .py | """
OpenID Connect relying party (RP) signals
=========================================
This modules defines Django signals that can be triggered during the OpenID Connect
authentication process.
"""
from django.dispatch import Signal
openid_create_or_update_user = Signal()
| 13 | 295 |
jumpserver | apps/authentication/backends/oidc/urls.py | .py | """
OpenID Connect relying party (RP) URLs
======================================
This modules defines the URLs allowing to perform OpenID Connect flows on a Relying Party (RP).
It defines three main endpoints: the authentication request endpoint, the authentication
callback endpoint and the end se... | 20 | 638 |
jumpserver | apps/authentication/backends/ukey/utils.py | .py | # -*- coding: utf-8 -*-
#
import base64
# SM2 曲线 OID:1.2.156.10197.1.301
# DER 编码:06 08 2a 81 1c cf 55 01 82 2d
SM2_OID_DER = bytes([0x06, 0x08, 0x2a, 0x81, 0x1c, 0xcf, 0x55, 0x01, 0x82, 0x2d])
def is_sm2_pem(pem_content):
"""
通过查找 SM2 曲线 OID 字节序列判断 PEM 数据(证书 / CSR / 公钥等)是否使用 SM2 算法。
pem_content: 标准 PEM... | 48 | 1,588 |
jumpserver | apps/authentication/backends/ukey/backends.py | .py | # -*- coding: utf-8 -*-
#
import base64
import os
import tempfile
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.utils.translation import gettext_lazy as _
from users.models import User
from common.utils import get_logger
from ..base import JMSBaseAuthBackend
from .s... | 361 | 14,643 |
jumpserver | apps/authentication/backends/ukey/exceptions.py | .py | # -*- coding: utf-8 -*-
#
from django.utils.translation import gettext_lazy as _
class UKeyAuthError(Exception):
"""证书认证失败基类,所有子类须带可展示给用户的 msg。"""
default_msg = _('Certificate authentication failed')
def __init__(self, msg=None, **kwargs):
self.msg = msg or self.default_msg
super().__init... | 45 | 1,211 |
jumpserver | apps/authentication/backends/ukey/api_urls.py | .py |
from django.urls import path
from . import api
app_name = 'ukey'
urlpatterns = [
path('ukey-sdk.js/', api.UKeySDKScriptFileAPIView.as_view(), name='ukey-sdk-script'),
path('ukey-sdk-config/', api.UKeySDKConfigFileAPIView.as_view(), name='ukey-sdk-config'),
path('enroll-cert/', api.UKeyCertEnrollAPIView.a... | 12 | 358 |
jumpserver | apps/authentication/backends/ukey/view_urls.py | .py | from . import views
from django.urls import path
urlpatterns = [
path('login/', views.UKeyLoginView.as_view(), name='ukey-login')
]
| 8 | 138 |
jumpserver | apps/authentication/backends/ukey/views.py | .py | # -*- coding: utf-8 -*-
#
import secrets
from urllib.parse import urlencode
from django.conf import settings
from django.contrib.auth import authenticate
from django.core.cache import cache
from django.utils.decorators import method_decorator
from django.utils.translation import gettext as _
from django.views.decorato... | 169 | 6,197 |
jumpserver | apps/authentication/backends/ukey/sdk.py | .py | import os
import yaml
from django.conf import settings
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from common.utils import get_logger
from common.const import Language
from .utils import detect_cert_algorithm
logger = get_logger(__name__)
class UKeySDKConfig:
def __i... | 253 | 10,159 |
jumpserver | apps/authentication/backends/ukey/api.py | .py |
import base64
import os
import subprocess
import tempfile
from django.utils.translation import gettext_lazy as _
import yaml
from django.conf import settings
from django.http import Http404, HttpResponse
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_control
from ... | 235 | 9,006 |
jumpserver | apps/authentication/backends/ukey/forms.py | .py | from django import forms
from django.utils.translation import gettext_lazy as _
class UKeyLoginForm(forms.Form):
username = forms.CharField(
required=True,
label=_('Username'),
widget=forms.HiddenInput(),
)
cert = forms.CharField(
required=True,
widget=forms.Hidden... | 24 | 530 |
jumpserver | apps/authentication/backends/saml2/backends.py | .py | # -*- coding: utf-8 -*-
#
from django.contrib.auth import get_user_model
from django.conf import settings
from django.db import transaction
from common.utils import get_logger
from .signals import (
saml2_create_or_update_user
)
from ..base import RedirectAuthBackend
__all__ = ['SAML2Backend']
logger = get_logge... | 67 | 2,267 |
jumpserver | apps/authentication/backends/saml2/views.py | .py | import copy
from urllib import parse
from django.conf import settings
from django.contrib import auth
from django.db import IntegrityError
from django.http import HttpResponseRedirect, HttpResponse, HttpResponseServerError
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from djan... | 335 | 12,362 |
jumpserver | apps/authentication/backends/saml2/signals.py | .py | from django.dispatch import Signal
saml2_create_or_update_user = Signal()
| 4 | 75 |
jumpserver | apps/authentication/backends/saml2/urls.py | .py | # -*- coding: utf-8 -*-
#
from django.urls import path
from . import views
urlpatterns = [
path('login/', views.Saml2AuthRequestView.as_view(), name='saml2-login'),
path('logout/', views.Saml2EndSessionView.as_view(), name='saml2-logout'),
path('callback/', views.Saml2AuthCallbackView.as_view(), name='sam... | 13 | 422 |
jumpserver | apps/authentication/backends/saml2/settings.py | .py | from django.conf import settings
from onelogin.saml2.settings import OneLogin_Saml2_Settings
class JmsSaml2Settings(OneLogin_Saml2_Settings):
def get_sp_key(self):
key = getattr(settings, 'SAML2_SP_KEY_CONTENT', '')
return key
def get_sp_cert(self):
cert = getattr(settings, 'SAML2_SP_... | 13 | 359 |
jumpserver | apps/authentication/backends/cas/middleware.py | .py | from django_cas_ng.middleware import CASMiddleware as _CASMiddleware
from django.core.exceptions import MiddlewareNotUsed
from django.conf import settings
class CASMiddleware(_CASMiddleware):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if not settings.AUTH_CAS:
... | 11 | 347 |
jumpserver | apps/authentication/backends/cas/utils.py | .py | from django_cas_ng import utils
from django_cas_ng.utils import (
django_settings, get_protocol,
urllib_parse, REDIRECT_FIELD_NAME, get_redirect_url
)
def get_service_url(request, redirect_to=None):
"""
重写 get_service url 方法, CAS_ROOT_PROXIED_AS 为空时, 支持跳转回当前访问的域名地址
"""
"""Generates application... | 33 | 1,046 |
jumpserver | apps/authentication/backends/cas/backends.py | .py | # -*- coding: utf-8 -*-
#
from django.conf import settings
from django_cas_ng.backends import CASBackend as _CASBackend
from common.utils import get_logger
from ..base import RedirectAuthBackend
__all__ = ['CASBackend']
logger = get_logger(__name__)
class CASBackend(RedirectAuthBackend, _CASBackend):
backend =... | 28 | 840 |
jumpserver | apps/authentication/backends/cas/views.py | .py | from django.contrib.auth import logout as auth_logout
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from django_cas_ng.views import LoginView
from authentication.views.mixins import... | 29 | 967 |
jumpserver | apps/authentication/backends/cas/urls.py | .py | # -*- coding: utf-8 -*-
#
import django_cas_ng.views
from django.urls import path
from .views import CASLoginView
urlpatterns = [
path('login/', CASLoginView.as_view(), name='cas-login'),
path('logout/', django_cas_ng.views.LogoutView.as_view(), name='cas-logout'),
path('callback/', django_cas_ng.views.Ca... | 13 | 371 |
jumpserver | apps/authentication/backends/oauth2/backends.py | .py | # -*- coding: utf-8 -*-
#
import base64
import requests
from django.utils.translation import gettext_lazy as _
from django.contrib.auth import get_user_model
from django.utils.http import urlencode
from django.conf import settings
from django.urls import reverse
from common.utils import get_logger
from users.utils im... | 166 | 6,647 |
jumpserver | apps/authentication/backends/oauth2/views.py | .py | import uuid
from django.conf import settings
from django.contrib import auth
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.utils.http import urlencode
from django.utils.translation import gettext_lazy as _
from django.views import View
from authentication.decorators import pr... | 126 | 4,938 |
jumpserver | apps/authentication/backends/oauth2/signals.py | .py | from django.dispatch import Signal
oauth2_create_or_update_user = Signal()
| 4 | 76 |
jumpserver | apps/authentication/backends/oauth2/urls.py | .py | # -*- coding: utf-8 -*-
#
from django.urls import path
from . import views
urlpatterns = [
path('login/', views.OAuth2AuthRequestView.as_view(), name='login'),
path('callback/', views.OAuth2AuthCallbackView.as_view(), name='login-callback'),
path('logout/', views.OAuth2EndSessionView.as_view(), name='logo... | 12 | 327 |
jumpserver | apps/authentication/backends/test/test_drf.py | .py | import os
import requests
from httpsig.requests_auth import HTTPSignatureAuth
import datetime
def test_drf_ak():
KEY_ID = os.environ.get('KEY_ID') or ''
SECRET = os.environ.get('KEY_SECRET') or ''
signature_headers = ['(request-target)', 'date']
now = datetime.datetime.now()
headers = {
'Ho... | 31 | 875 |
jumpserver | apps/authentication/backends/radius/backends.py | .py | # -*- coding: utf-8 -*-
#
import traceback
from django.conf import settings
from django.contrib.auth import get_user_model
from radiusauth.backends import RADIUSBackend, RADIUSRealmBackend
from authentication.backends.base import JMSBaseAuthBackend
from .signals import radius_create_user
User = get_user_model()
cl... | 61 | 1,978 |
jumpserver | apps/authentication/backends/radius/signals.py | .py | from django.dispatch import Signal
radius_create_user = Signal()
| 4 | 66 |
jumpserver | apps/authentication/backends/passkey/backends.py | .py | from django.conf import settings
from ..base import JMSModelBackend
class PasskeyAuthBackend(JMSModelBackend):
@staticmethod
def is_enabled():
return settings.AUTH_PASSKEY
def user_can_authenticate(self, user):
return user.source == 'local'
| 13 | 273 |
jumpserver | apps/authentication/backends/passkey/models.py | .py | from django.conf import settings
from django.db import models
from django.utils.translation import gettext_lazy as _
from common.db.models import JMSBaseModel
class Passkey(JMSBaseModel):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
name = models.CharField(max_length=255, verb... | 20 | 932 |
jumpserver | apps/authentication/backends/passkey/urls.py | .py | from rest_framework.routers import DefaultRouter
from . import api
router = DefaultRouter()
router.register('passkeys', api.PasskeyViewSet, 'passkey')
urlpatterns = []
urlpatterns += router.urls
| 10 | 198 |
jumpserver | apps/authentication/backends/passkey/fido.py | .py | import json
from urllib.parse import urlparse
import fido2.features
from django.conf import settings
from django.utils import timezone
from django.utils.translation import gettext as _
from fido2.server import Fido2Server
from fido2.utils import websafe_decode, websafe_encode
from fido2.webauthn import PublicKeyCreden... | 161 | 5,097 |
jumpserver | apps/authentication/backends/passkey/serializer.py | .py | from rest_framework import serializers
from .models import Passkey
class PasskeySerializer(serializers.ModelSerializer):
class Meta:
model = Passkey
fields = [
'id', 'name', 'is_active', 'platform', 'created_by',
'date_last_used', 'date_created',
]
read_onl... | 14 | 365 |
jumpserver | apps/authentication/backends/passkey/api.py | .py | import time
from django.conf import settings
from django.http import JsonResponse
from django.shortcuts import render
from django.utils.translation import gettext as _
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated, AllowAny
from rest_framework.response import Respo... | 91 | 3,693 |
jumpserver | apps/authentication/confirm/password.py | .py | from django.utils.translation import gettext_lazy as _
from authentication.mixins import authenticate
from .base import BaseConfirm
from ..const import ConfirmType
class ConfirmPassword(BaseConfirm):
name = ConfirmType.PASSWORD.value
display_name = ConfirmType.PASSWORD.name
def check(self):
retu... | 30 | 855 |
jumpserver | apps/authentication/confirm/__init__.py | .py | from .mfa import ConfirmMFA
from .password import ConfirmPassword
from .relogin import ConfirmReLogin
CONFIRM_BACKENDS = [ConfirmReLogin, ConfirmPassword, ConfirmMFA]
CONFIRM_BACKEND_MAP = {backend.name: backend for backend in CONFIRM_BACKENDS}
| 7 | 246 |
jumpserver | apps/authentication/confirm/relogin.py | .py | from datetime import datetime
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from .base import BaseConfirm
from ..const import ConfirmType
SPECIFIED_TIME = 5
RELOGIN_ERROR = _('Login time has exceeded {} minutes, please login again').format(SPECIFIED_TIME)
class ConfirmRe... | 32 | 1,000 |
jumpserver | apps/authentication/confirm/mfa.py | .py | from users.models import User
from .base import BaseConfirm
from ..const import ConfirmType
class ConfirmMFA(BaseConfirm):
name = ConfirmType.MFA.value
display_name = ConfirmType.MFA.name
def check(self):
return self.user.active_mfa_backends and self.user.mfa_enabled
@property
def conte... | 29 | 866 |
jumpserver | apps/authentication/confirm/base.py | .py | import abc
class BaseConfirm(abc.ABC):
def __init__(self, user, request):
self.user = user
self.request = request
@property
@abc.abstractmethod
def name(self) -> str:
return ''
@property
@abc.abstractmethod
def display_name(self) -> str:
return ''
@ab... | 30 | 561 |
jumpserver | apps/authentication/errors/redirect.py | .py | from django.urls import reverse
from django.utils.translation import gettext_lazy as _
from common.exceptions import JMSException
from . import const
class NeedMoreInfoError(Exception):
error = ''
msg = ''
def __init__(self, error='', msg=''):
if error:
self.error = error
if ... | 113 | 2,960 |
jumpserver | apps/authentication/errors/failed.py | .py | # -*- coding: utf-8 -*-
#
from django.conf import settings
from django.utils.translation import gettext_lazy as _
from users.utils import LoginBlockUtil, MFABlockUtils, LoginIpBlockUtil
from . import const
from ..signals import post_auth_failed
class AuthFailedNeedLogMixin:
username = ''
request = None
e... | 188 | 5,998 |
jumpserver | apps/authentication/errors/mfa.py | .py | from django.utils.translation import gettext_lazy as _
from common.exceptions import JMSException
class SSOAuthClosed(JMSException):
default_code = 'sso_auth_closed'
default_detail = _('SSO auth closed')
class WeComCodeInvalid(JMSException):
default_code = 'wecom_code_invalid'
default_detail = 'Cod... | 57 | 1,489 |
jumpserver | apps/authentication/errors/const.py | .py | from django.utils.translation import gettext_lazy as _
reason_password_failed = 'password_failed'
reason_password_decrypt_failed = 'password_decrypt_failed'
reason_mfa_failed = 'mfa_failed'
reason_mfa_unset = 'mfa_unset'
reason_user_not_exist = 'user_not_exist'
reason_password_expired = 'password_expired'
reason_user... | 80 | 3,062 |
jumpserver | apps/authentication/tests/access_key.py | .py | # Python 示例
# pip install requests drf-httpsig
import datetime
import json
import requests
from httpsig.requests_auth import HTTPSignatureAuth
def get_auth(KeyID, SecretID):
signature_headers = ['(request-target)', 'accept', 'date']
auth = HTTPSignatureAuth(key_id=KeyID, secret=SecretID, algorithm='hmac-sha2... | 35 | 1,026 |
jumpserver | apps/authentication/api/ssh_key.py | .py | from common.api import JMSModelViewSet
from common.permissions import IsValidUser
from ..models import SSHKey
from ..serializers import SSHKeySerializer
from users.notifications import ResetPublicKeySuccessMsg
class SSHkeyViewSet(JMSModelViewSet):
queryset = SSHKey.objects.none()
serializer_class = SSHKeySeri... | 22 | 738 |
jumpserver | apps/authentication/api/password.py | .py | import time
from django.conf import settings
from django.core.cache import cache
from django.http import HttpResponseRedirect
from django.shortcuts import reverse
from django.template.loader import render_to_string
from django.utils.translation import gettext as _
from rest_framework import status
from rest_framework.... | 129 | 5,457 |
jumpserver | apps/authentication/api/temp_token.py | .py | from django.utils import timezone
from rest_framework.response import Response
from rest_framework.decorators import action
from rbac.permissions import RBACPermission
from common.api import JMSModelViewSet
from ..models import TempToken
from ..serializers import TempTokenSerializer
class TempTokenViewSet(JMSModelVi... | 30 | 1,014 |
jumpserver | apps/authentication/api/token.py | .py | # -*- coding: utf-8 -*-
#
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.generics import CreateAPIView
from common.utils import get_logger
from .. import serializers, errors
from ..mixins import AuthMixin
logger = get_logger(__name__)
__all__ = ['To... | 48 | 1,669 |
jumpserver | apps/authentication/api/custom_sso.py | .py | from django.utils.module_loading import import_string
from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth import login
from django.http.response import HttpResponseRedirect
from rest_framework.generics import RetrieveAPIView
from rest_framework.response import Respo... | 100 | 3,807 |
jumpserver | apps/authentication/api/feishu.py | .py | from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.views import APIView
from common.permissions import IsValidUser
from common.utils import get_logger
logger = get_logger(__name__)
class FeiShuEventSubscriptionCallback(APIView):
"""
# https://open.fe... | 20 | 514 |
jumpserver | apps/authentication/api/confirm.py | .py | # -*- coding: utf-8 -*-
#
import time
from django.utils.translation import gettext_lazy as _
from rest_framework import status
from rest_framework.decorators import action
from rest_framework.generics import RetrieveAPIView
from rest_framework.response import Response
from authentication.permissions import UserConfir... | 77 | 2,815 |
jumpserver | apps/authentication/api/sso.py | .py | from urllib.parse import urlencode
from uuid import UUID
from django.conf import settings
from django.contrib.auth import login
from django.http.response import HttpResponseRedirect
from rest_framework import serializers
from rest_framework import status
from rest_framework.decorators import action
from rest_framework... | 133 | 5,067 |
jumpserver | apps/authentication/api/login_confirm.py | .py | # -*- coding: utf-8 -*-
#
from django.contrib.auth import logout as auth_logout
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.views import APIView
from common.utils import get_logger
from .. import errors, mixins
__all__ = ['TicketStatusApi']
logger ... | 43 | 1,505 |
jumpserver | apps/authentication/api/access_key.py | .py | # -*- coding: utf-8 -*-
#
from django.utils.translation import gettext as _
from rest_framework import serializers
from rest_framework.response import Response
from common.api import JMSModelViewSet
from rbac.permissions import RBACPermission
from ..const import ConfirmType
from ..permissions import UserConfirmation
... | 49 | 1,609 |
jumpserver | apps/authentication/api/session.py | .py | import time
from threading import Thread
from django.conf import settings
from django.contrib.auth import logout
from django.contrib.auth.models import AnonymousUser
from rest_framework import generics
from rest_framework import status
from rest_framework.response import Response
from common.sessions.cache import use... | 69 | 2,179 |
jumpserver | apps/authentication/api/common.py | .py | from django.utils.translation import gettext_lazy as _
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.views import APIView
from authentication import errors
from authentication.const import ConfirmType
from authentication.permissions import UserConfirmation
... | 52 | 1,897 |
jumpserver | apps/authentication/api/mfa.py | .py | # -*- coding: utf-8 -*-
#
from django.shortcuts import get_object_or_404
from django.utils.translation import gettext as _
from rest_framework import exceptions
from rest_framework.generics import CreateAPIView
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framew... | 100 | 3,304 |
jumpserver | apps/authentication/api/connection_token.py | .py | import base64
import json
import os
import urllib.parse
from struct import pack
from cryptography import x509
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.serialization import pkcs7
from django.conf import settings
from django.http import HttpResponse
from django... | 948 | 40,064 |
jumpserver | apps/authentication/api/lark.py | .py | from common.utils import get_logger
from .feishu import FeiShuEventSubscriptionCallback
logger = get_logger(__name__)
class LarkEventSubscriptionCallback(FeiShuEventSubscriptionCallback):
pass
| 9 | 200 |
jumpserver | apps/authentication/api/access_token.py | .py | from django.shortcuts import get_object_or_404
from django.utils.translation import gettext as _
from rest_framework.decorators import action
from rest_framework.response import Response
from rest_framework.status import HTTP_204_NO_CONTENT, HTTP_404_NOT_FOUND
from oauth2_provider.models import get_access_token_model... | 48 | 1,699 |
jumpserver | apps/authentication/api/face.py | .py | from django.core.cache import cache
from django.utils.translation import gettext as _
from rest_framework.exceptions import NotFound
from rest_framework.generics import CreateAPIView, RetrieveAPIView
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.seriali... | 256 | 8,803 |
jumpserver | apps/authentication/mfa/email.py | .py | from django.conf import settings
from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _
from common.utils import random_string
from common.utils.verify_code import SendAndVerifyCodeUtil
from settings.utils import get_login_title
from .base import BaseMFA
from ..const... | 75 | 2,189 |
jumpserver | apps/authentication/mfa/custom.py | .py | from django.conf import settings
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy as _
from common.utils import get_logger
from .base import BaseMFA
from ..const import MFAType
logger = get_logger(__file__)
mfa_custom_method = None
if settings.MFA_CUSTOM:
"... | 61 | 1,693 |
jumpserver | apps/authentication/mfa/sms.py | .py | from django.conf import settings
from django.utils.translation import gettext_lazy as _
from common.utils.verify_code import SendAndVerifyCodeUtil
from users.serializers import SmsUserSerializer
from .base import BaseMFA
from ..const import MFAType
sms_failed_msg = _("SMS verify code invalid")
class MFASms(BaseMFA)... | 72 | 1,806 |
jumpserver | apps/authentication/mfa/otp.py | .py | from django.shortcuts import reverse
from django.utils.translation import gettext_lazy as _
from .base import BaseMFA
from ..const import MFAType
otp_failed_msg = _("OTP code invalid, or server time error")
class MFAOtp(BaseMFA):
name = MFAType.OTP.value
display_name = MFAType.OTP.name
placeholder = _('... | 52 | 1,338 |
jumpserver | apps/authentication/mfa/passkey.py | .py | from django.conf import settings
from django.utils.translation import gettext_lazy as _
from authentication.mfa.base import BaseMFA
from ..const import MFAType
class MFAPasskey(BaseMFA):
name = MFAType.Passkey.value
display_name = MFAType.Passkey.name
placeholder = 'Passkey'
has_code = False
def... | 49 | 1,118 |
jumpserver | apps/authentication/mfa/radius.py | .py | from django.conf import settings
from django.utils.translation import gettext_lazy as _
from .base import BaseMFA
from ..backends.radius import RadiusBackend
from ..const import MFAType
mfa_failed_msg = _("Radius verify code invalid")
class MFARadius(BaseMFA):
name = MFAType.Radius.value
display_name = MFAT... | 49 | 1,170 |
jumpserver | apps/authentication/mfa/base.py | .py | import abc
from django.conf import settings
from django.core.cache import cache
from django.utils.translation import gettext_lazy as _
class BaseMFA(abc.ABC):
placeholder = _('Please input security code')
skip_cache_check = False
has_code = True
def __init__(self, user):
"""
:param u... | 103 | 2,283 |
jumpserver | apps/authentication/mfa/face.py | .py | from django.conf import settings
from django.utils.translation import gettext_lazy as _
from authentication.mfa.base import BaseMFA
from authentication.mixins import AuthFaceMixin
from ..const import MFAType
class MFAFace(BaseMFA, AuthFaceMixin):
name = MFAType.Face.value
display_name = MFAType.Face.name
... | 60 | 1,624 |
jumpserver | apps/authentication/views/slack.py | .py | from urllib.parse import urlencode
from django.conf import settings
from django.http.response import HttpResponseRedirect
from django.utils.translation import gettext_lazy as _
from django.views import View
from rest_framework.exceptions import APIException
from rest_framework.permissions import AllowAny, IsAuthentica... | 127 | 4,652 |
jumpserver | apps/authentication/views/utils.py | .py | # -*- coding: utf-8 -*-
#
from urllib.parse import urlencode, parse_qsl
from django.shortcuts import reverse, redirect
def redirect_to_guard_view(comment='', query_string=None):
params = {'_': comment}
base_url = reverse('authentication:login-guard')
if query_string:
params.update(dict(parse_qsl... | 19 | 458 |
jumpserver | apps/authentication/views/feishu.py | .py | from urllib.parse import urlencode
from django.conf import settings
from django.http.request import HttpRequest
from django.http.response import HttpResponseRedirect
from django.utils.translation import gettext_lazy as _
from django.views import View
from rest_framework.exceptions import APIException
from rest_framewo... | 147 | 4,921 |
jumpserver | apps/authentication/views/agreement.py | .py | from django.views.generic import TemplateView
from django.utils.translation import get_language
from django.conf import settings
__all__ = ['UserAgreementView', 'PrivacyPolicyView']
class UserAgreementView(TemplateView):
def get_template_names(self):
current_lang = get_language() or 'zh-cn'
lang... | 29 | 918 |
jumpserver | apps/authentication/views/mixins.py | .py | # -*- coding: utf-8 -*-
#
from django.utils.translation import gettext_lazy as _
from common.utils import FlashMessageUtil
from common.utils import safe_next_url
class FlashMessageMixin:
@staticmethod
def get_response(redirect_url='', title='', msg='', m_type='message', interval=5):
message_data = {
... | 36 | 1,407 |
jumpserver | apps/authentication/views/login.py | .py | # ~*~ coding: utf-8 ~*~
#
from __future__ import unicode_literals
import datetime
import os
from typing import Callable
from urllib.parse import urlparse, urlsplit, urlunsplit, urlencode
from django.conf import settings
from django.contrib.auth import BACKEND_SESSION_KEY
from django.contrib.auth import login as auth... | 387 | 14,564 |
jumpserver | apps/authentication/views/dingtalk.py | .py | from urllib.parse import urlencode
from django.conf import settings
from django.contrib.auth import logout as auth_logout
from django.db.utils import IntegrityError
from django.http.request import HttpRequest
from django.http.response import HttpResponseRedirect
from django.utils.translation import gettext_lazy as _
f... | 263 | 9,381 |
jumpserver | apps/authentication/views/wecom.py | .py | from urllib.parse import urlencode
from django.conf import settings
from django.http.request import HttpRequest
from django.http.response import HttpResponseRedirect
from django.utils.translation import gettext_lazy as _
from django.views import View
from rest_framework.exceptions import APIException
from rest_framewo... | 195 | 7,321 |
jumpserver | apps/authentication/views/mfa.py | .py | # -*- coding: utf-8 -*-
#
from __future__ import unicode_literals
from django.shortcuts import redirect, reverse
from django.utils.translation import gettext as _
from django.views.generic.edit import FormView
from common.utils import get_logger
from users.views import UserFaceCaptureView
from .utils import redirect... | 120 | 4,201 |
jumpserver | apps/authentication/views/lark.py | .py | from django.utils.translation import gettext_lazy as _
from common.sdk.im.lark import URL
from common.utils import get_logger
from .feishu import (
FeiShuEnableStartView, FeiShuQRBindView, FeiShuQRBindCallbackView,
FeiShuQRLoginView, FeiShuQRLoginCallbackView
)
logger = get_logger(__file__)
class LarkEnable... | 52 | 1,343 |
jumpserver | apps/authentication/views/base.py | .py | from functools import lru_cache
from django.conf import settings
from django.contrib.auth import logout as auth_logout
from django.db.utils import IntegrityError
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy as _
from django.views import View
from rest_framewor... | 163 | 5,995 |
jumpserver | apps/authentication/models/ssh_key.py | .py | import sshpubkeys
from django.db import models
from django.utils.translation import gettext_lazy as _
from common.db.models import JMSBaseModel, CASCADE_SIGNAL_SKIP
from users.models import AuthMixin
from common.db import fields
class SSHKey(JMSBaseModel, AuthMixin):
name = models.CharField(max_length=128, verb... | 28 | 952 |
jumpserver | apps/authentication/models/temp_token.py | .py | from django.db import models
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from common.db.models import JMSBaseModel
from common.db.fields import EncryptTextField
class TempToken(JMSBaseModel):
username = models.CharField(max_length=128, verbose_name=_("Username"))
... | 28 | 975 |
jumpserver | apps/authentication/models/sso_token.py | .py | import uuid
from django.db import models
from django.utils.translation import gettext_lazy as _
from common.db.models import BaseCreateUpdateModel, CASCADE_SIGNAL_SKIP
class SSOToken(BaseCreateUpdateModel):
"""
类似腾讯企业邮的 [单点登录](https://exmail.qq.com/qy_mng_logic/doc#10036)
出于安全考虑,这里的 `token` 使用一次随即过期。但我们... | 21 | 808 |
jumpserver | apps/authentication/models/access_key.py | .py | import uuid
from django.conf import settings
from django.db import models
from django.utils.translation import gettext_lazy as _
from common.db.fields import EncryptTextField
import common.db.models
from common.db.utils import default_ip_group
from common.utils.random import random_string
def default_secret():
... | 46 | 1,467 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.