Skip to content

Commit

Permalink
Include resend as a default dependency, rather than restricting to prod
Browse files Browse the repository at this point in the history
  • Loading branch information
sabaimran committed Dec 17, 2024
1 parent 741e9f5 commit 3b050a3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 24 deletions.
34 changes: 17 additions & 17 deletions documentation/docs/advanced/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ By default, most of the instructions for self-hosting Khoj assume a single user,
Remove the `--anonymous-mode` flag from your khoj start up command or docker-compose file to enable authentication.
:::

For either of these methods, you'll need to use the prod version of the Khoj package. You can install it as below:

<Tabs groupId="server" queryString>
<TabItem value="docker" label="Docker">
Update your `docker-compose.yml` to use the prod image
```bash
image: ghcr.io/khoj-ai/khoj-cloud:latest
```
</TabItem>

<TabItem value="pip" label="Pip">
```bash
pip install khoj[prod]
```
</TabItem>
</Tabs>

## Using Magic Links
The most secure way to do this is to integrate with [Resend](https://resend.com).

Expand Down Expand Up @@ -62,6 +45,23 @@ It's still possible to use the magic links feature without Resend, but you'll ne

## Using Google OAuth

For this method, you'll need to use the prod version of the Khoj package. You can install it as below:

<Tabs groupId="server" queryString>
<TabItem value="docker" label="Docker">
Update your `docker-compose.yml` to use the prod image
```bash
image: ghcr.io/khoj-ai/khoj-cloud:latest
```
</TabItem>

<TabItem value="pip" label="Pip">
```bash
pip install khoj[prod]
```
</TabItem>
</Tabs>

To set up your self-hosted Khoj with Google Auth, you need to create a project in the Google Cloud Console and enable the Google Auth API.

To implement this, you'll need to:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ dependencies = [
"docx2txt == 0.8",
"google-generativeai == 0.8.3",
"pyjson5 == 1.6.7",
"resend == 1.0.1",
]
dynamic = ["version"]

Expand All @@ -108,7 +109,6 @@ prod = [
"stripe == 7.3.0",
"twilio == 8.11",
"boto3 >= 1.34.57",
"resend == 1.0.1",
]
dev = [
"khoj[prod]",
Expand Down
8 changes: 2 additions & 6 deletions src/khoj/routers/email.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import logging
import os

try:
import resend
except ImportError:
pass

import markdown_it
import resend
from django.conf import settings
from jinja2 import Environment, FileSystemLoader

Expand All @@ -23,7 +19,7 @@
env = Environment(loader=FileSystemLoader(static_files))

if not RESEND_API_KEY:
logger.warn("RESEND_API_KEY not set - email sending disabled")
logger.warning("RESEND_API_KEY not set - email sending disabled")
else:
resend.api_key = RESEND_API_KEY

Expand Down

1 comment on commit 3b050a3

@sabaimran
Copy link
Member Author

Choose a reason for hiding this comment

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

In response to #1012

Please sign in to comment.