change RS256 algorithm
Some checks failed
Build And Test / build-and-push (push) Failing after 2m8s

This commit is contained in:
2025-09-28 20:52:08 +09:00
parent a2b01516c8
commit 0fc7d3e9bb
8 changed files with 77 additions and 172 deletions

View File

@ -169,12 +169,36 @@ TEMPLATES = [
WSGI_APPLICATION = 'auth_prj.wsgi.application'
SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=5),
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),
"ROTATE_REFRESH_TOKENS": True,
"BLACKLIST_AFTER_ROTATION": True, # 사용한 토큰은 갱신하면 블랙리스트처리됨
}
# JWT 설정
# https://django-rest-framework-simplejwt.readthedocs.io/en/latest/settings.html
# istio jwt token check
ISTIO_JWT = os.environ.get("ISTIO_JWT", "0") == "1"
if ISTIO_JWT:
# RS256 모드
# 운영환경에서 key파일은 POD mount로 적용하는게 안전
with open(BASE_DIR / "keys/private.pem", "r") as f:
PRIVATE_KEY = f.read()
with open(BASE_DIR / "keys/public.pem", "r") as f:
PUBLIC_KEY = f.read()
SIMPLE_JWT = {
"ALGORITHM": "RS256",
"SIGNING_KEY": PRIVATE_KEY,
"VERIFYING_KEY": PUBLIC_KEY,
"ISSUER": "msa-user",
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=30),
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),
"ROTATE_REFRESH_TOKENS": True,
"BLACKLIST_AFTER_ROTATION": True, # 사용한 토큰은 갱신하면 블랙리스트처리됨
}
else:
SIMPLE_JWT = {
"ACCESS_TOKEN_LIFETIME": timedelta(minutes=5),
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),
"ROTATE_REFRESH_TOKENS": True,
"BLACKLIST_AFTER_ROTATION": True, # 사용한 토큰은 갱신하면 블랙리스트처리됨
}
DATABASES = {
"default": {

View File

@ -1,23 +0,0 @@
from django.urls import path, include, re_path
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
schema_view = get_schema_view(
openapi.Info(
title="msa-django-auth API",
default_version='v1',
description="인증 서비스용 JWT API 문서",
),
public=True,
permission_classes=(permissions.AllowAny,),
)
urlpatterns = [
path('admin/', admin.site.urls),
path('api/auth/', include('users.urls')),
re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
path('swagger/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
]