Skip to content

Commit ef4eb97

Browse files
committed
ip filtering 추가
1 parent 9890bba commit ef4eb97

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

payment/views.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,19 @@
66
from payment.logic import generate_payment_key
77
from payment.models import Payment
88

9+
from django.conf import settings
10+
911

1012
class PortoneWebhookApi(APIView):
1113
def post(self, request):
12-
# TODO: IP Filtering
13-
# 52.78.100.19
14-
# 52.78.48.223
15-
# 52.78.5.241 (Webhook Test Only)
14+
portone_ips = [
15+
"52.78.100.19",
16+
"52.78.48.223",
17+
"52.78.5.241" # (Webhook Test Only)
18+
]
19+
20+
if settings.DEBUG is False and request.META.get("REMOTE_ADDR") not in portone_ips:
21+
raise ValueError("Not Allowed IP")
1622

1723
target_payment = Payment.objects.get(payment_key=request.data["merchant_uid"])
1824

0 commit comments

Comments
 (0)