Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Billing #2667

Merged
merged 22 commits into from
Oct 12, 2024
Merged

Billing #2667

merged 22 commits into from
Oct 12, 2024

Conversation

pablonyx
Copy link
Contributor

@pablonyx pablonyx commented Oct 3, 2024

  1. JWT-based authentication:

    • Uses SECRET_JWT_KEY for encrypting user/tenant context
    • Employs JWT_ALGORITHM (HS256) for token signing
  2. Inter-service communication security:

    • DATA_PLANE_SECRET secures control plane and data plane communication
    • Short-lived tokens generated with specific scopes and expiration times
  3. API access control:

    • EXPECTED_API_KEY required in headers for control plane API access
    • Dependency checks for valid API key and JWT in request headers
  4. Stripe integration for secure billing:

    • Stripe API key used for subscription management
    • Tenant IDs stored in Stripe metadata for correlation

Copy link

vercel bot commented Oct 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
internal-search ❌ Failed (Inspect) Oct 12, 2024 6:38pm

@pablonyx pablonyx marked this pull request as ready for review October 5, 2024 21:03
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR introduces comprehensive billing functionality and multi-tenant support to the DAnswer system, integrating Stripe for payment processing and enhancing user management capabilities.

  • Implemented Stripe integration for subscription management in backend/ee/danswer/server/tenants/api.py and web/src/app/ee/admin/cloud-settings/BillingInformationPage.tsx
  • Added new Cloud Settings admin page in web/src/app/ee/admin/cloud-settings/page.tsx for managing billing information
  • Modified PostgreSQL port from 5432 to 5433 in Docker Compose files and backend/danswer/configs/app_configs.py
  • Enhanced multi-tenant support with new functions in backend/danswer/auth/users.py and backend/danswer/server/manage/users.py
  • Hardcoded CLOUD_ENABLED to true in web/src/lib/constants.ts, potentially affecting cloud-related features

22 file(s) reviewed, 9 comment(s)
Edit PR Review Bot Settings

backend/ee/danswer/server/tenants/api.py Outdated Show resolved Hide resolved
backend/ee/danswer/server/tenants/api.py Outdated Show resolved Hide resolved
backend/ee/danswer/server/tenants/models.py Outdated Show resolved Hide resolved
backend/ee/danswer/server/tenants/models.py Outdated Show resolved Hide resolved
backend/ee/danswer/server/tenants/utils.py Outdated Show resolved Hide resolved
web/src/app/ee/admin/cloud-settings/page.tsx Outdated Show resolved Hide resolved
web/src/app/ee/admin/cloud-settings/utils.ts Outdated Show resolved Hide resolved
web/src/lib/constants.ts Outdated Show resolved Hide resolved
@pablonyx pablonyx changed the base branch from vespa_multi to multi_tenant_vespa October 10, 2024 16:38
Copy link
Contributor

@yuhongsun96 yuhongsun96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it works :P

FROM python:3.11.7-slim-bookworm

LABEL com.danswer.maintainer="founders@danswer.ai"
LABEL com.danswer.description="This image is the web/frontend container of Danswer which \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of the comments and things are not correct. I would say this just should not be used by the community.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove this one

from danswer.auth.users import current_admin_user
from danswer.auth.users import current_curator_or_admin_user
from danswer.auth.users import current_user
from danswer.auth.users import current_user_with_expired_token
from danswer.configs.app_configs import APP_API_PREFIX
from danswer.server.danswer_api.ingestion import api_key_dep
from ee.danswer.server.tenants.access import control_plane_dep
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not import ee modules from the MIT stuff. It confuses the separation between the versions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other places this is done but we should address those.

@@ -60,6 +63,7 @@
from ee.danswer.db.api_key import is_api_key_email_address
from ee.danswer.db.external_perm import delete_user__ext_group_for_user__no_commit
from ee.danswer.db.user_group import remove_curator_status__no_commit
from ee.danswer.server.tenants.billing import register_tenant_users
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here and around this line, it should not import from ee

They will be directed to the billing page.
We gate the product when
1) User has ended free trial without adding payment method
2) User's card has declined
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can let them use it and give a warning if the card declined. Hubspot does this and I appreciated that and paid them :P

backend/ee/danswer/server/tenants/api.py Outdated Show resolved Hide resolved
@@ -0,0 +1,243 @@
services:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove this

@pablonyx pablonyx merged commit 895adc4 into multi_tenant_vespa Oct 12, 2024
2 of 3 checks passed
pablonyx added a commit that referenced this pull request Oct 12, 2024
* k

* data -> control

* nit

* nit: error handling

* auth + app

* nit: color standardization

* nit

* nit: typing

* k

* k

* feat: functional upgrading

* feat: add block for downgrading to seats < active users

* add auth

* remove accomplished todo + prints

* nit

* tiny nit

* nit: centralize security

* add tenant expulsion/gating + invite user -> increment billing seat no.

* add cloud configs

* k

* k

* nit: update
github-merge-queue bot pushed a commit that referenced this pull request Oct 13, 2024
* add vespa multi tenancy

* k

* formatting

* Billing (#2667)

* k

* data -> control

* nit

* nit: error handling

* auth + app

* nit: color standardization

* nit

* nit: typing

* k

* k

* feat: functional upgrading

* feat: add block for downgrading to seats < active users

* add auth

* remove accomplished todo + prints

* nit

* tiny nit

* nit: centralize security

* add tenant expulsion/gating + invite user -> increment billing seat no.

* add cloud configs

* k

* k

* nit: update

* k

* k

* k

* k

* nit
@pablonyx pablonyx deleted the billing_multi branch October 17, 2024 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants