mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-28 01:45:07 +01:00
Disable Subscription if Stripe environment not setup
Deduplicate DJANGO_SECRET_KEY and KHOJ_DJANGO_SECRET_KEY to latter name as prefixed with KHOJ as KHOJ app specific
This commit is contained in:
parent
09e1235832
commit
a2609973b8
7 changed files with 18 additions and 7 deletions
|
@ -21,7 +21,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent.parent
|
|||
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY")
|
||||
SECRET_KEY = os.getenv("KHOJ_DJANGO_SECRET_KEY")
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = os.getenv("DJANGO_DEBUG", "False") == "True"
|
||||
|
|
|
@ -150,6 +150,8 @@ def configure_routes(app):
|
|||
app.include_router(api, prefix="/api")
|
||||
app.include_router(api_beta, prefix="/api/beta")
|
||||
app.include_router(indexer, prefix="/api/v1/index")
|
||||
if state.billing_enabled:
|
||||
logger.info("💳 Enabled Billing")
|
||||
app.include_router(subscription_router, prefix="/api/subscription")
|
||||
app.include_router(web_client)
|
||||
app.include_router(auth_router, prefix="/auth")
|
||||
|
|
|
@ -158,6 +158,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if billing_enabled %}
|
||||
<div class="section">
|
||||
<h2 class="section-title">Billing</h2>
|
||||
<div class="section-cards">
|
||||
|
@ -219,6 +220,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="section general-settings">
|
||||
<div id="results-count" title="Number of items to show in search and use for chat response">
|
||||
<label for="results-count-slider">Results Count: <span id="results-count-value">5</span></label>
|
||||
|
|
|
@ -24,7 +24,9 @@ logger = logging.getLogger(__name__)
|
|||
auth_router = APIRouter()
|
||||
|
||||
if not state.anonymous_mode and not (os.environ.get("GOOGLE_CLIENT_ID") and os.environ.get("GOOGLE_CLIENT_SECRET")):
|
||||
logger.info("Please set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET environment variables to use Google OAuth")
|
||||
logger.warn(
|
||||
"🚨 Use --anonymous-mode flag to disable Google OAuth or set GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET environment variables to enable it"
|
||||
)
|
||||
else:
|
||||
config = Config(environ=os.environ)
|
||||
|
||||
|
|
|
@ -12,13 +12,11 @@ import stripe
|
|||
# Internal Packages
|
||||
from database import adapters
|
||||
|
||||
|
||||
# Stripe integration for Khoj Cloud Subscription
|
||||
stripe.api_key = os.getenv("STRIPE_API_KEY")
|
||||
endpoint_secret = os.getenv("STRIPE_SIGNING_SECRET")
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
subscription_router = APIRouter()
|
||||
|
||||
|
||||
|
|
|
@ -150,6 +150,7 @@ def config_page(request: Request):
|
|||
"conversation_options": all_conversation_options,
|
||||
"selected_conversation_config": selected_conversation_config.id if selected_conversation_config else None,
|
||||
"user_photo": user_picture,
|
||||
"billing_enabled": state.billing_enabled,
|
||||
"subscription_state": user_subscription_state,
|
||||
"subscription_renewal_date": subscription_renewal_date,
|
||||
"khoj_cloud_subscription_url": os.getenv("KHOJ_CLOUD_SUBSCRIPTION_URL"),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Standard Packages
|
||||
import os
|
||||
import threading
|
||||
from typing import List, Dict
|
||||
from collections import defaultdict
|
||||
|
@ -35,3 +36,8 @@ khoj_version: str = None
|
|||
device = get_device()
|
||||
chat_on_gpu: bool = True
|
||||
anonymous_mode: bool = False
|
||||
billing_enabled: bool = (
|
||||
os.getenv("STRIPE_API_KEY") is not None
|
||||
and os.getenv("STRIPE_SIGNING_SECRET") is not None
|
||||
and os.getenv("KHOJ_CLOUD_SUBSCRIPTION_URL") is not None
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue