Skip to content

Commit fd3d3be

Browse files
committed
feat: implement authentication with TOTP support and update configuration
1 parent 9168112 commit fd3d3be

File tree

7 files changed

+549
-37
lines changed

7 files changed

+549
-37
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ console.log('Backup UI at http://localhost:3000/backup')
4545

4646
## Configuration
4747

48-
| Option | Type | Required | Description |
49-
| ----------------- | -------- | -------- | ------------------------------------------------------------- |
50-
| `bucket` | string || R2/S3 bucket name |
51-
| `accessKeyId` | string || R2/S3 Access Key ID |
52-
| `secretAccessKey` | string || R2/S3 Secret Access Key |
53-
| `endpoint` | string || R2/S3 Endpoint URL |
54-
| `sourceDir` | string || Local directory to backup |
55-
| `prefix` | string || Prefix for S3 keys (e.g., 'backups/') |
56-
| `extensions` | string[] || File extensions to include |
57-
| `cronSchedule` | string || Cron expression for scheduled backups |
58-
| `cronEnabled` | boolean || Enable/disable scheduled backups |
59-
| `configPath` | string || Path to save runtime config (default: './backup-config.json') |
48+
| Option | Type | Required | Description |
49+
| ----------------- | -------- | -------- | ------------------------------------------------------ |
50+
| `bucket` | string || R2/S3 bucket name |
51+
| `accessKeyId` | string || R2/S3 Access Key ID |
52+
| `secretAccessKey` | string || R2/S3 Secret Access Key |
53+
| `endpoint` | string || R2/S3 Endpoint URL |
54+
| `sourceDir` | string || Local directory to backup |
55+
| `prefix` | string || Prefix for S3 keys (e.g., 'backups/') |
56+
| `extensions` | string[] || File extensions to include |
57+
| `cronSchedule` | string || Cron expression for scheduled backups |
58+
| `cronEnabled` | boolean || Enable/disable scheduled backups |
59+
| `configPath` | string || Path to save runtime config (default: './config.json') |
6060

6161
## API Endpoints
6262

bun.lock

Lines changed: 69 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"bucket": "demo-bucket",
3+
"accessKeyId": "",
4+
"secretAccessKey": "",
5+
"endpoint": "https://example.r2.cloudflarestorage.com",
6+
"sourceDir": "./data",
7+
"prefix": "backups/",
8+
"extensions": [
9+
".json"
10+
],
11+
"cronSchedule": "0 * * * *",
12+
"cronEnabled": false,
13+
"auth": {
14+
"username": "admin",
15+
"password": "admin123",
16+
"totpSecret": "HB5AKIASH4MAG3BM"
17+
}
18+
}

demo/config.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"bucket": "demo-bucket",
3+
"accessKeyId": "135b46a7ebe62a798198865c64eee178",
4+
"secretAccessKey": "3ae633898d81a7aeb0ce1179a92095ab836bb3a60f601cdd43d4e2b6b6152646",
5+
"endpoint": "https://fb81cb0efe496349aa882e65d6704c6f.r2.cloudflarestorage.com",
6+
"sourceDir": "./data",
7+
"prefix": "backups/",
8+
"extensions": [
9+
".json"
10+
],
11+
"cronSchedule": "0 * * * *",
12+
"cronEnabled": false,
13+
"auth": {
14+
"username": "admin",
15+
"password": "admin123",
16+
"totpSecret": "DQMRAQL6ANCSI2BJ"
17+
}
18+
}

demo/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const app = new Elysia()
3333
auth: {
3434
username: process.env.BACKUP_USERNAME,
3535
password: process.env.BACKUP_PASSWORD,
36+
totpSecret: process.env.BACKUP_TOTP_SECRET, // Optional: base32 secret for 2FA
3637
},
3738
})
3839
)

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
"@elysiajs/html": ">=1.0.0"
4747
},
4848
"dependencies": {
49-
"cron": "^3.5.0"
49+
"cron": "^3.5.0",
50+
"otplib": "^12.0.1",
51+
"qrcode": "^1.5.4"
5052
},
5153
"devDependencies": {
5254
"@elysiajs/html": "^1.4.0",

0 commit comments

Comments
 (0)