auth service created

This commit is contained in:
A'zamov Samandar
2025-04-19 14:58:55 +05:00
parent a4b5833bbe
commit dd0da49eb9
127 changed files with 67 additions and 43 deletions

2
.env.example Normal file
View File

@@ -0,0 +1,2 @@
AUTH_COMMAND=sh ./resources/scripts/entrypoint.sh
JWT_KEY=key

View File

@@ -1,26 +0,0 @@
"""
Accounts app urls
"""
from django.urls import path, include
from rest_framework_simplejwt import views as jwt_views
from .views import RegisterView, ResetPasswordView, MeView, ChangePasswordView
from rest_framework.routers import DefaultRouter
router = DefaultRouter()
router.register("auth", RegisterView, basename="auth")
router.register("auth", ResetPasswordView, basename="reset-password")
router.register("auth", MeView, basename="me")
router.register("auth", ChangePasswordView, basename="change-password")
urlpatterns = [
path("", include(router.urls)),
path("auth/token/", jwt_views.TokenObtainPairView.as_view(), name="token_obtain_pair"),
path("auth/token/verify/", jwt_views.TokenVerifyView.as_view(), name="token_verify"),
path(
"auth/token/refresh/",
jwt_views.TokenRefreshView.as_view(),
name="token_refresh",
),
]

View File

@@ -7,16 +7,35 @@ volumes:
pycache: null
services:
auth-nginx:
traefik:
image: traefik:v2.10
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
- "--providers.docker.exposedbydefault=false"
ports:
- "80:80"
- "8080:8080" # Dashboard uchun
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
- lamenu
auth-nginx:
labels:
- "traefik.enable=true"
- "traefik.http.routers.auth.rule=PathPrefix(`/auth`)"
- "traefik.http.routers.auth.entrypoints=web"
- "traefik.http.services.auth.loadbalancer.server.port=80"
- "traefik.http.middlewares.auth-strip-prefix.stripPrefix.prefixes=/auth"
- "traefik.http.routers.auth.middlewares=auth-strip-prefix"
networks:
- lamenu
ports:
- ${PORT:-8001}:80
volumes:
- ./auth/resources/layout/nginx.conf:/etc/nginx/nginx.conf
- ./auth/resources/:/usr/share/nginx/html/resources/
- ./services/auth/resources/layout/nginx.conf:/etc/nginx/nginx.conf
- ./services/auth/resources/:/usr/share/nginx/html/resources/
build:
context: ./auth
context: ./services/auth
dockerfile: ./docker/Dockerfile.nginx
depends_on:
- auth
@@ -24,14 +43,15 @@ services:
networks:
- lamenu
build:
context: ./auth
context: ./services/auth
dockerfile: ./docker/Dockerfile.web
restart: always
command: ${AUTH_COMMAND:-sh ./resources/scripts/entrypoint.sh}
environment:
- PYTHONPYCACHEPREFIX=/var/cache/pycache
- JWT_KEY=${JWT_KEY}
volumes:
- ./auth:/code
- ./services/auth:/code
- pycache:/var/cache/pycache
depends_on:
- auth-db

3
services/auth/.flake8 Normal file
View File

@@ -0,0 +1,3 @@
[flake8]
max-line-length = 120
ignore = E701, E704, W503

2
services/auth/README.MD Normal file
View File

@@ -0,0 +1,2 @@
# JST-DJANGO
[Docs](https://docs.jscorp.uz)

View File

@@ -9,7 +9,7 @@ SIMPLE_JWT = {
"BLACKLIST_AFTER_ROTATION": False,
"UPDATE_LAST_LOGIN": False,
"ALGORITHM": "HS256",
"SIGNING_KEY": env("DJANGO_SECRET_KEY"),
"SIGNING_KEY": env("JWT_KEY"),
"VERIFYING_KEY": "",
"AUDIENCE": None,
"ISSUER": None,

View File

@@ -109,7 +109,7 @@ AUTH_PASSWORD_VALIDATORS = [
TIME_ZONE = "Asia/Tashkent"
USE_I18N = True
USE_TZ = True
STATIC_URL = "resources/static/"
STATIC_URL = "/auth/resources/static/"
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
# Date formats
@@ -140,7 +140,7 @@ LOCALE_PATHS = [os.path.join(BASE_DIR, "resources/locale")]
LANGUAGE_CODE = "uz"
MEDIA_ROOT = os.path.join(BASE_DIR, "resources/media") # Media files
MEDIA_URL = "/resources/media/"
MEDIA_URL = "/auth/resources/media/"
AUTH_USER_MODEL = "accounts.User"
@@ -152,9 +152,6 @@ CSRF_TRUSTED_ORIGINS = env("CSRF_TRUSTED_ORIGINS").split(",")
SILKY_AUTHORISATION = True
SILKY_PYTHON_PROFILER = True
JST_LANGUAGES = [
{
"code": "uz",

View File

@@ -0,0 +1,26 @@
"""
Accounts app urls
"""
from django.urls import path, include
from rest_framework_simplejwt import views as jwt_views
from .views import RegisterView, ResetPasswordView, MeView, ChangePasswordView
from rest_framework.routers import DefaultRouter
router = DefaultRouter()
router.register("", RegisterView, basename="auth")
router.register("", ResetPasswordView, basename="reset-password")
router.register("", MeView, basename="me")
router.register("", ChangePasswordView, basename="change-password")
urlpatterns = [
path("", include(router.urls)),
path("token/", jwt_views.TokenObtainPairView.as_view(), name="token_obtain_pair"),
path("token/verify/", jwt_views.TokenVerifyView.as_view(), name="token_verify"),
path(
"token/refresh/",
jwt_views.TokenRefreshView.as_view(),
name="token_refresh",
),
]

View File

@@ -29,14 +29,14 @@ http {
server_name _;
location / {
proxy_pass http://web:8000;
proxy_pass http://auth:8000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
}
location /ws/ {
proxy_pass http://web:8000; # Uvicorn serveri ishga tushadigan port
proxy_pass http://auth:8000; # Uvicorn serveri ishga tushadigan port
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';

Some files were not shown because too many files have changed in this diff Show More