feat: add Uptime Kuma integration with periodic ping task and configuration options

This commit is contained in:
Christian Krakau-Louis
2025-04-01 22:44:46 +02:00
parent 4ba34e2cbc
commit ceaed1a081
19 changed files with 921 additions and 525 deletions
+100
View File
@@ -0,0 +1,100 @@
# Setting up Amazon S3 Integration
This guide explains how to set up the Amazon S3 integration for DocuNova.
## Required Configuration Parameters
| **Variable** | **Description** |
|---------------------------------|-------------------------------------------------------|
| `AWS_ACCESS_KEY_ID` | AWS IAM access key ID |
| `AWS_SECRET_ACCESS_KEY` | AWS IAM secret access key |
| `AWS_REGION` | AWS region where your S3 bucket is located (default: `us-east-1`) |
| `S3_BUCKET_NAME` | Name of your S3 bucket |
| `S3_FOLDER_PREFIX` | Optional prefix/folder path for uploaded files |
| `S3_STORAGE_CLASS` | Storage class for uploaded objects (default: `STANDARD`) |
| `S3_ACL` | Access control for uploaded files (default: `private`) |
For a complete list of configuration options, see the [Configuration Guide](ConfigurationGuide.md).
## Step-by-Step Setup Instructions
### 1. Create an S3 bucket
1. Go to the [Amazon S3 Console](https://s3.console.aws.amazon.com/)
2. Click "Create bucket"
3. Enter a globally unique name for your bucket
4. Select your preferred AWS region
5. Configure other settings as needed (block public access is recommended)
6. Click "Create bucket"
### 2. Create an IAM User with S3 Access
1. Go to the [AWS IAM Console](https://console.aws.amazon.com/iam/)
2. Navigate to "Users" and click "Add users"
3. Enter a name (e.g., "docunova-s3-access")
4. For access type, select "Programmatic access"
5. Click "Next: Permissions"
6. Choose "Attach existing policies directly" and search for "AmazonS3FullAccess"
7. For more security, you can create a custom policy limiting access to just your bucket
8. Click through to review and create the user
9. On the final page, you'll see the Access Key ID and Secret Access Key
10. Save these credentials securely as they won't be shown again
### 3. Configure DocuNova
1. Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` to the credentials from step 2
2. Set `AWS_REGION` to the region where your bucket was created (e.g., "us-east-1")
3. Set `S3_BUCKET_NAME` to your bucket name
4. Set `S3_FOLDER_PREFIX` to organize files in specific subfolder paths (e.g., "invoices/" or "documents/2023/")
5. Optionally customize `S3_STORAGE_CLASS` and `S3_ACL` for your storage needs
### 4. Optional: Create a Custom IAM Policy (for better security)
1. In IAM console, go to "Policies" and click "Create policy"
2. Use the JSON editor and paste a policy like this (replace `your-bucket-name`):
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::your-bucket-name",
"arn:aws:s3:::your-bucket-name/*"
]
}
]
}
```
3. After creating the policy, attach it to your user instead of the broader AmazonS3FullAccess
## Storage Class Options
Amazon S3 offers several storage classes to optimize costs:
| **Storage Class** | **Use Case** | **Retrieval Time** |
|------------------|--------------|-------------------|
| `STANDARD` | Default, frequently accessed data | Immediate |
| `INTELLIGENT_TIERING` | Data with changing or unknown access patterns | Immediate |
| `STANDARD_IA` | Long-lived, infrequently accessed data | Immediate |
| `ONEZONE_IA` | Long-lived, infrequently accessed, non-critical data | Immediate |
| `GLACIER_IR` | Archive data that needs immediate access | Immediate |
| `GLACIER` | Archive data that rarely needs to be accessed | Minutes to hours |
| `DEEP_ARCHIVE` | Long-term archive and digital preservation | Hours |
Set your preferred storage class using the `S3_STORAGE_CLASS` parameter.
## Access Control List (ACL) Options
Common ACL values include:
- `private` (default) - Only the bucket owner has access
- `public-read` - Anyone can read the file (use cautiously)
- `bucket-owner-full-control` - Useful for cross-account uploads
For most document storage scenarios, `private` is recommended for security.
+45 -331
View File
@@ -55,12 +55,14 @@ DocuNova can monitor multiple IMAP mailboxes for document attachments. Each mail
### Dropbox
| **Variable** | **Description** | **How to Obtain** |
|-------------------------|--------------------------------------------------|---------------------------------------------------------|
| `DROPBOX_APP_KEY` | Dropbox API app key. | [Dropbox Developer Console](#setting-up-dropbox-integration) |
| `DROPBOX_APP_SECRET` | Dropbox API app secret. | [Dropbox Developer Console](#setting-up-dropbox-integration) |
| `DROPBOX_REFRESH_TOKEN` | OAuth2 refresh token for Dropbox. | Follow steps in [Dropbox Setup](#setting-up-dropbox-integration) |
| `DROPBOX_FOLDER` | Default folder path for Dropbox uploads. | e.g. `"/Documents/Uploads"` (leading slash optional) |
| **Variable** | **Description** |
|-------------------------|--------------------------------------------------|
| `DROPBOX_APP_KEY` | Dropbox API app key. |
| `DROPBOX_APP_SECRET` | Dropbox API app secret. |
| `DROPBOX_REFRESH_TOKEN` | OAuth2 refresh token for Dropbox. |
| `DROPBOX_FOLDER` | Default folder path for Dropbox uploads. |
For detailed setup instructions, see the [Dropbox Setup Guide](DropboxSetup.md).
### Nextcloud
@@ -73,11 +75,13 @@ DocuNova can monitor multiple IMAP mailboxes for document attachments. Each mail
### Google Drive
| **Variable** | **Description** | **How to Obtain** |
|---------------------------------|-------------------------------------------------------|------------------------------------------------------|
| `GOOGLE_DRIVE_CREDENTIALS_JSON` | JSON string containing service account credentials | [Google Cloud Console](#setting-up-google-drive-api) |
| `GOOGLE_DRIVE_FOLDER_ID` | Google Drive folder ID for file uploads | See [folder ID instructions](#get-google-drive-folder-id) |
| `GOOGLE_DRIVE_DELEGATE_TO` | Email address to delegate permissions (optional) | User email in your Google Workspace |
| **Variable** | **Description** |
|---------------------------------|-------------------------------------------------------|
| `GOOGLE_DRIVE_CREDENTIALS_JSON` | JSON string containing service account credentials |
| `GOOGLE_DRIVE_FOLDER_ID` | Google Drive folder ID for file uploads |
| `GOOGLE_DRIVE_DELEGATE_TO` | Email address to delegate permissions (optional) |
For detailed setup instructions, see the [Google Drive Setup Guide](GoogleDriveSetup.md).
### WebDAV
@@ -125,166 +129,36 @@ DocuNova can monitor multiple IMAP mailboxes for document attachments. Each mail
### OneDrive / Microsoft Graph
| **Variable** | **Description** | **How to Obtain** |
|---------------------------------|-------------------------------------------------------|------------------------------------------------------|
| `ONEDRIVE_CLIENT_ID` | Azure AD application client ID | [Microsoft Azure Portal](#setting-up-onedrive-integration) |
| `ONEDRIVE_CLIENT_SECRET` | Azure AD application client secret | [Microsoft Azure Portal](#setting-up-onedrive-integration) |
| `ONEDRIVE_TENANT_ID` | Azure AD tenant ID: use "common" for personal accounts or your tenant ID for corporate accounts | [Microsoft Azure Portal](#setting-up-onedrive-integration) |
| `ONEDRIVE_REFRESH_TOKEN` | OAuth 2.0 refresh token (required for personal accounts) | Follow steps in [Personal OneDrive Setup](#personal-onedrive-setup) |
| `ONEDRIVE_FOLDER_PATH` | Folder path in OneDrive for storing documents | e.g. `/Documents/Uploads` or `Documents/Uploads` |
| **Variable** | **Description** |
|---------------------------------|-------------------------------------------------------|
| `ONEDRIVE_CLIENT_ID` | Azure AD application client ID |
| `ONEDRIVE_CLIENT_SECRET` | Azure AD application client secret |
| `ONEDRIVE_TENANT_ID` | Azure AD tenant ID: use "common" for personal accounts or your tenant ID for corporate accounts |
| `ONEDRIVE_REFRESH_TOKEN` | OAuth 2.0 refresh token (required for personal accounts) |
| `ONEDRIVE_FOLDER_PATH` | Folder path in OneDrive for storing documents |
## Setting up OneDrive Integration
There are two main types of Microsoft accounts that can be used with OneDrive integration:
1. **Personal Microsoft Accounts** - These include accounts with @outlook.com, @hotmail.com, @live.com domains, or personal Microsoft accounts linked to other email addresses (like Gmail)
2. **Work/School Microsoft Accounts** - These are accounts managed by an organization through Microsoft 365 or Azure Active Directory
The setup process differs slightly based on which account type you're using.
### Common Setup Steps (All Account Types)
1. **Register an application in Azure Active Directory**:
- Go to the [Azure Portal](https://portal.azure.com/)
- Navigate to "Azure Active Directory" > "App registrations"
- Click "New registration"
- Enter a name for your application (e.g., "DocuNova")
- For "Supported account types", select the appropriate option:
- For personal accounts: "Accounts in any organizational directory and personal Microsoft accounts"
- For corporate accounts only: "Accounts in this organizational directory only"
- For Redirect URI, select "Web" and enter a URL you can access (e.g., `http://localhost:8000/auth/callback`)
- Click "Register"
2. **Get Application (client) ID**:
- After registration, note the "Application (client) ID" from the overview page
- Set this value as `ONEDRIVE_CLIENT_ID`
3. **Create a client secret**:
- In your application page, go to "Certificates & secrets"
- Under "Client secrets," click "New client secret"
- Add a description and select an expiration period
- Click "Add" and immediately copy the secret value (it will only be shown once)
- Set this value as `ONEDRIVE_CLIENT_SECRET`
### For Personal Microsoft Accounts
If you're using a personal Microsoft account (@outlook.com, @hotmail.com, or personal accounts linked to other emails):
1. **Set Tenant ID to "common"**:
- Set `ONEDRIVE_TENANT_ID=common` in your configuration
2. **Configure API permissions**:
- In your application page, go to "API permissions"
- Click "Add a permission"
- Select "Microsoft Graph" > "Delegated permissions"
- Search for and add the following permissions:
- `Files.ReadWrite` (Allows the app to read and write files that the user has access to)
- `offline_access` (Needed for refresh tokens)
- Click "Add permissions"
3. **Generate a Refresh Token**:
- Use the following URL (replace CLIENT_ID and REDIRECT_URI with your values):
```
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=YOUR_REDIRECT_URI&response_mode=query&scope=offline_access%20Files.ReadWrite
```
- Open this URL in your browser
- Sign in with your personal Microsoft account
- After authentication, you'll be redirected to your redirect URI with a code parameter in the URL
- Copy the code value from the URL (everything after "code=")
4. **Exchange Code for Refresh Token**:
- Use the following command to exchange the code for tokens:
```bash
curl -X POST https://login.microsoftonline.com/common/oauth2/v2.0/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=YOUR_CLIENT_ID&scope=offline_access Files.ReadWrite&code=YOUR_AUTH_CODE&redirect_uri=YOUR_REDIRECT_URI&grant_type=authorization_code&client_secret=YOUR_CLIENT_SECRET"
```
- From the response JSON, copy the `refresh_token` value
- Set this as `ONEDRIVE_REFRESH_TOKEN` in your configuration
### For Corporate Microsoft Accounts
If you're using a work/school account provided by your organization:
1. **Get your Tenant ID**:
- In the Azure Portal, find your "Tenant ID" (also called "Directory ID")
- It will be in the Azure Active Directory overview or properties section
- Set this value as `ONEDRIVE_TENANT_ID` in your configuration
2. **Configuration based on use case**:
**Option A: Access your own OneDrive (Interactive Login)**
This option requires a refresh token just like personal accounts:
- Follow the same steps as for personal accounts, but use your work email to sign in
- Make sure to set `ONEDRIVE_TENANT_ID` to your organization's tenant ID instead of "common"
- Set the refresh token you receive as `ONEDRIVE_REFRESH_TOKEN`
**Option B: Access OneDrive as a system service (App-only access)**
This option is for service accounts or automated systems with no user interaction:
- In API permissions, add "Application permissions" instead of "Delegated permissions"
- Add `Files.ReadWrite.All` permission under "Application permissions"
- Click "Grant admin consent" (requires admin privileges)
- In this case, `ONEDRIVE_REFRESH_TOKEN` is not needed as the app will use client credentials flow
- Note: This approach can only access specific shared folders or sites, not personal OneDrives
### Troubleshooting OAuth Login Issues
If you encounter errors during authentication:
1. **Check account permissions**:
- Ensure your Microsoft account has the necessary permissions to grant access
- For corporate accounts, check if your admin has restricted third-party app access
2. **Permission errors**:
- Verify the app registration has the correct API permissions
- For corporate accounts, ensure an admin has consented to the permissions
3. **Refresh token expired**:
- If uploads stop working, you may need to generate a new refresh token
- Repeat the process to get a new authorization code and refresh token
### Configuration Examples
**Personal Microsoft Account:**
```dotenv
ONEDRIVE_CLIENT_ID=12345678-1234-1234-1234-123456789012
ONEDRIVE_CLIENT_SECRET=your_client_secret
ONEDRIVE_TENANT_ID=common
ONEDRIVE_REFRESH_TOKEN=your_refresh_token
ONEDRIVE_FOLDER_PATH=Documents/Uploads
```
**Corporate Account with Interactive Login:**
```dotenv
ONEDRIVE_CLIENT_ID=12345678-1234-1234-1234-123456789012
ONEDRIVE_CLIENT_SECRET=your_client_secret
ONEDRIVE_TENANT_ID=87654321-4321-4321-4321-210987654321
ONEDRIVE_REFRESH_TOKEN=your_refresh_token
ONEDRIVE_FOLDER_PATH=Documents/Uploads
```
**Corporate Account with App-Only Access:**
```dotenv
ONEDRIVE_CLIENT_ID=12345678-1234-1234-1234-123456789012
ONEDRIVE_CLIENT_SECRET=your_client_secret
ONEDRIVE_TENANT_ID=87654321-4321-4321-4321-210987654321
# No refresh token needed for app-only access
ONEDRIVE_FOLDER_PATH=Documents/Uploads
```
For detailed setup instructions, see the [OneDrive Setup Guide](OneDriveSetup.md).
### Amazon S3
| **Variable** | **Description** | **How to Obtain** |
|---------------------------------|-------------------------------------------------------|------------------------------------------------------|
| `AWS_ACCESS_KEY_ID` | AWS IAM access key ID | [AWS IAM Console](#setting-up-amazon-s3-integration) |
| `AWS_SECRET_ACCESS_KEY` | AWS IAM secret access key | [AWS IAM Console](#setting-up-amazon-s3-integration) |
| `AWS_REGION` | AWS region where your S3 bucket is located (default: `us-east-1`) | [AWS S3 Console](https://s3.console.aws.amazon.com/) |
| `S3_BUCKET_NAME` | Name of your S3 bucket | [AWS S3 Console](https://s3.console.aws.amazon.com/) |
| `S3_FOLDER_PREFIX` | Optional prefix/folder path for uploaded files | e.g. `documents/` or `uploads/2023/` (include trailing slash) |
| `S3_STORAGE_CLASS` | Storage class for uploaded objects (default: `STANDARD`) | [S3 Storage Classes](https://aws.amazon.com/s3/storage-classes/) |
| `S3_ACL` | Access control for uploaded files (default: `private`) | `private`, `public-read`, etc. |
| **Variable** | **Description** |
|---------------------------------|-------------------------------------------------------|
| `AWS_ACCESS_KEY_ID` | AWS IAM access key ID |
| `AWS_SECRET_ACCESS_KEY` | AWS IAM secret access key |
| `AWS_REGION` | AWS region where your S3 bucket is located (default: `us-east-1`) |
| `S3_BUCKET_NAME` | Name of your S3 bucket |
| `S3_FOLDER_PREFIX` | Optional prefix/folder path for uploaded files |
| `S3_STORAGE_CLASS` | Storage class for uploaded objects (default: `STANDARD`) |
| `S3_ACL` | Access control for uploaded files (default: `private`) |
For detailed setup instructions, see the [Amazon S3 Setup Guide](AmazonS3Setup.md).
### Uptime Kuma
| **Variable** | **Description** |
|-----------------------------|----------------------------------------------------------------|
| `UPTIME_KUMA_URL` | Uptime Kuma push URL for monitoring the application's health. |
| `UPTIME_KUMA_PING_INTERVAL` | How often to ping Uptime Kuma in minutes (default: `5`). |
## Configuration Examples
@@ -395,172 +269,12 @@ S3_BUCKET_NAME=my-document-bucket
S3_FOLDER_PREFIX=documents/uploads/2023/ # Will place files in this subfolder
S3_STORAGE_CLASS=STANDARD
S3_ACL=private
# Uptime Kuma
UPTIME_KUMA_URL=https://kuma.example.com/api/push/abcde12345?status=up
UPTIME_KUMA_PING_INTERVAL=5
```
## Setting up Google Drive API
To use the Google Drive integration, follow these steps:
1. **Create a Google Cloud Project**:
- Go to the [Google Cloud Console](https://console.cloud.google.com/)
- Create a new project or select an existing one
- Navigate to "APIs & Services" > "Library"
- Search for and enable the "Google Drive API"
2. **Create Service Account**:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "Service Account"
- Fill in the service account details and click "Create"
- Add appropriate roles (e.g., "Editor" for full access)
- Click "Continue" and then "Done"
3. **Generate Service Account Key**:
- Find your service account in the list and click on it
- Go to the "Keys" tab
- Click "Add Key" > "Create New Key"
- Choose JSON format and click "Create"
- The key file will be downloaded automatically
4. **Configure DocuNova**:
- Open the downloaded JSON key file
- Set the entire JSON content as the `GOOGLE_DRIVE_CREDENTIALS_JSON` environment variable
- For security, ensure the JSON is properly escaped if your deployment method requires it
### Get Google Drive Folder ID
To find your Google Drive folder ID:
1. Navigate to the desired folder in Google Drive web interface
2. The URL will look like: `https://drive.google.com/drive/folders/1a2b3c4d5e6f7g8h9i0j`
3. The string after "folders/" is your folder ID (in this example: `1a2b3c4d5e6f7g8h9i0j`)
4. Set this value as `GOOGLE_DRIVE_FOLDER_ID` in your configuration
### Domain-Wide Delegation (Optional)
If you need the service account to access files on behalf of users in your Google Workspace:
1. In your [Google Workspace Admin Console](https://admin.google.com/), go to:
- Security > API Controls > Domain-wide Delegation
2. Click "Add new" and provide:
- Client ID: your service account's client ID (found in the JSON credentials file)
- OAuth Scopes: `https://www.googleapis.com/auth/drive`
3. Set `GOOGLE_DRIVE_DELEGATE_TO` to the email address of the user to impersonate
This setup is only relevant for Google Workspace environments where you need the service account to access user-specific files.
## Setting up Dropbox Integration
To use the Dropbox integration, you'll need to create a Dropbox app and generate OAuth2 credentials:
1. **Create a Dropbox App**:
- Go to the [Dropbox Developer Apps Console](https://www.dropbox.com/developers/apps)
- Click "Create app"
- Select "Scoped access" for API
- Choose "Full Dropbox" access (or "App folder" for more restricted access)
- Give your app a name (e.g., "DocuNova")
- Click "Create app"
2. **Configure App Permissions**:
- In your app's settings page, go to the "Permissions" tab
- Enable the following permissions:
- `files.content.write` (to upload files)
- `files.content.read` (if you need to read file content)
- Click "Submit" to save changes
3. **Get App Key and Secret**:
- On your app's settings page, find the "App key" and "App secret"
- Set these as `DROPBOX_APP_KEY` and `DROPBOX_APP_SECRET` in your configuration
4. **Generate a Refresh Token**:
- Go to the "OAuth 2" tab in your app settings
- Add a redirect URI: `http://localhost` (this is for the authorization flow)
- Generate an authorization URL with these instructions:
```
https://www.dropbox.com/oauth2/authorize?client_id=YOUR_APP_KEY&response_type=code&token_access_type=offline
```
- Replace `YOUR_APP_KEY` with your app key
- Open this URL in your browser
- Authorize the app when prompted
- You'll be redirected to `localhost` with a code parameter in the URL
- Copy this code parameter
5. **Exchange the Code for a Refresh Token**:
- Use this curl command to exchange the code for tokens:
```bash
curl -X POST https://api.dropboxapi.com/oauth2/token \
-d code=YOUR_AUTH_CODE \
-d grant_type=authorization_code \
-d client_id=YOUR_APP_KEY \
-d client_secret=YOUR_APP_SECRET \
-d redirect_uri=http://localhost
```
- From the response, copy the `refresh_token` value
6. **Configure DocuNova**:
- Set `DROPBOX_APP_KEY`, `DROPBOX_APP_SECRET`, and `DROPBOX_REFRESH_TOKEN` with your values
- Set `DROPBOX_FOLDER` to the path where files should be uploaded
The system will use the refresh token to automatically generate short-lived access tokens when needed, so you shouldn't need to worry about token expiration.
## Setting up Amazon S3 Integration
To use the Amazon S3 integration, you'll need an AWS account and an S3 bucket:
1. **Create an S3 bucket**:
- Go to the [Amazon S3 Console](https://s3.console.aws.amazon.com/)
- Click "Create bucket"
- Enter a globally unique name for your bucket
- Select your preferred AWS region
- Configure other settings as needed (block public access is recommended)
- Click "Create bucket"
2. **Create an IAM User with S3 Access**:
- Go to the [AWS IAM Console](https://console.aws.amazon.com/iam/)
- Navigate to "Users" and click "Add users"
- Enter a name (e.g., "docunova-s3-access")
- For access type, select "Programmatic access"
- Click "Next: Permissions"
- Choose "Attach existing policies directly" and search for "AmazonS3FullAccess"
- For more security, you can create a custom policy limiting access to just your bucket
- Click through to review and create the user
- On the final page, you'll see the Access Key ID and Secret Access Key
- Save these credentials securely as they won't be shown again
3. **Configure DocuNova**:
- Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` to the credentials from step 2
- Set `AWS_REGION` to the region where your bucket was created (e.g., "us-east-1")
- Set `S3_BUCKET_NAME` to your bucket name
- Set `S3_FOLDER_PREFIX` to organize files in specific subfolder paths (e.g., "invoices/" or "documents/2023/")
- Optionally customize `S3_STORAGE_CLASS` and `S3_ACL` for your storage needs
4. **Optional: Create a Custom IAM Policy** (for better security):
- In IAM console, go to "Policies" and click "Create policy"
- Use the JSON editor and paste a policy like this (replace `your-bucket-name`):
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::your-bucket-name",
"arn:aws:s3:::your-bucket-name/*"
]
}
]
}
```
- After creating the policy, attach it to your user instead of the broader AmazonS3FullAccess
## Selective Service Configuration
You can choose which document storage services to use by only including the relevant environment variables. For example, if you only want to use Dropbox, include only the Dropbox variables and omit the Paperless NGX and Nextcloud variables.
+37
View File
@@ -0,0 +1,37 @@
# DocuNova Configuration
This section contains detailed documentation about configuring DocuNova for your environment.
## Configuration Overview
DocuNova is designed to be highly configurable through environment variables, typically set in a `.env` file. This allows you to enable only the services and integrations you need for your specific use case.
## Documentation Sections
- [Configuration Guide](ConfigurationGuide.md) - Complete list of all available configuration parameters
- [Google Drive Setup](GoogleDriveSetup.md) - How to set up Google Drive integration
- [Dropbox Setup](DropboxSetup.md) - How to set up Dropbox integration
- [OneDrive Setup](OneDriveSetup.md) - How to set up Microsoft OneDrive/Graph integration
- [Amazon S3 Setup](AmazonS3Setup.md) - How to set up Amazon S3 integration
## Configuration File Location
The `.env` file should be placed at the root of the project directory. When using Docker Compose, you can reference it with the `env_file` directive in your `docker-compose.yml`.
## Example Configuration
Below is a minimal example configuration to get started:
```dotenv
# Core settings
DATABASE_URL=sqlite:///./app/database.db
REDIS_URL=redis://redis:6379/0
WORKDIR=/workdir
GOTENBERG_URL=http://gotenberg:3000
EXTERNAL_HOSTNAME=docunova.example.com
# Enable only the services you need
# For detailed parameters, see the Configuration Guide
```
For a complete example with all possible parameters, see the [Configuration Guide](ConfigurationGuide.md).
+76
View File
@@ -0,0 +1,76 @@
# Setting up Dropbox Integration
This guide explains how to set up the Dropbox integration for DocuNova.
## Required Configuration Parameters
| **Variable** | **Description** |
|-------------------------|--------------------------------------------------|
| `DROPBOX_APP_KEY` | Dropbox API app key |
| `DROPBOX_APP_SECRET` | Dropbox API app secret |
| `DROPBOX_REFRESH_TOKEN` | OAuth2 refresh token for Dropbox |
| `DROPBOX_FOLDER` | Default folder path for Dropbox uploads |
For a complete list of configuration options, see the [Configuration Guide](ConfigurationGuide.md).
## Step-by-Step Setup Instructions
### 1. Create a Dropbox App
1. Go to the [Dropbox Developer Apps Console](https://www.dropbox.com/developers/apps)
2. Click "Create app"
3. Select "Scoped access" for API
4. Choose "Full Dropbox" access (or "App folder" for more restricted access)
5. Give your app a name (e.g., "DocuNova")
6. Click "Create app"
### 2. Configure App Permissions
1. In your app's settings page, go to the "Permissions" tab
2. Enable the following permissions:
- `files.content.write` (to upload files)
- `files.content.read` (if you need to read file content)
3. Click "Submit" to save changes
### 3. Get App Key and Secret
1. On your app's settings page, find the "App key" and "App secret"
2. Set these as `DROPBOX_APP_KEY` and `DROPBOX_APP_SECRET` in your configuration
### 4. Generate a Refresh Token
1. Go to the "OAuth 2" tab in your app settings
2. Add a redirect URI: `http://localhost` (this is for the authorization flow)
3. Generate an authorization URL with these instructions:
```
https://www.dropbox.com/oauth2/authorize?client_id=YOUR_APP_KEY&response_type=code&token_access_type=offline
```
4. Replace `YOUR_APP_KEY` with your app key
5. Open this URL in your browser
6. Authorize the app when prompted
7. You'll be redirected to `localhost` with a code parameter in the URL
8. Copy this code parameter
### 5. Exchange the Code for a Refresh Token
1. Use this curl command to exchange the code for tokens:
```bash
curl -X POST https://api.dropboxapi.com/oauth2/token \
-d code=YOUR_AUTH_CODE \
-d grant_type=authorization_code \
-d client_id=YOUR_APP_KEY \
-d client_secret=YOUR_APP_SECRET \
-d redirect_uri=http://localhost
```
2. From the response, copy the `refresh_token` value
### 6. Configure DocuNova
1. Set `DROPBOX_APP_KEY`, `DROPBOX_APP_SECRET`, and `DROPBOX_REFRESH_TOKEN` with your values
2. Set `DROPBOX_FOLDER` to the path where files should be uploaded (e.g., `/Documents/Uploads`)
The system will use the refresh token to automatically generate short-lived access tokens when needed, so you shouldn't need to worry about token expiration.
+66
View File
@@ -0,0 +1,66 @@
# Setting up Google Drive Integration
This guide explains how to set up the Google Drive integration for DocuNova.
## Required Configuration Parameters
| **Variable** | **Description** |
|---------------------------------|-------------------------------------------------------|
| `GOOGLE_DRIVE_CREDENTIALS_JSON` | JSON string containing service account credentials |
| `GOOGLE_DRIVE_FOLDER_ID` | Google Drive folder ID for file uploads |
| `GOOGLE_DRIVE_DELEGATE_TO` | Email address to delegate permissions (optional) |
For a complete list of configuration options, see the [Configuration Guide](ConfigurationGuide.md).
## Step-by-Step Setup Instructions
### 1. Create a Google Cloud Project
1. Go to the [Google Cloud Console](https://console.cloud.google.com/)
2. Create a new project or select an existing one
3. Navigate to "APIs & Services" > "Library"
4. Search for and enable the "Google Drive API"
### 2. Create Service Account
1. Go to "APIs & Services" > "Credentials"
2. Click "Create Credentials" > "Service Account"
3. Fill in the service account details and click "Create"
4. Add appropriate roles (e.g., "Editor" for full access)
5. Click "Continue" and then "Done"
### 3. Generate Service Account Key
1. Find your service account in the list and click on it
2. Go to the "Keys" tab
3. Click "Add Key" > "Create New Key"
4. Choose JSON format and click "Create"
5. The key file will be downloaded automatically
### 4. Configure DocuNova
1. Open the downloaded JSON key file
2. Set the entire JSON content as the `GOOGLE_DRIVE_CREDENTIALS_JSON` environment variable
3. For security, ensure the JSON is properly escaped if your deployment method requires it
### Get Google Drive Folder ID
To find your Google Drive folder ID:
1. Navigate to the desired folder in Google Drive web interface
2. The URL will look like: `https://drive.google.com/drive/folders/1a2b3c4d5e6f7g8h9i0j`
3. The string after "folders/" is your folder ID (in this example: `1a2b3c4d5e6f7g8h9i0j`)
4. Set this value as `GOOGLE_DRIVE_FOLDER_ID` in your configuration
### Domain-Wide Delegation (Optional)
If you need the service account to access files on behalf of users in your Google Workspace:
1. In your [Google Workspace Admin Console](https://admin.google.com/), go to:
- Security > API Controls > Domain-wide Delegation
2. Click "Add new" and provide:
- Client ID: your service account's client ID (found in the JSON credentials file)
- OAuth Scopes: `https://www.googleapis.com/auth/drive`
3. Set `GOOGLE_DRIVE_DELEGATE_TO` to the email address of the user to impersonate
This setup is only relevant for Google Workspace environments where you need the service account to access user-specific files.
+164
View File
@@ -0,0 +1,164 @@
# Setting up OneDrive Integration
This guide explains how to set up the Microsoft OneDrive integration for DocuNova.
## Required Configuration Parameters
| **Variable** | **Description** |
|---------------------------------|-------------------------------------------------------|
| `ONEDRIVE_CLIENT_ID` | Azure AD application client ID |
| `ONEDRIVE_CLIENT_SECRET` | Azure AD application client secret |
| `ONEDRIVE_TENANT_ID` | Azure AD tenant ID: use "common" for personal accounts or your tenant ID for corporate accounts |
| `ONEDRIVE_REFRESH_TOKEN` | OAuth 2.0 refresh token (required for personal accounts) |
| `ONEDRIVE_FOLDER_PATH` | Folder path in OneDrive for storing documents |
For a complete list of configuration options, see the [Configuration Guide](ConfigurationGuide.md).
## Types of Microsoft Accounts
There are two main types of Microsoft accounts that can be used with OneDrive integration:
1. **Personal Microsoft Accounts** - These include accounts with @outlook.com, @hotmail.com, @live.com domains, or personal Microsoft accounts linked to other email addresses (like Gmail)
2. **Work/School Microsoft Accounts** - These are accounts managed by an organization through Microsoft 365 or Azure Active Directory
The setup process differs slightly based on which account type you're using.
## Common Setup Steps (All Account Types)
### 1. Register an application in Azure Active Directory
1. Go to the [Azure Portal](https://portal.azure.com/)
2. Navigate to "Azure Active Directory" > "App registrations"
3. Click "New registration"
4. Enter a name for your application (e.g., "DocuNova")
5. For "Supported account types", select the appropriate option:
- For personal accounts: "Accounts in any organizational directory and personal Microsoft accounts"
- For corporate accounts only: "Accounts in this organizational directory only"
6. For Redirect URI, select "Web" and enter a URL you can access (e.g., `http://localhost:8000/auth/callback`)
7. Click "Register"
### 2. Get Application (client) ID
1. After registration, note the "Application (client) ID" from the overview page
2. Set this value as `ONEDRIVE_CLIENT_ID`
### 3. Create a client secret
1. In your application page, go to "Certificates & secrets"
2. Under "Client secrets," click "New client secret"
3. Add a description and select an expiration period
4. Click "Add" and immediately copy the secret value (it will only be shown once)
5. Set this value as `ONEDRIVE_CLIENT_SECRET`
## For Personal Microsoft Accounts
If you're using a personal Microsoft account (@outlook.com, @hotmail.com, or personal accounts linked to other emails):
### 1. Set Tenant ID to "common"
- Set `ONEDRIVE_TENANT_ID=common` in your configuration
### 2. Configure API permissions
1. In your application page, go to "API permissions"
2. Click "Add a permission"
3. Select "Microsoft Graph" > "Delegated permissions"
4. Search for and add the following permissions:
- `Files.ReadWrite` (Allows the app to read and write files that the user has access to)
- `offline_access` (Needed for refresh tokens)
5. Click "Add permissions"
### 3. Generate a Refresh Token
1. Use the following URL (replace CLIENT_ID and REDIRECT_URI with your values):
```
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=YOUR_CLIENT_ID&response_type=code&redirect_uri=YOUR_REDIRECT_URI&response_mode=query&scope=offline_access%20Files.ReadWrite
```
2. Open this URL in your browser
3. Sign in with your personal Microsoft account
4. After authentication, you'll be redirected to your redirect URI with a code parameter in the URL
5. Copy the code value from the URL (everything after "code=")
### 4. Exchange Code for Refresh Token
1. Use the following command to exchange the code for tokens:
```bash
curl -X POST https://login.microsoftonline.com/common/oauth2/v2.0/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "client_id=YOUR_CLIENT_ID&scope=offline_access Files.ReadWrite&code=YOUR_AUTH_CODE&redirect_uri=YOUR_REDIRECT_URI&grant_type=authorization_code&client_secret=YOUR_CLIENT_SECRET"
```
2. From the response JSON, copy the `refresh_token` value
3. Set this as `ONEDRIVE_REFRESH_TOKEN` in your configuration
## For Corporate Microsoft Accounts
If you're using a work/school account provided by your organization:
### 1. Get your Tenant ID
1. In the Azure Portal, find your "Tenant ID" (also called "Directory ID")
2. It will be in the Azure Active Directory overview or properties section
3. Set this value as `ONEDRIVE_TENANT_ID` in your configuration
### 2. Configuration based on use case
**Option A: Access your own OneDrive (Interactive Login)**
This option requires a refresh token just like personal accounts:
1. Follow the same steps as for personal accounts, but use your work email to sign in
2. Make sure to set `ONEDRIVE_TENANT_ID` to your organization's tenant ID instead of "common"
3. Set the refresh token you receive as `ONEDRIVE_REFRESH_TOKEN`
**Option B: Access OneDrive as a system service (App-only access)**
This option is for service accounts or automated systems with no user interaction:
1. In API permissions, add "Application permissions" instead of "Delegated permissions"
2. Add `Files.ReadWrite.All` permission under "Application permissions"
3. Click "Grant admin consent" (requires admin privileges)
4. In this case, `ONEDRIVE_REFRESH_TOKEN` is not needed as the app will use client credentials flow
5. Note: This approach can only access specific shared folders or sites, not personal OneDrives
## Troubleshooting OAuth Login Issues
If you encounter errors during authentication:
1. **Check account permissions**:
- Ensure your Microsoft account has the necessary permissions to grant access
- For corporate accounts, check if your admin has restricted third-party app access
2. **Permission errors**:
- Verify the app registration has the correct API permissions
- For corporate accounts, ensure an admin has consented to the permissions
3. **Refresh token expired**:
- If uploads stop working, you may need to generate a new refresh token
- Repeat the process to get a new authorization code and refresh token
## Configuration Examples
**Personal Microsoft Account:**
```dotenv
ONEDRIVE_CLIENT_ID=12345678-1234-1234-1234-123456789012
ONEDRIVE_CLIENT_SECRET=your_client_secret
ONEDRIVE_TENANT_ID=common
ONEDRIVE_REFRESH_TOKEN=your_refresh_token
ONEDRIVE_FOLDER_PATH=Documents/Uploads
```
**Corporate Account with Interactive Login:**
```dotenv
ONEDRIVE_CLIENT_ID=12345678-1234-1234-1234-123456789012
ONEDRIVE_CLIENT_SECRET=your_client_secret
ONEDRIVE_TENANT_ID=87654321-4321-4321-4321-210987654321
ONEDRIVE_REFRESH_TOKEN=your_refresh_token
ONEDRIVE_FOLDER_PATH=Documents/Uploads
```
**Corporate Account with App-Only Access:**
```dotenv
ONEDRIVE_CLIENT_ID=12345678-1234-1234-1234-123456789012
ONEDRIVE_CLIENT_SECRET=your_client_secret
ONEDRIVE_TENANT_ID=87654321-4321-4321-4321-210987654321
# No refresh token needed for app-only access
ONEDRIVE_FOLDER_PATH=Documents/Uploads
```
View File