mirror of
https://github.com/Dokploy/cli.git
synced 2026-06-15 20:25:22 +02:00
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
This commit is contained in:
@@ -132,7 +132,7 @@ export default class AppCreate extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -107,7 +107,7 @@ export default class AppDelete extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -107,7 +107,7 @@ export default class AppDeploy extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -102,7 +102,7 @@ export default class AppStop extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -83,12 +83,11 @@ export default class Authenticate extends Command {
|
||||
try {
|
||||
console.log(`\n${chalk.blue("Validating server...")}`);
|
||||
|
||||
await axios.post(
|
||||
`${url}/api/trpc/auth.verifyToken`,
|
||||
{},
|
||||
await axios.get(
|
||||
`${url}/api/trpc/user.get`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
"x-api-key": token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
@@ -104,3 +103,7 @@ export default class Authenticate extends Command {
|
||||
}
|
||||
}
|
||||
}
|
||||
// curl -X 'GET' \
|
||||
// 'https://panel.jinza.app/api/project.all' \
|
||||
// -H 'accept: application/json' \
|
||||
// -H 'x-api-key: EawCkTREMhxoAqvCxJFZurgCGoDZPjYHHrLgUPghRjJTpXLaahFdhCOGfABZXTRP'
|
||||
@@ -182,17 +182,6 @@ export default class DatabaseMariadbCreate extends Command {
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(JSON.stringify({
|
||||
name,
|
||||
databaseName,
|
||||
description,
|
||||
databaseRootPassword,
|
||||
databasePassword,
|
||||
databaseUser,
|
||||
dockerImage,
|
||||
appName,
|
||||
projectId,
|
||||
}, null, 2));
|
||||
const response = await axios.post(
|
||||
`${auth.url}/api/trpc/mariadb.create`,
|
||||
{
|
||||
@@ -210,7 +199,7 @@ export default class DatabaseMariadbCreate extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -102,7 +102,7 @@ export default class DatabaseMariadbDelete extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -103,7 +103,7 @@ export default class DatabaseMariadbDeploy extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -103,7 +103,7 @@ export default class DatabaseMariadbStop extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -186,7 +186,7 @@ export default class DatabaseMongoCreate extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -106,7 +106,7 @@ export default class DatabaseMongoDelete extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -103,7 +103,7 @@ export default class DatabaseMongoDeploy extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -103,7 +103,7 @@ export default class DatabaseMongoStop extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -183,17 +183,6 @@ export default class DatabaseMysqlCreate extends Command {
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(JSON.stringify({
|
||||
name,
|
||||
databaseName,
|
||||
description,
|
||||
databaseRootPassword,
|
||||
databasePassword,
|
||||
databaseUser,
|
||||
dockerImage,
|
||||
appName,
|
||||
projectId,
|
||||
}, null, 2));
|
||||
|
||||
const response = await axios.post(
|
||||
`${auth.url}/api/trpc/mysql.create`,
|
||||
@@ -212,7 +201,7 @@ export default class DatabaseMysqlCreate extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -106,7 +106,7 @@ export default class DatabaseMysqlDelete extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -85,7 +85,7 @@ export default class DatabaseMysqlDeploy extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -85,7 +85,7 @@ export default class DatabaseMysqlStop extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -169,16 +169,6 @@ export default class DatabasePostgresCreate extends Command {
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(JSON.stringify({
|
||||
name,
|
||||
databaseName,
|
||||
description,
|
||||
databasePassword,
|
||||
databaseUser,
|
||||
dockerImage,
|
||||
appName,
|
||||
projectId,
|
||||
}, null, 2));
|
||||
|
||||
const response = await axios.post(
|
||||
`${auth.url}/api/trpc/postgres.create`,
|
||||
@@ -196,7 +186,7 @@ export default class DatabasePostgresCreate extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -106,7 +106,7 @@ export default class DatabasePostgresDelete extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -103,7 +103,7 @@ export default class DatabasePostgresDeploy extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -103,7 +103,7 @@ export default class DatabasePostgresStop extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -145,15 +145,6 @@ export default class DatabaseRedisCreate extends Command {
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(JSON.stringify({
|
||||
name,
|
||||
description,
|
||||
databasePassword,
|
||||
dockerImage,
|
||||
appName,
|
||||
projectId,
|
||||
}, null, 2));
|
||||
|
||||
const response = await axios.post(
|
||||
`${auth.url}/api/trpc/redis.create`,
|
||||
{
|
||||
@@ -168,7 +159,7 @@ export default class DatabaseRedisCreate extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -106,7 +106,7 @@ export default class DatabaseRedisDelete extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -103,7 +103,7 @@ export default class DatabaseRedisDeploy extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -103,7 +103,7 @@ export default class DatabaseRedisStop extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
4
src/commands/env/push.ts
vendored
4
src/commands/env/push.ts
vendored
@@ -91,7 +91,7 @@ export default class EnvPush extends Command {
|
||||
}, {
|
||||
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
@@ -114,7 +114,7 @@ export default class EnvPush extends Command {
|
||||
}
|
||||
}, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -75,10 +75,6 @@ export default class ProjectCreate extends Command {
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(JSON.stringify({
|
||||
name,
|
||||
description,
|
||||
}, null, 2));
|
||||
|
||||
const response = await axios.post(
|
||||
`${auth.url}/api/trpc/project.create`,
|
||||
@@ -90,7 +86,7 @@ export default class ProjectCreate extends Command {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -58,12 +58,11 @@ export default class Verify extends Command {
|
||||
try {
|
||||
console.log(chalk.blue("Validating token with server..."));
|
||||
|
||||
const response = await axios.post(
|
||||
`${url}/api/trpc/auth.verifyToken`,
|
||||
{},
|
||||
const response = await axios.get(
|
||||
`${url}/api/trpc/user.get`,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
"x-api-key": token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
},
|
||||
|
||||
@@ -19,7 +19,7 @@ export const getProjects = async (
|
||||
try {
|
||||
const response = await axios.get(`${auth.url}/api/trpc/project.all`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
@@ -53,7 +53,7 @@ export const getProject = async (
|
||||
}
|
||||
const response = await axios.get(`${auth.url}/api/trpc/project.one`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${auth.token}`,
|
||||
"x-api-key": auth.token,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
params: {
|
||||
|
||||
Reference in New Issue
Block a user