{{ user }} 3 | (delete)
4 | {% endfor %} -------------------------------------------------------------------------------- /backend/src/apps/users/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from .views import CreateUserAPI 3 | 4 | urlpatterns = [ 5 | path('create/', CreateUserAPI.as_view(), name="create_user"), 6 | ] -------------------------------------------------------------------------------- /backend/src/apps/users/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.views.generic.edit import CreateView, UpdateView, DeleteView 3 | from django.urls import reverse_lazy 4 | from django.contrib.auth.mixins import LoginRequiredMixin 5 | from .models import User 6 | 7 | from rest_framework_simplejwt.views import TokenObtainPairView 8 | from rest_framework import status, permissions 9 | from rest_framework.response import Response 10 | from rest_framework.views import APIView 11 | from drf_yasg.utils import swagger_auto_schema 12 | from .serializers import UserSerializer 13 | 14 | # Create your views here. 15 | 16 | # FOR DJANGO ADMIN 17 | class CreateUser(LoginRequiredMixin, CreateView): 18 | model = User 19 | fields = ['username', 'email', 'phone_number', 'password'] 20 | template_name = 'create_user.html' 21 | success_url = reverse_lazy('user_list') 22 | 23 | class UpdateUser(LoginRequiredMixin, UpdateView): 24 | model = User 25 | fields = ['username', 'email', 'phone_number', 'password'] 26 | template_name = 'update_user.html' 27 | success_url = reverse_lazy('user_list') 28 | 29 | class DeleteUser(LoginRequiredMixin, DeleteView): 30 | model = User 31 | template_name = 'delete_user.html' 32 | success_url = reverse_lazy('user_list') 33 | 34 | def user_list(request): 35 | users = User.objects.all() 36 | return render(request, 'user_list.html', {'users': users}) 37 | 38 | # FOR API 39 | class CreateUserAPI(APIView): 40 | permission_classes = (permissions.AllowAny, ) 41 | 42 | @swagger_auto_schema(request_body=UserSerializer, operation_description='Create user') 43 | def post(self, request, format='json'): 44 | serializer = UserSerializer(data=request.data) 45 | if serializer.is_valid(): 46 | user = serializer.save() 47 | if user: 48 | json = serializer.data 49 | return Response(json, status=status.HTTP_201_CREATED) 50 | return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) -------------------------------------------------------------------------------- /backend/src/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bekkaze/abusebox/e5eb7988e5e972499f526b74bf9161a9639000c6/backend/src/core/__init__.py -------------------------------------------------------------------------------- /backend/src/core/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for core project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /backend/src/core/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for core project. 3 | 4 | Generated by 'django-admin startproject' using Django 4.2.7. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.2/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/4.2/ref/settings/ 11 | """ 12 | 13 | from datetime import timedelta 14 | from pathlib import Path 15 | import os 16 | 17 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 18 | BASE_DIR = Path(__file__).resolve().parent.parent 19 | 20 | 21 | # Quick-start development settings - unsuitable for production 22 | # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ 23 | 24 | # SECURITY WARNING: keep the secret key used in production secret! 25 | SECRET_KEY = 'django-insecure-qg%5cq$_djbjqn1yn2$4nq%^_d@l=@ybq-h@4oa$#-c1my*^!6' 26 | 27 | # SECURITY WARNING: don't run with debug turned on in production! 28 | DEBUG = True 29 | 30 | ALLOWED_HOSTS = ['*'] 31 | 32 | 33 | # Application definition 34 | 35 | INSTALLED_APPS = [ 36 | 'django.contrib.admin', 37 | 'django.contrib.auth', 38 | 'django.contrib.contenttypes', 39 | 'django.contrib.sessions', 40 | 'django.contrib.messages', 41 | 'django.contrib.staticfiles', 42 | 43 | # MY APPS 44 | 'apps.users', 45 | 'apps.authentication', 46 | 'apps.blacklist', 47 | 'apps.hostname', 48 | 49 | # NATIVE 50 | 'rest_framework', 51 | 'drf_yasg', 52 | 'corsheaders', 53 | 'django_crontab', 54 | ] 55 | 56 | AUTH_USER_MODEL = 'users.User' 57 | 58 | REST_FRAMEWORK = { 59 | 'DEFAULT_PERMISSION_CLASSES': ( 60 | 'rest_framework.permissions.IsAuthenticated', 61 | ), 62 | 'DEFAULT_AUTHENTICATION_CLASSES': ( 63 | 'rest_framework_simplejwt.authentication.JWTAuthentication', 64 | ), 65 | } 66 | SIMPLE_JWT = { 67 | 'ACCESS_TOKEN_LIFETIME': timedelta(minutes=120), 68 | 'REFRESH_TOKEN_LIFETIME': timedelta(days=14), 69 | 'ROTATE_REFRESH_TOKENS': True, 70 | 'BLACKLIST_AFTER_ROTATION': False, 71 | 'ALGORITHM': 'HS256', 72 | 'SIGNING_KEY': SECRET_KEY, 73 | 'VERIFYING_KEY': None, 74 | 'AUTH_HEADER_TYPES': ('Bearer',), 75 | 'USER_ID_FIELD': 'id', 76 | 'USER_ID_CLAIM': 'user_id', 77 | 'AUTH_TOKEN_CLASSES': ('rest_framework_simplejwt.tokens.AccessToken',), 78 | 'TOKEN_TYPE_CLAIM': 'token_type', 79 | } 80 | 81 | SWAGGER_SETTINGS = { 82 | 'SECURITY_DEFINITIONS': { 83 | 'Basic': { 84 | 'type': 'basic' 85 | } 86 | } 87 | } 88 | 89 | CORS_ALLOWED_ORIGINS = [ 90 | "http://10.136.32.236:3000", 91 | ] 92 | 93 | FRONT_IP = os.getenv("FRONT_IP") 94 | if FRONT_IP: 95 | CORS_ALLOWED_ORIGINS.append(FRONT_IP) 96 | 97 | CORS_ALLOW_CREDENTIALS = True 98 | 99 | MIDDLEWARE = [ 100 | 'corsheaders.middleware.CorsMiddleware', 101 | 'django.middleware.security.SecurityMiddleware', 102 | 'django.contrib.sessions.middleware.SessionMiddleware', 103 | 'django.middleware.common.CommonMiddleware', 104 | 'django.middleware.csrf.CsrfViewMiddleware', 105 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 106 | 'django.contrib.messages.middleware.MessageMiddleware', 107 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 108 | ] 109 | 110 | ROOT_URLCONF = 'core.urls' 111 | 112 | TEMPLATES = [ 113 | { 114 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 115 | 'DIRS': [], 116 | 'APP_DIRS': True, 117 | 'OPTIONS': { 118 | 'context_processors': [ 119 | 'django.template.context_processors.debug', 120 | 'django.template.context_processors.request', 121 | 'django.contrib.auth.context_processors.auth', 122 | 'django.contrib.messages.context_processors.messages', 123 | ], 124 | }, 125 | }, 126 | ] 127 | 128 | WSGI_APPLICATION = 'core.wsgi.application' 129 | 130 | 131 | # Database 132 | # https://docs.djangoproject.com/en/4.2/ref/settings/#databases 133 | 134 | DATABASES = { 135 | 'default': { 136 | 'ENGINE': 'django.db.backends.sqlite3', 137 | 'NAME': BASE_DIR / 'db.sqlite3', 138 | } 139 | } 140 | 141 | 142 | # Password validation 143 | # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators 144 | 145 | AUTH_PASSWORD_VALIDATORS = [ 146 | { 147 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 148 | }, 149 | { 150 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 151 | }, 152 | { 153 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 154 | }, 155 | { 156 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 157 | }, 158 | ] 159 | 160 | 161 | # Internationalization 162 | # https://docs.djangoproject.com/en/4.2/topics/i18n/ 163 | 164 | LANGUAGE_CODE = 'en-us' 165 | 166 | TIME_ZONE = 'UTC' 167 | 168 | USE_I18N = True 169 | 170 | USE_TZ = True 171 | 172 | 173 | # Static files (CSS, JavaScript, Images) 174 | # https://docs.djangoproject.com/en/4.2/howto/static-files/ 175 | 176 | STATIC_URL = 'static/' 177 | 178 | # Default primary key field type 179 | # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field 180 | 181 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 182 | 183 | CRONJOBS = [ 184 | ('0 0 * * *', 'apps.blacklist.jobs.check_hostname_blacklist.run') 185 | ] -------------------------------------------------------------------------------- /backend/src/core/urls.py: -------------------------------------------------------------------------------- 1 | """ 2 | URL configuration for core project. 3 | 4 | The `urlpatterns` list routes URLs to views. For more information please see: 5 | https://docs.djangoproject.com/en/4.2/topics/http/urls/ 6 | Examples: 7 | Function views 8 | 1. Add an import: from my_app import views 9 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 10 | Class-based views 11 | 1. Add an import: from other_app.views import Home 12 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 13 | Including another URLconf 14 | 1. Import the include() function: from django.urls import include, path 15 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 16 | """ 17 | from django.contrib import admin 18 | from django.urls import path, include 19 | from rest_framework import permissions 20 | from drf_yasg.views import get_schema_view 21 | from drf_yasg import openapi 22 | 23 | schema_view = get_schema_view( 24 | openapi.Info( 25 | title="AbuseBOX APIs", 26 | default_version='v1', 27 | description="AbuseBOX backend APIs", 28 | terms_of_service="https://www.example.com/terms/", 29 | contact=openapi.Contact(email="bekkaze7@gmail.com"), 30 | license=openapi.License(name="Awesome License"), 31 | ), 32 | public=True, 33 | permission_classes=(permissions.AllowAny,), 34 | ) 35 | 36 | urlpatterns = [ 37 | path('swaggerProvider | 43 |Status | 44 |Action | 45 |
---|---|---|
{provider} | 51 |52 | {isBlacklisted(provider) ? 'Blacklisted' : 'Clear'} 53 | | 54 |55 | {isBlacklisted(provider) ? ( 56 | getProviderStatus(provider) === 'open' ? ( 57 | 63 | ) : ( 64 | 67 | ) 68 | ) : ( 69 | '' 70 | )} 71 | | 72 |
Provider | 26 |Status | 27 |
---|---|
{provider} | 33 |34 | {isBlacklisted(provider) ? 'Blacklisted' : 'Clear'} 35 | | 36 |
Hostname | 12 |Description | 13 |Type | 14 |Report | 15 |Checked | 16 |Created | 17 |Monitor | 18 |Alert | 19 |Status | 20 |Action | 21 |
---|---|---|---|---|---|---|---|---|---|
{hostnameData.hostname} | 27 |{hostnameData.description} | 28 |{hostnameData.hostname_type} | 29 |
30 |
31 | {!hostnameData.result ?
33 | Not checked :Detected by: {hostnameData.result.detected_on.length} of {hostnameData.result.providers.length} } 32 | |
34 | {hostnameData.checked} | 35 |{hostnameData.created} | 36 |
37 | {hostnameData.is_alert_enabled ? |
39 |
40 | {hostnameData.is_monitor_enabled ? |
42 | 43 | {hostnameData.status} 44 | | 45 |46 | 114 | | 115 |
24 | Blacklist Monitor and check 25 |
26 |31 | 32 |
33 |Keep it clean from malicious activity
*/} 42 |