mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2025-04-28 02:31:15 +08:00
Rework CSRF and improved .woodpecker.yml
This commit is contained in:
parent
47613a07d2
commit
81dd9334e3
8 changed files with 44 additions and 40 deletions
|
@ -35,17 +35,20 @@ def get_secret(secret_name):
|
|||
|
||||
|
||||
# URL Prefixes
|
||||
USE_HTTPS = (get_secret('USE_HTTPS') == 'True')
|
||||
URL_PREFIX = 'https://' if USE_HTTPS else 'http://'
|
||||
BACKEND_URL = URL_PREFIX + \
|
||||
get_secret('BACKEND_ADDRESS') + ':' + get_secret('BACKEND_PORT')
|
||||
FRONTEND_URL = URL_PREFIX + \
|
||||
get_secret('FRONTEND_ADDRESS') + ':' + get_secret('FRONTEND_PORT')
|
||||
URL_SCHEME = 'https' if (get_secret('USE_HTTPS') == 'True') else 'http'
|
||||
# Backend
|
||||
BACKEND_ADDRESS = get_secret('BACKEND_ADDRESS')
|
||||
BACKEND_PORT = get_secret('BACKEND_PORT')
|
||||
# Frontend
|
||||
FRONTEND_ADDRESS = get_secret('FRONTEND_ADDRESS')
|
||||
FRONTEND_PORT = get_secret('FRONTEND_PORT')
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
CSRF_TRUSTED_ORIGINS = [
|
||||
BACKEND_URL,
|
||||
FRONTEND_URL
|
||||
# Frontend
|
||||
f'{URL_SCHEME}://{FRONTEND_ADDRESS}:{FRONTEND_PORT}',
|
||||
# Backend
|
||||
f'{URL_SCHEME}://{BACKEND_ADDRESS}:{BACKEND_PORT}',
|
||||
# You can also set up https://*.name.xyz for wildcards here
|
||||
]
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from config.settings import STRIPE_SECRET_KEY, STRIPE_SECRET_WEBHOOK, FRONTEND_URL
|
||||
from config.settings import STRIPE_SECRET_KEY, STRIPE_SECRET_WEBHOOK, URL_SCHEME, FRONTEND_ADDRESS, FRONTEND_PORT
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
|
@ -87,9 +87,10 @@ class StripeCheckoutView(APIView):
|
|||
'error': 'Regular users cannot avail prorated plans'
|
||||
}, status=status.HTTP_403_FORBIDDEN)
|
||||
|
||||
success_url = FRONTEND_URL + \
|
||||
success_url = f'{URL_SCHEME}://{FRONTEND_ADDRESS}:{FRONTEND_PORT}' + \
|
||||
'/user/subscription/payment?success=true&agency=False&session_id={CHECKOUT_SESSION_ID}'
|
||||
cancel_url = FRONTEND_URL + '/user/subscription/payment?success=false&user_group=False'
|
||||
cancel_url = f'{URL_SCHEME}://{FRONTEND_ADDRESS}:{FRONTEND_PORT}' + \
|
||||
'/user/subscription/payment?success=false&user_group=False'
|
||||
|
||||
checkout_session = stripe.checkout.Session.create(
|
||||
line_items=[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue