id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
40,000 | yml.py | jumpserver_jumpserver/apps/common/utils/yml.py | import io
import yaml
from django.conf import settings
from jinja2 import Environment
def translate(key, i18n, lang):
lang = settings.LANGUAGE_CODE if lang is None else lang
lang = lang[:2]
lang_data = i18n.get(key, {})
return lang_data.get(lang, key)
def yaml_load_with_i18n(stream, lang=None):
... | 882 | Python | .py | 27 | 27.962963 | 65 | 0.656434 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,001 | encode.py | jumpserver_jumpserver/apps/common/utils/encode.py | # -*- coding: utf-8 -*-
#
import base64
import hashlib
import json
import os
import re
import time
from io import StringIO
import paramiko
import sshpubkeys
from cryptography.hazmat.primitives import serialization
from django.conf import settings
from django.core.serializers.json import DjangoJSONEncoder
from itsdange... | 8,060 | Python | .py | 217 | 29.903226 | 97 | 0.666145 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,002 | django.py | jumpserver_jumpserver/apps/common/utils/django.py | # -*- coding: utf-8 -*-
#
import re
from django.conf import settings
from django.db import models
from django.db.models.signals import post_save, pre_save
from django.shortcuts import reverse as dj_reverse
from django.utils import timezone
from django.utils.http import url_has_allowed_host_and_scheme
UUID_PATTERN = r... | 2,913 | Python | .py | 85 | 27.952941 | 81 | 0.64611 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,003 | jumpserver.py | jumpserver_jumpserver/apps/common/utils/jumpserver.py | from django.core.cache import cache
from django.shortcuts import reverse, redirect
from django.utils.translation import gettext_noop
from .random import random_string
__all__ = ['FlashMessageUtil']
class FlashMessageUtil:
"""
跳转到通用msg页面
message_data: {
'title': '',
'message': '',
... | 1,175 | Python | .py | 39 | 23.307692 | 64 | 0.619946 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,004 | connection.py | jumpserver_jumpserver/apps/common/utils/connection.py | import json
import threading
import time
import redis
from django.core.cache import cache
from redis.client import PubSub
from common.db.utils import safe_db_connection
from common.utils import get_logger
logger = get_logger(__name__)
def get_redis_client(db=0):
client = cache.client.get_client()
assert is... | 3,710 | Python | .py | 104 | 25.375 | 98 | 0.563773 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,005 | verify_code.py | jumpserver_jumpserver/apps/common/utils/verify_code.py | from celery import shared_task
from django.conf import settings
from django.core.cache import cache
from django.utils.translation import gettext_lazy as _
from common.exceptions import JMSException
from common.sdk.sms.endpoint import SMS
from common.sdk.sms.exceptions import CodeError, CodeExpired, CodeSendTooFrequent... | 2,975 | Python | .py | 80 | 29.0375 | 98 | 0.631171 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,006 | common.py | jumpserver_jumpserver/apps/common/utils/common.py | # -*- coding: utf-8 -*-
#
import datetime
import ipaddress
import logging
import os
import platform
import re
import socket
import time
import uuid
from collections import OrderedDict
from functools import wraps
from itertools import chain
import html2text
import psutil
from django.conf import settings
from django.tem... | 10,479 | Python | .py | 329 | 24.756839 | 107 | 0.594289 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,007 | crypto.py | jumpserver_jumpserver/apps/common/utils/crypto.py | import base64
import logging
import re
from Cryptodome import Random
from Cryptodome.Cipher import AES, PKCS1_v1_5
from Cryptodome.PublicKey import RSA
from Cryptodome.Random import get_random_bytes
from Cryptodome.Util.Padding import pad
from django.conf import settings
from django.core.exceptions import ImproperlyCo... | 9,467 | Python | .py | 252 | 28.56746 | 98 | 0.625981 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,008 | http.py | jumpserver_jumpserver/apps/common/utils/http.py | # -*- coding: utf-8 -*-
#
import calendar
import threading
import time
from email.utils import formatdate
from rest_framework.serializers import BooleanField
_STRPTIME_LOCK = threading.Lock()
_GMT_FORMAT = "%a, %d %b %Y %H:%M:%S GMT"
_ISO8601_FORMAT = "%Y-%m-%dT%H:%M:%S.000Z"
def to_unixtime(time_string, format_st... | 1,348 | Python | .py | 31 | 34.225806 | 78 | 0.728889 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,009 | random.py | jumpserver_jumpserver/apps/common/utils/random.py | # -*- coding: utf-8 -*-
#
import random
import secrets
import socket
import string
import struct
string_punctuation = '!#$%&()*+,-.:;<=>?@[]^_~'
def random_datetime(date_start, date_end):
random_delta = (date_end - date_start) * random.random()
return date_start + random_delta
def random_ip():
return s... | 1,823 | Python | .py | 51 | 29.45098 | 84 | 0.637631 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,010 | utils.py | jumpserver_jumpserver/apps/common/utils/ip/utils.py | import ipaddress
import socket
from ipaddress import ip_network, ip_address
from django.conf import settings
from django.utils.translation import gettext_lazy as _
from .geoip import get_ip_city_by_geoip
from .ipip import get_ip_city_by_ipip
def is_ip_address(address):
""" 192.168.10.1 """
try:
ip_a... | 2,980 | Python | .py | 94 | 24.148936 | 97 | 0.580679 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,011 | utils.py | jumpserver_jumpserver/apps/common/utils/ip/geoip/utils.py | # -*- coding: utf-8 -*-
#
import ipaddress
import os
import geoip2.database
from django.conf import settings
from django.utils.translation import gettext_lazy as _
from geoip2.errors import GeoIP2Error
__all__ = ['get_ip_city_by_geoip']
reader = None
def get_ip_city_by_geoip(ip):
global reader
if reader is ... | 914 | Python | .py | 31 | 24.387097 | 76 | 0.648402 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,012 | utils.py | jumpserver_jumpserver/apps/common/utils/ip/ipip/utils.py | # -*- coding: utf-8 -*-
#
import os
import ipdb
__all__ = ['get_ip_city_by_ipip']
ipip_db = None
def get_ip_city_by_ipip(ip):
global ipip_db
if ipip_db is None:
ipip_db_path = os.path.join(os.path.dirname(__file__), 'ipipfree.ipdb')
ipip_db = ipdb.City(ipip_db_path)
try:
info = i... | 492 | Python | .py | 18 | 22.555556 | 79 | 0.612766 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,013 | __init__.py | jumpserver_jumpserver/apps/common/utils/ip/ipip/__init__.py | # -*- coding: utf-8 -*-
#
from .utils import *
| 47 | Python | .py | 3 | 14.666667 | 23 | 0.568182 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,014 | replay.py | jumpserver_jumpserver/apps/common/storage/replay.py | import json
import os
import shutil
import tarfile
import time
from itertools import chain
from django.core.files.storage import default_storage
from common.utils import make_dirs, get_logger
from terminal.models import Session
from .base import BaseStorageHandler, get_multi_object_storage
logger = get_logger(__name... | 4,783 | Python | .py | 94 | 40.148936 | 92 | 0.652759 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,015 | base.py | jumpserver_jumpserver/apps/common/storage/base.py | import os
from django.conf import settings
from django.core.files.storage import default_storage
from common.storage import jms_storage
from common.utils import get_logger, make_dirs
from terminal.models import ReplayStorage
logger = get_logger(__name__)
def get_multi_object_storage():
replay_storages = Replay... | 2,190 | Python | .py | 58 | 29.603448 | 77 | 0.647981 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,016 | ftp_file.py | jumpserver_jumpserver/apps/common/storage/ftp_file.py | from terminal.models import default_storage
from .base import BaseStorageHandler
class FTPFileStorageHandler(BaseStorageHandler):
NAME = 'FTP'
def get_file_path(self, **kwargs):
return self.obj.filepath, self.obj.filepath
def find_local(self):
local_path = self.obj.filepath
# 去de... | 503 | Python | .py | 13 | 30.923077 | 51 | 0.692469 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,017 | sftp.py | jumpserver_jumpserver/apps/common/storage/jms_storage/sftp.py | # -*- coding: utf-8 -*-
import os
import io
import paramiko
from jms_storage.base import ObjectStorage
class SFTPStorage(ObjectStorage):
def __init__(self, config):
self.sftp = None
self.sftp_host = config.get('SFTP_HOST', None)
self.sftp_port = int(config.get('SFTP_PORT', 22))
se... | 3,572 | Python | .py | 95 | 27.536842 | 100 | 0.584127 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,018 | jms.py | jumpserver_jumpserver/apps/common/storage/jms_storage/jms.py | # -*- coding: utf-8 -*-
#
import os
from .base import ObjectStorage, LogStorage
class JMSReplayStorage(ObjectStorage):
def __init__(self, config):
self.client = config.get("SERVICE")
def upload(self, src, target):
session_id = os.path.basename(target).split('.')[0]
ok = self.client.pu... | 1,375 | Python | .py | 37 | 29.594595 | 61 | 0.636981 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,019 | oss.py | jumpserver_jumpserver/apps/common/storage/jms_storage/oss.py | # -*- coding: utf-8 -*-
#
import os
import time
import oss2
from .base import ObjectStorage
class OSSStorage(ObjectStorage):
def __init__(self, config):
self.endpoint = config.get("ENDPOINT", None)
self.bucket = config.get("BUCKET", None)
self.access_key = config.get("ACCESS_KEY", None)
... | 2,188 | Python | .py | 61 | 26.163934 | 89 | 0.586011 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,020 | s3.py | jumpserver_jumpserver/apps/common/storage/jms_storage/s3.py | # -*- coding: utf-8 -*-
#
import boto3
import os
from .base import ObjectStorage
class S3Storage(ObjectStorage):
def __init__(self, config):
self.bucket = config.get("BUCKET", "jumpserver")
self.region = config.get("REGION", None)
self.access_key = config.get("ACCESS_KEY", None)
s... | 2,235 | Python | .py | 63 | 25.47619 | 81 | 0.575659 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,021 | __init__.py | jumpserver_jumpserver/apps/common/storage/jms_storage/__init__.py | #!/usr/bin/env python
# coding: utf-8
# Copyright (c) 2018
#
__version__ = '0.0.59'
from .ftp import FTPStorage
from .oss import OSSStorage
from .obs import OBSStorage
from .s3 import S3Storage
from .azure import AzureStorage
from .ceph import CEPHStorage
from .jms import JMSReplayStorage, JMSCommandStorage
from .mul... | 1,158 | Python | .py | 35 | 28.714286 | 60 | 0.696509 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,022 | ftp.py | jumpserver_jumpserver/apps/common/storage/jms_storage/ftp.py | # -*- coding: utf-8 -*-
#
import os
from ftplib import FTP, error_perm
from .base import ObjectStorage
class FTPStorage(ObjectStorage):
def __init__(self, config):
self.host = config.get("HOST", None)
self.port = int(config.get("PORT", 21))
self.username = config.get("USERNAME", None)
... | 3,494 | Python | .py | 103 | 22.31068 | 74 | 0.533616 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,023 | base.py | jumpserver_jumpserver/apps/common/storage/jms_storage/base.py | # -*- coding: utf-8 -*-
#
import abc
class ObjectStorage(metaclass=abc.ABCMeta):
@abc.abstractmethod
def upload(self, src, target):
return None, None
@abc.abstractmethod
def download(self, src, target):
pass
@abc.abstractmethod
def delete(self, path):
pass
@abc.... | 1,134 | Python | .py | 39 | 21.769231 | 58 | 0.624192 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,024 | azure.py | jumpserver_jumpserver/apps/common/storage/jms_storage/azure.py | # -*- coding: utf-8 -*-
#
import os
from azure.storage.blob import BlobServiceClient
from .base import ObjectStorage
class AzureStorage(ObjectStorage):
def __init__(self, config):
self.account_name = config.get("ACCOUNT_NAME", None)
self.account_key = config.get("ACCOUNT_KEY", None)
se... | 1,898 | Python | .py | 48 | 30.1875 | 95 | 0.615133 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,025 | multi.py | jumpserver_jumpserver/apps/common/storage/jms_storage/multi.py | # -*- coding: utf-8 -*-
#
from .base import ObjectStorage, LogStorage
class MultiObjectStorage(ObjectStorage):
def __init__(self, configs):
self.configs = configs
self.storage_list = []
self.init_storage_list()
def init_storage_list(self):
from . import get_object_storage
... | 1,950 | Python | .py | 63 | 18.809524 | 55 | 0.495462 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,026 | obs.py | jumpserver_jumpserver/apps/common/storage/jms_storage/obs.py | # -*- coding: utf-8 -*-
#
import os
from obs.client import ObsClient
from .base import ObjectStorage
class OBSStorage(ObjectStorage):
def __init__(self, config):
self.endpoint = config.get("ENDPOINT", None)
self.bucket = config.get("BUCKET", None)
self.access_key = config.get("ACCESS_KEY"... | 2,385 | Python | .py | 61 | 29.032787 | 234 | 0.597408 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,027 | ceph.py | jumpserver_jumpserver/apps/common/storage/jms_storage/ceph.py | # -*- coding: utf-8 -*-
#
import os
import boto
import boto.s3.connection
from .base import ObjectStorage
class CEPHStorage(ObjectStorage):
def __init__(self, config):
self.bucket = config.get("BUCKET", None)
self.region = config.get("REGION", None)
self.access_key = config.get("ACCESS_... | 1,936 | Python | .py | 56 | 24.714286 | 74 | 0.579764 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,028 | api_urls.py | jumpserver_jumpserver/apps/common/urls/api_urls.py | # -*- coding: utf-8 -*-
#
from django.urls import path
from .. import api
app_name = 'common'
urlpatterns = [
path('resources/cache/', api.ResourcesIDCacheApi.as_view(), name='resources-cache'),
path('countries/', api.CountryListApi.as_view(), name='resources-cache'),
]
| 283 | Python | .py | 9 | 29.111111 | 88 | 0.7 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,029 | view_urls.py | jumpserver_jumpserver/apps/common/urls/view_urls.py | from django.urls import path
from .. import views
app_name = 'common'
urlpatterns = [
# login
path('flash-message/', views.FlashMessageMsgView.as_view(), name='flash-message'),
] | 189 | Python | .py | 7 | 24.571429 | 86 | 0.722222 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,030 | signals.py | jumpserver_jumpserver/apps/common/const/signals.py | """
`m2m_changed`
```
def m2m_signal_handler(action, instance, reverse, model, pk_set, using):
pass
```
"""
PRE_ADD = 'pre_add'
POST_ADD = 'post_add'
PRE_REMOVE = 'pre_remove'
POST_REMOVE = 'post_remove'
PRE_CLEAR = 'pre_clear'
POST_CLEAR = 'post_clear'
POST_PREFIX = 'post'
PRE_PREFIX = 'pre'
SKIP_SIGNAL = 'ski... | 330 | Python | .py | 16 | 19.125 | 72 | 0.684887 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,031 | crontab.py | jumpserver_jumpserver/apps/common/const/crontab.py |
CRONTAB_AT_AM_TWO = '0 2 * * *'
CRONTAB_AT_AM_THREE = '0 3 * * *'
CRONTAB_AT_AM_TEN = '0 10 * * *'
CRONTAB_AT_PM_TWO = '0 14 * * *'
| 134 | Python | .py | 4 | 32 | 33 | 0.53125 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,032 | choices.py | jumpserver_jumpserver/apps/common/const/choices.py | import phonenumbers
import pycountry
from django.db import models
from django.utils.translation import gettext_lazy as _
from phonenumbers import PhoneMetadata
ADMIN = 'Admin'
USER = 'User'
AUDITOR = 'Auditor'
def get_country_phone_codes():
phone_codes = []
for region_code in phonenumbers.SUPPORTED_REGIONS:
... | 1,986 | Python | .py | 60 | 26.433333 | 74 | 0.623542 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,033 | __init__.py | jumpserver_jumpserver/apps/common/const/__init__.py | # -*- coding: utf-8 -*-
#
from .choices import *
from .common import *
from .crontab import *
from .http import *
from .signals import *
| 138 | Python | .py | 7 | 18.571429 | 23 | 0.7 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,034 | common.py | jumpserver_jumpserver/apps/common/const/common.py | import re
from django.utils.translation import gettext_lazy as _
create_success_msg = _("%(name)s was created successfully")
update_success_msg = _("%(name)s was updated successfully")
FILE_END_GUARD = ">>> Content End <<<"
celery_task_pre_key = "CELERY_"
KEY_CACHE_RESOURCE_IDS = "RESOURCE_IDS_{}"
# AD User AccountD... | 567 | Python | .py | 11 | 50.272727 | 120 | 0.730561 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,035 | http.py | jumpserver_jumpserver/apps/common/const/http.py |
GET = 'GET'
POST = 'POST'
PUT = 'PUT'
PATCH = 'PATCH'
DELETE = 'DELETE'
OPTIONS = 'OPTIONS'
| 93 | Python | .py | 6 | 14.333333 | 19 | 0.651163 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,036 | serializer.py | jumpserver_jumpserver/apps/common/api/serializer.py | # -*- coding: utf-8 -*-
#
from rest_framework.request import Request
__all__ = ['SerializerMixin']
class SerializerMixin:
""" 根据用户请求动作的不同,获取不同的 `serializer_class `"""
action: str
request: Request
serializer_classes = None
single_actions = ['put', 'retrieve', 'patch']
def get_serializer_cl... | 1,780 | Python | .py | 39 | 36.410256 | 86 | 0.665684 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,037 | mixin.py | jumpserver_jumpserver/apps/common/api/mixin.py | # -*- coding: utf-8 -*-
#
from collections import defaultdict
from itertools import chain
from typing import Callable
from django.db import models
from django.db.models.signals import m2m_changed
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.settings import... | 7,458 | Python | .py | 184 | 31.505435 | 90 | 0.651941 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,038 | permission.py | jumpserver_jumpserver/apps/common/api/permission.py | # -*- coding: utf-8 -*-
#
from django.contrib.auth import get_user_model
from django.db.models import Q
from rest_framework.request import Request
from common.utils import lazyproperty
__all__ = ['AllowBulkDestroyMixin', 'RoleAdminMixin', 'RoleUserMixin']
class AllowBulkDestroyMixin:
def allow_bulk_destroy(self... | 1,868 | Python | .py | 51 | 24.901961 | 78 | 0.565593 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,039 | generic.py | jumpserver_jumpserver/apps/common/api/generic.py | from rest_framework.viewsets import GenericViewSet, ModelViewSet
from rest_framework_bulk import BulkModelViewSet
from .mixin import CommonApiMixin, RelationMixin
from .permission import AllowBulkDestroyMixin
class JMSGenericViewSet(CommonApiMixin, GenericViewSet):
pass
class JMSModelViewSet(CommonApiMixin, Mo... | 555 | Python | .py | 12 | 43.166667 | 106 | 0.872659 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,040 | __init__.py | jumpserver_jumpserver/apps/common/api/__init__.py | from .action import *
from .common import *
from .generic import *
from .mixin import *
from .patch import *
from .permission import *
from .serializer import *
| 161 | Python | .py | 7 | 22 | 25 | 0.772727 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,041 | patch.py | jumpserver_jumpserver/apps/common/api/patch.py | # -*- coding: utf-8 -*-
#
import time
from hashlib import md5
from threading import Thread
from django.core.cache import cache
from rest_framework.response import Response
from common.utils import lazyproperty
__all__ = ['InterceptMixin', 'AsyncApiMixin']
class InterceptMixin:
"""
Hack默认的dispatch, 让用户可以实现... | 4,073 | Python | .py | 116 | 25.37069 | 82 | 0.559928 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,042 | action.py | jumpserver_jumpserver/apps/common/api/action.py | # -*- coding: utf-8 -*-
#
from typing import Callable
from django.utils.translation import gettext as _
from rest_framework.decorators import action
from rest_framework.request import Request
from rest_framework.response import Response
from common.const.http import POST, PUT
__all__ = ['SuggestionMixin', 'RenderToJ... | 1,936 | Python | .py | 45 | 35.666667 | 82 | 0.663825 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,043 | common.py | jumpserver_jumpserver/apps/common/api/common.py | # -*- coding: utf-8 -*-
#
import os
import uuid
from django.core.cache import cache
from django.views.decorators.csrf import csrf_exempt
from rest_framework import generics, serializers
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from rest_framework.views import APIView... | 3,401 | Python | .py | 86 | 32.151163 | 73 | 0.64441 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,044 | start.py | jumpserver_jumpserver/apps/common/management/commands/start.py | from .services.command import BaseActionCommand, Action
class Command(BaseActionCommand):
help = 'Start services'
action = Action.start.value
| 152 | Python | .py | 4 | 34.5 | 55 | 0.794521 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,045 | expire_caches.py | jumpserver_jumpserver/apps/common/management/commands/expire_caches.py | from django.core.management.base import BaseCommand
from assets.signal_handlers.node_assets_mapping import expire_node_assets_mapping as _expire_node_assets_mapping
from orgs.caches import OrgResourceStatisticsCache
from orgs.models import Organization
def expire_node_assets_mapping():
org_ids = Organization.obj... | 866 | Python | .py | 19 | 40.526316 | 112 | 0.742243 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,046 | check_api.py | jumpserver_jumpserver/apps/common/management/commands/check_api.py | import re
from django.conf import settings
from django.core.management.base import BaseCommand
from django.test import Client
from django.urls import URLPattern, URLResolver
from jumpserver.urls import api_v1
path_uuid_pattern = re.compile(r'<\w+:\w+>', re.IGNORECASE)
uuid_pattern = re.compile(r'\(\(\?P<.*>[^)]+\)/\... | 4,279 | Python | .py | 110 | 31.7 | 133 | 0.58693 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,047 | status.py | jumpserver_jumpserver/apps/common/management/commands/status.py | from .services.command import BaseActionCommand, Action
class Command(BaseActionCommand):
help = 'Show services status'
action = Action.status.value
| 159 | Python | .py | 4 | 36.25 | 55 | 0.797386 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,048 | restart.py | jumpserver_jumpserver/apps/common/management/commands/restart.py | from .services.command import BaseActionCommand, Action
class Command(BaseActionCommand):
help = 'Restart services'
action = Action.restart.value
| 156 | Python | .py | 4 | 35.5 | 55 | 0.8 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,049 | stop.py | jumpserver_jumpserver/apps/common/management/commands/stop.py | from .services.command import BaseActionCommand, Action
class Command(BaseActionCommand):
help = 'Stop services'
action = Action.stop.value
| 150 | Python | .py | 4 | 34 | 55 | 0.791667 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,050 | command.py | jumpserver_jumpserver/apps/common/management/commands/services/command.py | import multiprocessing
from django.core.management.base import BaseCommand
from django.db.models import TextChoices
from .hands import *
from .utils import ServicesUtil
class Services(TextChoices):
gunicorn = 'gunicorn', 'gunicorn'
celery_ansible = 'celery_ansible', 'celery_ansible'
celery_default = 'ce... | 4,237 | Python | .py | 110 | 30.118182 | 101 | 0.610339 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,051 | hands.py | jumpserver_jumpserver/apps/common/management/commands/services/hands.py | import logging
import os
import sys
from django.conf import settings
from apps.jumpserver.const import CONFIG
try:
from apps.jumpserver import const
__version__ = const.VERSION
except ImportError as e:
print("Not found __version__: {}".format(e))
print("Python is: ")
logging.info(sys.executable)... | 706 | Python | .py | 22 | 29.590909 | 48 | 0.723122 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,052 | utils.py | jumpserver_jumpserver/apps/common/management/commands/services/utils.py | import threading
import signal
import time
import daemon
from daemon import pidfile
from .hands import *
from .hands import __version__
from .services.base import BaseService
class ServicesUtil(object):
def __init__(self, services, run_daemon=False, force_stop=False, stop_daemon=False):
self._services = ... | 3,933 | Python | .py | 120 | 23.075 | 94 | 0.571579 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,053 | celery_ansible.py | jumpserver_jumpserver/apps/common/management/commands/services/services/celery_ansible.py | from .celery_base import CeleryBaseService
__all__ = ['CeleryAnsibleService']
class CeleryAnsibleService(CeleryBaseService):
def __init__(self, **kwargs):
kwargs['queue'] = 'ansible'
super().__init__(**kwargs)
| 235 | Python | .py | 6 | 34 | 46 | 0.678571 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,054 | flower.py | jumpserver_jumpserver/apps/common/management/commands/services/services/flower.py | from .base import BaseService
from ..hands import *
__all__ = ['FlowerService']
class FlowerService(BaseService):
@property
def cmd(self):
print("\n- Start Flower as Task Monitor")
if os.getuid() == 0:
os.environ.setdefault('C_FORCE_ROOT', '1')
cmd = [
'celery... | 638 | Python | .py | 23 | 19.043478 | 54 | 0.514754 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,055 | __init__.py | jumpserver_jumpserver/apps/common/management/commands/services/services/__init__.py | from .beat import *
from .celery_ansible import *
from .celery_default import *
from .flower import *
from .gunicorn import *
| 126 | Python | .py | 5 | 24.2 | 29 | 0.77686 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,056 | base.py | jumpserver_jumpserver/apps/common/management/commands/services/services/base.py | import abc
import time
import shutil
import psutil
import datetime
import threading
import subprocess
from ..hands import *
class BaseService(object):
def __init__(self, **kwargs):
self.name = kwargs['name']
self._process = None
self.STOP_TIMEOUT = 10
self.max_retry = 0
se... | 5,726 | Python | .py | 174 | 23.270115 | 102 | 0.542114 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,057 | celery_base.py | jumpserver_jumpserver/apps/common/management/commands/services/services/celery_base.py | from .base import BaseService
from ..hands import *
class CeleryBaseService(BaseService):
def __init__(self, queue, num=10, **kwargs):
super().__init__(**kwargs)
self.queue = queue
self.num = num
@property
def cmd(self):
print('\n- Start Celery as Distributed Task Queue: ... | 1,544 | Python | .py | 39 | 30.307692 | 95 | 0.572096 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,058 | celery_default.py | jumpserver_jumpserver/apps/common/management/commands/services/services/celery_default.py | from .celery_base import CeleryBaseService
__all__ = ['CeleryDefaultService']
class CeleryDefaultService(CeleryBaseService):
def __init__(self, **kwargs):
kwargs['queue'] = 'celery'
super().__init__(**kwargs)
def start_other(self):
from terminal.startup import CeleryTerminal
... | 406 | Python | .py | 10 | 34.2 | 51 | 0.689744 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,059 | beat.py | jumpserver_jumpserver/apps/common/management/commands/services/services/beat.py | from ..hands import *
from .base import BaseService
from django.core.cache import cache
__all__ = ['BeatService']
class BeatService(BaseService):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.lock = cache.lock('beat-distribute-start-lock', expire=60)
@property
def cmd(s... | 563 | Python | .py | 18 | 25 | 71 | 0.622677 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,060 | gunicorn.py | jumpserver_jumpserver/apps/common/management/commands/services/services/gunicorn.py | from .base import BaseService
from ..hands import *
__all__ = ['GunicornService']
class GunicornService(BaseService):
def __init__(self, **kwargs):
self.worker = kwargs['worker_gunicorn']
super().__init__(**kwargs)
@property
def cmd(self):
print("\n- Start Gunicorn WSGI HTTP Ser... | 1,125 | Python | .py | 33 | 25.30303 | 62 | 0.545706 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,061 | signature.py | jumpserver_jumpserver/apps/common/auth/signature.py | from rest_framework import authentication
from rest_framework import exceptions
from httpsig import HeaderVerifier, utils
"""
Reusing failure exceptions serves several purposes:
1. Lack of useful information regarding the failure inhibits attackers
from learning about valid keyIDs or other forms of informati... | 4,243 | Python | .py | 93 | 37.193548 | 98 | 0.660684 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,062 | sm3.py | jumpserver_jumpserver/apps/common/hashers/sm3.py | from gmssl import sm3, func
from django.contrib.auth.hashers import PBKDF2PasswordHasher
class Hasher:
name = 'sm3'
block_size = 64
digest_size = 32
def __init__(self, data):
self.__data = data
def hexdigest(self):
return sm3.sm3_hash(func.bytes_to_list(self.__data))
def di... | 671 | Python | .py | 22 | 24.590909 | 60 | 0.66405 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,063 | es.py | jumpserver_jumpserver/apps/common/plugins/es.py | # -*- coding: utf-8 -*-
#
import datetime
import inspect
import sys
if sys.version_info.major == 3 and sys.version_info.minor >= 10:
from collections.abc import Iterable
else:
from collections import Iterable
from functools import reduce, partial
from itertools import groupby
from uuid import UUID
from django... | 16,448 | Python | .py | 427 | 27.278689 | 105 | 0.550183 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,064 | cache.py | jumpserver_jumpserver/apps/common/sessions/cache.py | import re
from importlib import import_module
from django.conf import settings
from django.contrib.sessions.backends.cache import (
SessionStore as DjangoSessionStore
)
from django.core.cache import cache, caches
from common.utils import get_logger
from jumpserver.utils import get_current_request
logger = get_lo... | 2,490 | Python | .py | 60 | 33.666667 | 92 | 0.650498 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,065 | mixin.py | jumpserver_jumpserver/apps/common/serializers/mixin.py | import sys
from collections import defaultdict, OrderedDict
if sys.version_info.major >= 3 and sys.version_info.minor >= 10:
from collections.abc import Iterable
else:
from collections import Iterable
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db.models i... | 15,569 | Python | .py | 387 | 30.144703 | 99 | 0.61645 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,066 | __init__.py | jumpserver_jumpserver/apps/common/serializers/__init__.py | from .common import *
from .dynamic import *
from .mixin import *
| 66 | Python | .py | 3 | 21 | 22 | 0.761905 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,067 | dynamic.py | jumpserver_jumpserver/apps/common/serializers/dynamic.py | from rest_framework import serializers
example_info = [
{"name": "name", "label": "姓名", "required": False, "default": "广州老广", "type": "str"},
{"name": "age", "label": "年龄", "required": False, "default": 18, "type": "int"},
]
type_field_map = {
"str": serializers.CharField,
"password": serializers.Char... | 2,417 | Python | .py | 59 | 32.830508 | 89 | 0.599042 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,068 | fields.py | jumpserver_jumpserver/apps/common/serializers/fields.py | # -*- coding: utf-8 -*-
#
import phonenumbers
from django.core.exceptions import ObjectDoesNotExist
from django.db.models import Model
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
from rest_framework.fields import ChoiceField, empty
from common.db.fields import TreeChoi... | 9,838 | Python | .py | 253 | 28.826087 | 102 | 0.58256 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,069 | common.py | jumpserver_jumpserver/apps/common/serializers/common.py | import logging
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from drf_writable_nested.serializers import WritableNestedModelSerializer as NestedModelSerializer
from rest_framework import serializers
from rest_framework.serializers import ModelSerializer
from... | 3,496 | Python | .py | 79 | 35.493671 | 98 | 0.736546 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,070 | signals.py | jumpserver_jumpserver/apps/users/signals.py | from django.dispatch import Signal
post_user_create = Signal()
post_user_change_password = Signal()
pre_user_leave_org = Signal()
post_user_leave_org = Signal()
| 162 | Python | .py | 5 | 31.2 | 36 | 0.775641 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,071 | filters.py | jumpserver_jumpserver/apps/users/filters.py | from django.utils.translation import gettext as _
from django_filters import rest_framework as filters
from common.drf.filters import BaseFilterSet
from common.utils import is_uuid
from rbac.models import Role, OrgRoleBinding, SystemRoleBinding
from users.models.user import User
from orgs.utils import current_org
cl... | 2,171 | Python | .py | 47 | 38.425532 | 100 | 0.673314 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,072 | hands.py | jumpserver_jumpserver/apps/users/hands.py | """
jumpserver.__app__.hands.py
~~~~~~~~~~~~~~~~~
This app depends other apps api, function .. should be import or write mack here.
Other module of this app shouldn't connect with other app.
:copyright: (c) 2014-2018 by JumpServer Team.
:license: GPL v2, see LICENSE for more details.
"""
# f... | 556 | Python | .py | 13 | 39.615385 | 85 | 0.732839 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,073 | tasks.py | jumpserver_jumpserver/apps/users/tasks.py | # -*- coding: utf-8 -*-
#
import uuid
from datetime import timedelta
from celery import shared_task, current_task
from django.conf import settings
from django.db.models import Q
from django.utils import timezone
from django.utils.translation import gettext_lazy as _, gettext_noop
from audits.const import ActivityChoi... | 5,454 | Python | .py | 137 | 33.751825 | 98 | 0.679569 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,074 | const.py | jumpserver_jumpserver/apps/users/const.py | # -*- coding: utf-8 -*-
#
from django.db.models import TextChoices
from django.utils.translation import gettext_lazy as _
TICKET_DETAIL_URL = '/ui/#/tickets/tickets/{id}'
class SystemOrOrgRole(TextChoices):
SYSTEM_ADMIN = 'system_admin', _('System administrator')
SYSTEM_AUDITOR = 'system_auditor', _('System ... | 2,192 | Python | .py | 49 | 40.367347 | 75 | 0.670293 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,075 | apps.py | jumpserver_jumpserver/apps/users/apps.py | from __future__ import unicode_literals
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class UsersConfig(AppConfig):
name = 'users'
verbose_name = _('App Users')
def ready(self):
from . import signal_handlers # noqa
from . import tasks # noqa
... | 387 | Python | .py | 11 | 29.818182 | 54 | 0.682796 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,076 | utils.py | jumpserver_jumpserver/apps/users/utils.py | # ~*~ coding: utf-8 ~*~
#
import base64
import logging
import os
import re
import time
import pyotp
from django.conf import settings
from django.core.cache import cache
from common.tasks import send_mail_async
from common.utils import reverse, get_object_or_none, ip, safe_next_url
from .models import User
logger = l... | 9,136 | Python | .py | 234 | 32.132479 | 81 | 0.644942 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,077 | exceptions.py | jumpserver_jumpserver/apps/users/exceptions.py | from django.utils.translation import gettext_lazy as _
from rest_framework import status
from common.exceptions import JMSException
class MFANotEnabled(JMSException):
status_code = status.HTTP_403_FORBIDDEN
default_code = 'mfa_not_enabled'
default_detail = _('MFA not enabled')
class PhoneNotSet(JMSExcep... | 731 | Python | .py | 16 | 41.9375 | 85 | 0.763791 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,078 | permissions.py | jumpserver_jumpserver/apps/users/permissions.py | from rest_framework import permissions
from .utils import is_auth_password_time_valid
class IsAuthPasswdTimeValid(permissions.IsAuthenticated):
def has_permission(self, request, view):
return super().has_permission(request, view) \
and is_auth_password_time_valid(request.session)
class Use... | 631 | Python | .py | 13 | 41 | 70 | 0.720854 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,079 | notifications.py | jumpserver_jumpserver/apps/users/notifications.py | from collections import defaultdict
from urllib.parse import urljoin
from django.conf import settings
from django.template.loader import render_to_string
from django.utils import timezone
from django.utils.translation import gettext as _
from common.utils import reverse, get_request_ip_or_data, get_request_user_agent... | 7,741 | Python | .py | 194 | 30.85567 | 97 | 0.616226 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,080 | signal_handlers.py | jumpserver_jumpserver/apps/users/signal_handlers.py | # -*- coding: utf-8 -*-
#
from celery import shared_task
from django.conf import settings
from django.contrib.auth.signals import user_logged_out
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils.translation import gettext_lazy as _
from django_auth_ldap.backend impor... | 9,647 | Python | .py | 224 | 36.526786 | 100 | 0.685711 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,081 | preference.py | jumpserver_jumpserver/apps/users/models/preference.py | from django.db import models
from django.utils.translation import gettext_lazy as _
from common.db.utils import Encryptor
from common.utils import get_logger
logger = get_logger(__name__)
class Preference(models.Model):
name = models.CharField(max_length=128, verbose_name=_("Name"))
category = models.CharFi... | 2,401 | Python | .py | 59 | 33.254237 | 99 | 0.650473 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,082 | utils.py | jumpserver_jumpserver/apps/users/models/utils.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from .user import User
from .group import UserGroup
def init_model():
for cls in [User, UserGroup]:
if getattr(cls, 'initial'):
cls.initial()
def generate_fake():
for cls in [User, UserGroup]:
if getattr(cls, 'generate_fake'):
... | 349 | Python | .py | 13 | 21.692308 | 41 | 0.616314 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,083 | __init__.py | jumpserver_jumpserver/apps/users/models/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from .group import *
from .preference import *
from .user import *
from .utils import *
| 138 | Python | .py | 7 | 18.428571 | 25 | 0.684615 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,084 | group.py | jumpserver_jumpserver/apps/users/models/group.py | # -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import gettext_lazy as _
from common.utils import lazyproperty
from labels.mixins import LabeledMixin
from orgs.mixins.models import JMSOrgBaseModel
__all__ = ['UserGroup']
class UserGroup(LabeledMixin, JMSOrgBaseModel):
name = m... | 956 | Python | .py | 27 | 29.074074 | 90 | 0.654723 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,085 | _json.py | jumpserver_jumpserver/apps/users/models/user/_json.py | from django.db import models
from django.db.models import Count
class JSONFilterMixin:
@staticmethod
def get_json_filter_attr_q(name, value, match):
from rbac.models import RoleBinding
from orgs.utils import current_org
kwargs = {}
if name == "system_roles":
kwargs... | 1,082 | Python | .py | 27 | 27.925926 | 98 | 0.563618 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,086 | __init__.py | jumpserver_jumpserver/apps/users/models/user/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import uuid
from django.conf import settings
from django.contrib.auth.models import AbstractUser, UserManager as _UserManager
from django.db import models
from django.shortcuts import reverse
from django.utils import timezone
from django.utils.translation import gettext_... | 9,987 | Python | .py | 282 | 28.219858 | 88 | 0.640079 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,087 | _token.py | jumpserver_jumpserver/apps/users/models/user/_token.py | import base64
from django.conf import settings
from django.core.cache import cache
from django.utils import timezone
from common.utils import (
get_logger,
random_string,
)
logger = get_logger(__file__)
class TokenMixin:
CACHE_KEY_USER_RESET_PASSWORD_PREFIX = "_KEY_USER_RESET_PASSWORD_{}"
email = "... | 2,871 | Python | .py | 76 | 29.789474 | 78 | 0.636888 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,088 | _role.py | jumpserver_jumpserver/apps/users/models/user/_role.py | from collections import defaultdict
from django.conf import settings
from django.core.cache import cache
from django.db import models
from common.utils import (
get_logger,
lazyproperty,
bulk_create_with_signal,
)
from orgs.utils import current_org
from rbac.const import Scope
from rbac.models import Role... | 11,562 | Python | .py | 325 | 26.966154 | 88 | 0.613628 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,089 | _source.py | jumpserver_jumpserver/apps/users/models/user/_source.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
from django.conf import settings
from django.db import models
from django.utils.translation import gettext_lazy as _
class Source(models.TextChoices):
local = "local", _("Local")
ldap = "ldap", "LDAP/AD"
ldap_ha = "ldap_ha", "LDAP/AD (HA)"
openid = "ope... | 3,676 | Python | .py | 97 | 29.639175 | 86 | 0.619008 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,090 | _auth.py | jumpserver_jumpserver/apps/users/models/user/_auth.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import datetime
from typing import Callable
import sshpubkeys
from django.conf import settings
from django.contrib.auth.hashers import check_password
from django.core.cache import cache
from django.db import models
from django.utils import timezone
from django.utils.modu... | 8,872 | Python | .py | 249 | 27.148594 | 103 | 0.622368 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,091 | 0001_initial.py | jumpserver_jumpserver/apps/users/migrations/0001_initial.py | # Generated by Django 4.1.13 on 2024-05-09 03:16
import uuid
import django.utils.timezone
from django.conf import settings
from django.contrib.auth.hashers import make_password
from django.db import migrations, models
import common.db.fields
import common.db.models
import common.utils.django
import users.models.user... | 10,465 | Python | .py | 169 | 46.786982 | 164 | 0.572679 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,092 | reset.py | jumpserver_jumpserver/apps/users/views/profile/reset.py | # ~*~ coding: utf-8 ~*~
from __future__ import unicode_literals
import time
from django.conf import settings
from django.core.cache import cache
from django.shortcuts import redirect, reverse
from django.urls import reverse_lazy
from django.utils.translation import gettext as _
from django.views.generic import FormV... | 9,123 | Python | .py | 198 | 37.186869 | 99 | 0.646595 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,093 | password.py | jumpserver_jumpserver/apps/users/views/profile/password.py | # ~*~ coding: utf-8 ~*~
from django.contrib.auth import authenticate
from django.shortcuts import redirect
from django.utils.translation import gettext as _
from django.views.generic.edit import FormView
from authentication import errors
from authentication.mixins import AuthMixin
from common.utils import get_logger
... | 1,760 | Python | .py | 45 | 32.066667 | 92 | 0.667645 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,094 | mfa.py | jumpserver_jumpserver/apps/users/views/profile/mfa.py | # -*- coding: utf-8 -*-
#
from __future__ import unicode_literals
from django.views.generic.base import TemplateView
from common.permissions import IsValidUser
from common.views.mixins import PermissionsMixin
from users.models import User
__all__ = ['MFASettingView']
class MFASettingView(PermissionsMixin, TemplateV... | 676 | Python | .py | 18 | 32.722222 | 68 | 0.718224 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,095 | __init__.py | jumpserver_jumpserver/apps/users/views/profile/__init__.py | # -*- coding: utf-8 -*-
#
from .password import *
from .mfa import *
from .otp import *
from .reset import *
from .pubkey import *
| 131 | Python | .py | 7 | 17.714286 | 23 | 0.685484 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,096 | pubkey.py | jumpserver_jumpserver/apps/users/views/profile/pubkey.py | # ~*~ coding: utf-8 ~*~
from django.http import HttpResponse
from django.views import View
from common.utils import get_logger, ssh_key_gen
from common.permissions import IsValidUser
from common.views.mixins import PermissionsMixin
from users.exceptions import CreateSSHKeyExceedLimit
__all__ = ['UserPublicKeyGenerat... | 1,131 | Python | .py | 24 | 40.833333 | 84 | 0.711818 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,097 | otp.py | jumpserver_jumpserver/apps/users/views/profile/otp.py | # ~*~ coding: utf-8 ~*~
import os
from django.conf import settings
from django.contrib.auth import logout as auth_logout
from django.http.response import HttpResponseRedirect
from django.shortcuts import redirect
from django.templatetags.static import static
from django.urls import reverse
from django.utils.translatio... | 6,453 | Python | .py | 158 | 32.936709 | 84 | 0.65198 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,098 | api_urls.py | jumpserver_jumpserver/apps/users/urls/api_urls.py | #!/usr/bin/env python
# ~*~ coding: utf-8 ~*~
#
from __future__ import absolute_import
from django.urls import path
from rest_framework_bulk.routes import BulkRouter
from authentication import api as auth_api
from .. import api
app_name = 'users'
router = BulkRouter()
router.register(r'users', api.UserViewSet, 'use... | 1,562 | Python | .py | 27 | 55.333333 | 120 | 0.748366 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |
40,099 | profile.py | jumpserver_jumpserver/apps/users/api/profile.py | # ~*~ coding: utf-8 ~*~
import uuid
from rest_framework import generics
from rest_framework.permissions import IsAuthenticated
from authentication.models import ConnectionToken
from authentication.permissions import IsValidUserOrConnectionToken
from common.utils import get_object_or_none
from orgs.utils import tmp_to... | 2,503 | Python | .py | 63 | 33.507937 | 75 | 0.722658 | jumpserver/jumpserver | 25,048 | 5,291 | 48 | GPL-3.0 | 9/5/2024, 5:15:46 PM (Europe/Amsterdam) |