Skip to content

Commit 82aed68

Browse files
committed
feat: update authentication method to use x-api-key header
- Replace Bearer token authentication with x-api-key header across all commands - Update token verification endpoints from auth.verifyToken to user.get - Remove unnecessary console.log debug statements - Bump version to v0.2.7
1 parent 21dd3f0 commit 82aed68

30 files changed

+40
-83
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@dokploy/cli",
33
"description": "A CLI to manage dokploy server remotely",
4-
"version": "v0.2.6",
4+
"version": "v0.2.7",
55
"author": "Mauricio Siu",
66
"licenses": [{
77
"type": "MIT",

src/commands/app/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default class AppCreate extends Command {
132132
},
133133
{
134134
headers: {
135-
Authorization: `Bearer ${auth.token}`,
135+
"x-api-key": auth.token,
136136
"Content-Type": "application/json",
137137
},
138138
},

src/commands/app/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default class AppDelete extends Command {
107107
},
108108
{
109109
headers: {
110-
Authorization: `Bearer ${auth.token}`,
110+
"x-api-key": auth.token,
111111
"Content-Type": "application/json",
112112
},
113113
},

src/commands/app/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default class AppDeploy extends Command {
107107
},
108108
{
109109
headers: {
110-
Authorization: `Bearer ${auth.token}`,
110+
"x-api-key": auth.token,
111111
"Content-Type": "application/json",
112112
},
113113
},

src/commands/app/stop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export default class AppStop extends Command {
102102
},
103103
{
104104
headers: {
105-
Authorization: `Bearer ${auth.token}`,
105+
"x-api-key": auth.token,
106106
"Content-Type": "application/json",
107107
},
108108
},

src/commands/authenticate.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,11 @@ export default class Authenticate extends Command {
8383
try {
8484
console.log(`\n${chalk.blue("Validating server...")}`);
8585

86-
await axios.post(
87-
`${url}/api/trpc/auth.verifyToken`,
88-
{},
86+
await axios.get(
87+
`${url}/api/trpc/user.get`,
8988
{
9089
headers: {
91-
Authorization: `Bearer ${token}`,
90+
"x-api-key": token,
9291
"Content-Type": "application/json",
9392
},
9493
},
@@ -104,3 +103,7 @@ export default class Authenticate extends Command {
104103
}
105104
}
106105
}
106+
// curl -X 'GET' \
107+
// 'https://panel.jinza.app/api/project.all' \
108+
// -H 'accept: application/json' \
109+
// -H 'x-api-key: EawCkTREMhxoAqvCxJFZurgCGoDZPjYHHrLgUPghRjJTpXLaahFdhCOGfABZXTRP'

src/commands/database/mariadb/create.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -182,17 +182,6 @@ export default class DatabaseMariadbCreate extends Command {
182182
}
183183

184184
try {
185-
console.log(JSON.stringify({
186-
name,
187-
databaseName,
188-
description,
189-
databaseRootPassword,
190-
databasePassword,
191-
databaseUser,
192-
dockerImage,
193-
appName,
194-
projectId,
195-
}, null, 2));
196185
const response = await axios.post(
197186
`${auth.url}/api/trpc/mariadb.create`,
198187
{
@@ -210,7 +199,7 @@ export default class DatabaseMariadbCreate extends Command {
210199
},
211200
{
212201
headers: {
213-
Authorization: `Bearer ${auth.token}`,
202+
"x-api-key": auth.token,
214203
"Content-Type": "application/json",
215204
},
216205
},

src/commands/database/mariadb/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export default class DatabaseMariadbDelete extends Command {
102102
},
103103
{
104104
headers: {
105-
Authorization: `Bearer ${auth.token}`,
105+
"x-api-key": auth.token,
106106
"Content-Type": "application/json",
107107
},
108108
},

src/commands/database/mariadb/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class DatabaseMariadbDeploy extends Command {
103103
},
104104
{
105105
headers: {
106-
Authorization: `Bearer ${auth.token}`,
106+
"x-api-key": auth.token,
107107
"Content-Type": "application/json",
108108
},
109109
},

src/commands/database/mariadb/stop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class DatabaseMariadbStop extends Command {
103103
},
104104
{
105105
headers: {
106-
Authorization: `Bearer ${auth.token}`,
106+
"x-api-key": auth.token,
107107
"Content-Type": "application/json",
108108
},
109109
},

src/commands/database/mongo/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export default class DatabaseMongoCreate extends Command {
186186
},
187187
{
188188
headers: {
189-
Authorization: `Bearer ${auth.token}`,
189+
"x-api-key": auth.token,
190190
"Content-Type": "application/json",
191191
},
192192
},

src/commands/database/mongo/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default class DatabaseMongoDelete extends Command {
106106
},
107107
{
108108
headers: {
109-
Authorization: `Bearer ${auth.token}`,
109+
"x-api-key": auth.token,
110110
"Content-Type": "application/json",
111111
},
112112
},

src/commands/database/mongo/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class DatabaseMongoDeploy extends Command {
103103
},
104104
{
105105
headers: {
106-
Authorization: `Bearer ${auth.token}`,
106+
"x-api-key": auth.token,
107107
"Content-Type": "application/json",
108108
},
109109
},

src/commands/database/mongo/stop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class DatabaseMongoStop extends Command {
103103
},
104104
{
105105
headers: {
106-
Authorization: `Bearer ${auth.token}`,
106+
"x-api-key": auth.token,
107107
"Content-Type": "application/json",
108108
},
109109
},

src/commands/database/mysql/create.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,6 @@ export default class DatabaseMysqlCreate extends Command {
183183
}
184184

185185
try {
186-
console.log(JSON.stringify({
187-
name,
188-
databaseName,
189-
description,
190-
databaseRootPassword,
191-
databasePassword,
192-
databaseUser,
193-
dockerImage,
194-
appName,
195-
projectId,
196-
}, null, 2));
197186

198187
const response = await axios.post(
199188
`${auth.url}/api/trpc/mysql.create`,
@@ -212,7 +201,7 @@ export default class DatabaseMysqlCreate extends Command {
212201
},
213202
{
214203
headers: {
215-
Authorization: `Bearer ${auth.token}`,
204+
"x-api-key": auth.token,
216205
"Content-Type": "application/json",
217206
},
218207
},

src/commands/database/mysql/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default class DatabaseMysqlDelete extends Command {
106106
},
107107
{
108108
headers: {
109-
Authorization: `Bearer ${auth.token}`,
109+
"x-api-key": auth.token,
110110
"Content-Type": "application/json",
111111
},
112112
},

src/commands/database/mysql/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default class DatabaseMysqlDeploy extends Command {
8585
},
8686
{
8787
headers: {
88-
Authorization: `Bearer ${auth.token}`,
88+
"x-api-key": auth.token,
8989
"Content-Type": "application/json",
9090
},
9191
},

src/commands/database/mysql/stop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default class DatabaseMysqlStop extends Command {
8585
},
8686
{
8787
headers: {
88-
Authorization: `Bearer ${auth.token}`,
88+
"x-api-key": auth.token,
8989
"Content-Type": "application/json",
9090
},
9191
},

src/commands/database/postgres/create.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,6 @@ export default class DatabasePostgresCreate extends Command {
169169
}
170170

171171
try {
172-
console.log(JSON.stringify({
173-
name,
174-
databaseName,
175-
description,
176-
databasePassword,
177-
databaseUser,
178-
dockerImage,
179-
appName,
180-
projectId,
181-
}, null, 2));
182172

183173
const response = await axios.post(
184174
`${auth.url}/api/trpc/postgres.create`,
@@ -196,7 +186,7 @@ export default class DatabasePostgresCreate extends Command {
196186
},
197187
{
198188
headers: {
199-
Authorization: `Bearer ${auth.token}`,
189+
"x-api-key": auth.token,
200190
"Content-Type": "application/json",
201191
},
202192
},

src/commands/database/postgres/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default class DatabasePostgresDelete extends Command {
106106
},
107107
{
108108
headers: {
109-
Authorization: `Bearer ${auth.token}`,
109+
"x-api-key": auth.token,
110110
"Content-Type": "application/json",
111111
},
112112
},

src/commands/database/postgres/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class DatabasePostgresDeploy extends Command {
103103
},
104104
{
105105
headers: {
106-
Authorization: `Bearer ${auth.token}`,
106+
"x-api-key": auth.token,
107107
"Content-Type": "application/json",
108108
},
109109
},

src/commands/database/postgres/stop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class DatabasePostgresStop extends Command {
103103
},
104104
{
105105
headers: {
106-
Authorization: `Bearer ${auth.token}`,
106+
"x-api-key": auth.token,
107107
"Content-Type": "application/json",
108108
},
109109
},

src/commands/database/redis/create.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,6 @@ export default class DatabaseRedisCreate extends Command {
145145
}
146146

147147
try {
148-
console.log(JSON.stringify({
149-
name,
150-
description,
151-
databasePassword,
152-
dockerImage,
153-
appName,
154-
projectId,
155-
}, null, 2));
156-
157148
const response = await axios.post(
158149
`${auth.url}/api/trpc/redis.create`,
159150
{
@@ -168,7 +159,7 @@ export default class DatabaseRedisCreate extends Command {
168159
},
169160
{
170161
headers: {
171-
Authorization: `Bearer ${auth.token}`,
162+
"x-api-key": auth.token,
172163
"Content-Type": "application/json",
173164
},
174165
},

src/commands/database/redis/delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default class DatabaseRedisDelete extends Command {
106106
},
107107
{
108108
headers: {
109-
Authorization: `Bearer ${auth.token}`,
109+
"x-api-key": auth.token,
110110
"Content-Type": "application/json",
111111
},
112112
},

src/commands/database/redis/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class DatabaseRedisDeploy extends Command {
103103
},
104104
{
105105
headers: {
106-
Authorization: `Bearer ${auth.token}`,
106+
"x-api-key": auth.token,
107107
"Content-Type": "application/json",
108108
},
109109
},

src/commands/database/redis/stop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default class DatabaseRedisStop extends Command {
103103
},
104104
{
105105
headers: {
106-
Authorization: `Bearer ${auth.token}`,
106+
"x-api-key": auth.token,
107107
"Content-Type": "application/json",
108108
},
109109
},

src/commands/env/push.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export default class EnvPush extends Command {
9191
}, {
9292

9393
headers: {
94-
Authorization: `Bearer ${auth.token}`,
94+
"x-api-key": auth.token,
9595
"Content-Type": "application/json",
9696
},
9797
}
@@ -114,7 +114,7 @@ export default class EnvPush extends Command {
114114
}
115115
}, {
116116
headers: {
117-
Authorization: `Bearer ${auth.token}`,
117+
"x-api-key": auth.token,
118118
"Content-Type": "application/json",
119119
},
120120
}

src/commands/project/create.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ export default class ProjectCreate extends Command {
7575
}
7676

7777
try {
78-
console.log(JSON.stringify({
79-
name,
80-
description,
81-
}, null, 2));
8278

8379
const response = await axios.post(
8480
`${auth.url}/api/trpc/project.create`,
@@ -90,7 +86,7 @@ export default class ProjectCreate extends Command {
9086
},
9187
{
9288
headers: {
93-
Authorization: `Bearer ${auth.token}`,
89+
"x-api-key": auth.token,
9490
"Content-Type": "application/json",
9591
},
9692
},

src/commands/verify.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ export default class Verify extends Command {
5858
try {
5959
console.log(chalk.blue("Validating token with server..."));
6060

61-
const response = await axios.post(
62-
`${url}/api/trpc/auth.verifyToken`,
63-
{},
61+
const response = await axios.get(
62+
`${url}/api/trpc/user.get`,
6463
{
6564
headers: {
66-
Authorization: `Bearer ${token}`,
65+
"x-api-key": token,
6766
"Content-Type": "application/json",
6867
},
6968
},

src/utils/shared.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const getProjects = async (
1919
try {
2020
const response = await axios.get(`${auth.url}/api/trpc/project.all`, {
2121
headers: {
22-
Authorization: `Bearer ${auth.token}`,
22+
"x-api-key": auth.token,
2323
"Content-Type": "application/json",
2424
},
2525
});
@@ -53,7 +53,7 @@ export const getProject = async (
5353
}
5454
const response = await axios.get(`${auth.url}/api/trpc/project.one`, {
5555
headers: {
56-
Authorization: `Bearer ${auth.token}`,
56+
"x-api-key": auth.token,
5757
"Content-Type": "application/json",
5858
},
5959
params: {

0 commit comments

Comments
 (0)