@minecraft-docker/mcctl-api 1.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +142 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +83 -0
- package/dist/app.js.map +1 -0
- package/dist/config/index.d.ts +32 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +124 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/rcon.d.ts +35 -0
- package/dist/lib/rcon.d.ts.map +1 -0
- package/dist/lib/rcon.js +90 -0
- package/dist/lib/rcon.js.map +1 -0
- package/dist/plugins/auth.d.ts +32 -0
- package/dist/plugins/auth.d.ts.map +1 -0
- package/dist/plugins/auth.js +194 -0
- package/dist/plugins/auth.js.map +1 -0
- package/dist/plugins/swagger.d.ts +170 -0
- package/dist/plugins/swagger.d.ts.map +1 -0
- package/dist/plugins/swagger.js +211 -0
- package/dist/plugins/swagger.js.map +1 -0
- package/dist/routes/auth.d.ts +12 -0
- package/dist/routes/auth.d.ts.map +1 -0
- package/dist/routes/auth.js +144 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/backup.d.ts +9 -0
- package/dist/routes/backup.d.ts.map +1 -0
- package/dist/routes/backup.js +271 -0
- package/dist/routes/backup.js.map +1 -0
- package/dist/routes/console.d.ts +6 -0
- package/dist/routes/console.d.ts.map +1 -0
- package/dist/routes/console.js +90 -0
- package/dist/routes/console.js.map +1 -0
- package/dist/routes/players.d.ts +9 -0
- package/dist/routes/players.d.ts.map +1 -0
- package/dist/routes/players.js +353 -0
- package/dist/routes/players.js.map +1 -0
- package/dist/routes/router.d.ts +10 -0
- package/dist/routes/router.d.ts.map +1 -0
- package/dist/routes/router.js +55 -0
- package/dist/routes/router.js.map +1 -0
- package/dist/routes/servers/actions.d.ts +6 -0
- package/dist/routes/servers/actions.d.ts.map +1 -0
- package/dist/routes/servers/actions.js +65 -0
- package/dist/routes/servers/actions.js.map +1 -0
- package/dist/routes/servers.d.ts +10 -0
- package/dist/routes/servers.d.ts.map +1 -0
- package/dist/routes/servers.js +403 -0
- package/dist/routes/servers.js.map +1 -0
- package/dist/routes/worlds.d.ts +10 -0
- package/dist/routes/worlds.d.ts.map +1 -0
- package/dist/routes/worlds.js +341 -0
- package/dist/routes/worlds.js.map +1 -0
- package/dist/schemas/backup.d.ts +47 -0
- package/dist/schemas/backup.d.ts.map +1 -0
- package/dist/schemas/backup.js +43 -0
- package/dist/schemas/backup.js.map +1 -0
- package/dist/schemas/player.d.ts +46 -0
- package/dist/schemas/player.d.ts.map +1 -0
- package/dist/schemas/player.js +46 -0
- package/dist/schemas/player.js.map +1 -0
- package/dist/schemas/router.d.ts +42 -0
- package/dist/schemas/router.d.ts.map +1 -0
- package/dist/schemas/router.js +26 -0
- package/dist/schemas/router.js.map +1 -0
- package/dist/schemas/server.d.ts +139 -0
- package/dist/schemas/server.d.ts.map +1 -0
- package/dist/schemas/server.js +124 -0
- package/dist/schemas/server.js.map +1 -0
- package/dist/schemas/world.d.ts +142 -0
- package/dist/schemas/world.d.ts.map +1 -0
- package/dist/schemas/world.js +124 -0
- package/dist/schemas/world.js.map +1 -0
- package/dist/utils/docker-compose.d.ts +23 -0
- package/dist/utils/docker-compose.d.ts.map +1 -0
- package/dist/utils/docker-compose.js +100 -0
- package/dist/utils/docker-compose.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import fp from 'fastify-plugin';
|
|
2
|
+
import bcrypt from 'bcrypt';
|
|
3
|
+
import ipRangeCheck from 'ip-range-check';
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Plugin Implementation
|
|
6
|
+
// ============================================================
|
|
7
|
+
const authPlugin = async (fastify, opts) => {
|
|
8
|
+
const { config } = opts;
|
|
9
|
+
// Validate config based on mode
|
|
10
|
+
validateAuthConfig(config);
|
|
11
|
+
// Decorate fastify with auth utilities
|
|
12
|
+
fastify.decorate('authConfig', config);
|
|
13
|
+
fastify.decorate('isAuthenticated', false);
|
|
14
|
+
// Default excluded paths
|
|
15
|
+
const excludedPaths = new Set(config.excludePaths ?? ['/health', '/health/']);
|
|
16
|
+
// Skip authentication if disabled
|
|
17
|
+
if (config.mode === 'disabled') {
|
|
18
|
+
fastify.log.warn('Authentication is DISABLED. This should only be used in development!');
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// Add preHandler hook for authentication
|
|
22
|
+
fastify.addHook('preHandler', async (request, reply) => {
|
|
23
|
+
// Skip authentication for excluded paths
|
|
24
|
+
if (excludedPaths.has(request.url)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
// Normalize URL for path matching (remove query string)
|
|
28
|
+
const urlPath = request.url.split('?')[0] ?? request.url;
|
|
29
|
+
if (excludedPaths.has(urlPath)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
await authenticate(request, reply, config, fastify);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error instanceof AuthError) {
|
|
37
|
+
reply.code(error.statusCode).send({
|
|
38
|
+
error: error.name,
|
|
39
|
+
message: error.message,
|
|
40
|
+
});
|
|
41
|
+
return reply;
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
// ============================================================
|
|
48
|
+
// Authentication Logic
|
|
49
|
+
// ============================================================
|
|
50
|
+
class AuthError extends Error {
|
|
51
|
+
statusCode;
|
|
52
|
+
constructor(message, statusCode = 401) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = 'AuthenticationError';
|
|
55
|
+
this.statusCode = statusCode;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function authenticate(request, _reply, config, fastify) {
|
|
59
|
+
switch (config.mode) {
|
|
60
|
+
case 'api-key':
|
|
61
|
+
await authenticateApiKey(request, config, fastify);
|
|
62
|
+
break;
|
|
63
|
+
case 'ip-whitelist':
|
|
64
|
+
await authenticateIpWhitelist(request, config, fastify);
|
|
65
|
+
break;
|
|
66
|
+
case 'basic':
|
|
67
|
+
await authenticateBasic(request, config, fastify);
|
|
68
|
+
break;
|
|
69
|
+
case 'combined':
|
|
70
|
+
await authenticateCombined(request, config, fastify);
|
|
71
|
+
break;
|
|
72
|
+
default:
|
|
73
|
+
throw new AuthError('Invalid authentication mode', 500);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function authenticateApiKey(request, config, fastify) {
|
|
77
|
+
const apiKey = request.headers['x-api-key'];
|
|
78
|
+
if (!apiKey) {
|
|
79
|
+
throw new AuthError('Missing X-API-Key header');
|
|
80
|
+
}
|
|
81
|
+
if (apiKey !== config.apiKey) {
|
|
82
|
+
fastify.log.warn({ ip: getClientIp(request) }, 'Invalid API key attempt');
|
|
83
|
+
throw new AuthError('Invalid API key');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function authenticateIpWhitelist(request, config, fastify) {
|
|
87
|
+
const clientIp = getClientIp(request);
|
|
88
|
+
const whitelist = config.ipWhitelist ?? [];
|
|
89
|
+
if (whitelist.length === 0) {
|
|
90
|
+
throw new AuthError('IP whitelist is empty', 500);
|
|
91
|
+
}
|
|
92
|
+
const isAllowed = ipRangeCheck(clientIp, whitelist);
|
|
93
|
+
if (!isAllowed) {
|
|
94
|
+
fastify.log.warn({ ip: clientIp }, 'IP not in whitelist');
|
|
95
|
+
throw new AuthError('IP address not allowed', 403);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function authenticateBasic(request, config, fastify) {
|
|
99
|
+
const authHeader = request.headers.authorization;
|
|
100
|
+
if (!authHeader || !authHeader.startsWith('Basic ')) {
|
|
101
|
+
throw new AuthError('Missing or invalid Authorization header');
|
|
102
|
+
}
|
|
103
|
+
const base64Credentials = authHeader.substring(6);
|
|
104
|
+
const credentials = Buffer.from(base64Credentials, 'base64').toString('utf-8');
|
|
105
|
+
const [username, password] = credentials.split(':');
|
|
106
|
+
if (!username || !password) {
|
|
107
|
+
throw new AuthError('Invalid credentials format');
|
|
108
|
+
}
|
|
109
|
+
const users = config.users ?? [];
|
|
110
|
+
const user = users.find((u) => u.username === username);
|
|
111
|
+
if (!user) {
|
|
112
|
+
fastify.log.warn({ username, ip: getClientIp(request) }, 'Unknown user attempt');
|
|
113
|
+
throw new AuthError('Invalid credentials');
|
|
114
|
+
}
|
|
115
|
+
const isValid = await bcrypt.compare(password, user.passwordHash);
|
|
116
|
+
if (!isValid) {
|
|
117
|
+
fastify.log.warn({ username, ip: getClientIp(request) }, 'Invalid password attempt');
|
|
118
|
+
throw new AuthError('Invalid credentials');
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async function authenticateCombined(request, config, fastify) {
|
|
122
|
+
// Both API key AND IP whitelist must pass
|
|
123
|
+
await authenticateApiKey(request, config, fastify);
|
|
124
|
+
await authenticateIpWhitelist(request, config, fastify);
|
|
125
|
+
}
|
|
126
|
+
// ============================================================
|
|
127
|
+
// Utilities
|
|
128
|
+
// ============================================================
|
|
129
|
+
function getClientIp(request) {
|
|
130
|
+
// Check for forwarded headers (reverse proxy scenarios)
|
|
131
|
+
const xForwardedFor = request.headers['x-forwarded-for'];
|
|
132
|
+
if (xForwardedFor) {
|
|
133
|
+
const ips = Array.isArray(xForwardedFor) ? xForwardedFor[0] : xForwardedFor.split(',')[0];
|
|
134
|
+
if (ips) {
|
|
135
|
+
return ips.trim();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const xRealIp = request.headers['x-real-ip'];
|
|
139
|
+
if (xRealIp) {
|
|
140
|
+
const ip = Array.isArray(xRealIp) ? xRealIp[0] : xRealIp;
|
|
141
|
+
if (ip) {
|
|
142
|
+
return ip;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Fallback to socket IP
|
|
146
|
+
return request.ip;
|
|
147
|
+
}
|
|
148
|
+
function validateAuthConfig(config) {
|
|
149
|
+
switch (config.mode) {
|
|
150
|
+
case 'disabled':
|
|
151
|
+
// No validation needed
|
|
152
|
+
break;
|
|
153
|
+
case 'api-key':
|
|
154
|
+
if (!config.apiKey) {
|
|
155
|
+
throw new Error('API key is required for api-key authentication mode');
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case 'ip-whitelist':
|
|
159
|
+
if (!config.ipWhitelist || config.ipWhitelist.length === 0) {
|
|
160
|
+
throw new Error('IP whitelist is required for ip-whitelist authentication mode');
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case 'basic':
|
|
164
|
+
if (!config.users || config.users.length === 0) {
|
|
165
|
+
throw new Error('Users are required for basic authentication mode');
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
case 'combined':
|
|
169
|
+
if (!config.apiKey) {
|
|
170
|
+
throw new Error('API key is required for combined authentication mode');
|
|
171
|
+
}
|
|
172
|
+
if (!config.ipWhitelist || config.ipWhitelist.length === 0) {
|
|
173
|
+
throw new Error('IP whitelist is required for combined authentication mode');
|
|
174
|
+
}
|
|
175
|
+
break;
|
|
176
|
+
default:
|
|
177
|
+
throw new Error(`Unknown authentication mode: ${config.mode}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// ============================================================
|
|
181
|
+
// Helper for generating password hashes
|
|
182
|
+
// ============================================================
|
|
183
|
+
export async function hashPassword(password, saltRounds = 10) {
|
|
184
|
+
return bcrypt.hash(password, saltRounds);
|
|
185
|
+
}
|
|
186
|
+
// ============================================================
|
|
187
|
+
// Export
|
|
188
|
+
// ============================================================
|
|
189
|
+
export default fp(authPlugin, {
|
|
190
|
+
name: 'auth',
|
|
191
|
+
fastify: '5.x',
|
|
192
|
+
});
|
|
193
|
+
export { authPlugin, AuthError };
|
|
194
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@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AC/D,SAAS;AACT,+DAA+D;AAE/D,eAAe,EAAE,CAAC,UAAU,EAAE;IAC5B,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,KAAK;CACf,CAAC,CAAC;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { FastifyPluginAsync } from 'fastify';
|
|
2
|
+
export interface SwaggerPluginOptions {
|
|
3
|
+
title?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
routePrefix?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const swaggerPlugin: FastifyPluginAsync<SwaggerPluginOptions>;
|
|
9
|
+
/**
|
|
10
|
+
* Common response schemas for reuse across routes
|
|
11
|
+
*/
|
|
12
|
+
export declare const commonSchemas: {
|
|
13
|
+
errorResponse: {
|
|
14
|
+
type: string;
|
|
15
|
+
properties: {
|
|
16
|
+
error: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
message: {
|
|
21
|
+
type: string;
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
required: string[];
|
|
26
|
+
};
|
|
27
|
+
healthResponse: {
|
|
28
|
+
type: string;
|
|
29
|
+
properties: {
|
|
30
|
+
status: {
|
|
31
|
+
type: string;
|
|
32
|
+
enum: string[];
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
timestamp: {
|
|
36
|
+
type: string;
|
|
37
|
+
format: string;
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
required: string[];
|
|
42
|
+
};
|
|
43
|
+
serverNameParam: {
|
|
44
|
+
type: string;
|
|
45
|
+
description: string;
|
|
46
|
+
pattern: string;
|
|
47
|
+
examples: string[];
|
|
48
|
+
};
|
|
49
|
+
worldNameParam: {
|
|
50
|
+
type: string;
|
|
51
|
+
description: string;
|
|
52
|
+
pattern: string;
|
|
53
|
+
examples: string[];
|
|
54
|
+
};
|
|
55
|
+
playerNameParam: {
|
|
56
|
+
type: string;
|
|
57
|
+
description: string;
|
|
58
|
+
pattern: string;
|
|
59
|
+
examples: string[];
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Common route options for consistent error responses
|
|
64
|
+
*/
|
|
65
|
+
export declare const commonRouteOptions: {
|
|
66
|
+
unauthorizedResponse: {
|
|
67
|
+
description: string;
|
|
68
|
+
content: {
|
|
69
|
+
'application/json': {
|
|
70
|
+
schema: {
|
|
71
|
+
type: string;
|
|
72
|
+
properties: {
|
|
73
|
+
error: {
|
|
74
|
+
type: string;
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
77
|
+
message: {
|
|
78
|
+
type: string;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
required: string[];
|
|
83
|
+
};
|
|
84
|
+
example: {
|
|
85
|
+
error: string;
|
|
86
|
+
message: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
forbiddenResponse: {
|
|
92
|
+
description: string;
|
|
93
|
+
content: {
|
|
94
|
+
'application/json': {
|
|
95
|
+
schema: {
|
|
96
|
+
type: string;
|
|
97
|
+
properties: {
|
|
98
|
+
error: {
|
|
99
|
+
type: string;
|
|
100
|
+
description: string;
|
|
101
|
+
};
|
|
102
|
+
message: {
|
|
103
|
+
type: string;
|
|
104
|
+
description: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
required: string[];
|
|
108
|
+
};
|
|
109
|
+
example: {
|
|
110
|
+
error: string;
|
|
111
|
+
message: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
notFoundResponse: {
|
|
117
|
+
description: string;
|
|
118
|
+
content: {
|
|
119
|
+
'application/json': {
|
|
120
|
+
schema: {
|
|
121
|
+
type: string;
|
|
122
|
+
properties: {
|
|
123
|
+
error: {
|
|
124
|
+
type: string;
|
|
125
|
+
description: string;
|
|
126
|
+
};
|
|
127
|
+
message: {
|
|
128
|
+
type: string;
|
|
129
|
+
description: string;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
required: string[];
|
|
133
|
+
};
|
|
134
|
+
example: {
|
|
135
|
+
error: string;
|
|
136
|
+
message: string;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
internalErrorResponse: {
|
|
142
|
+
description: string;
|
|
143
|
+
content: {
|
|
144
|
+
'application/json': {
|
|
145
|
+
schema: {
|
|
146
|
+
type: string;
|
|
147
|
+
properties: {
|
|
148
|
+
error: {
|
|
149
|
+
type: string;
|
|
150
|
+
description: string;
|
|
151
|
+
};
|
|
152
|
+
message: {
|
|
153
|
+
type: string;
|
|
154
|
+
description: string;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
required: string[];
|
|
158
|
+
};
|
|
159
|
+
example: {
|
|
160
|
+
error: string;
|
|
161
|
+
message: string;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
declare const _default: FastifyPluginAsync<SwaggerPluginOptions>;
|
|
168
|
+
export default _default;
|
|
169
|
+
export { swaggerPlugin };
|
|
170
|
+
//# sourceMappingURL=swagger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swagger.d.ts","sourceRoot":"","sources":["../../src/plugins/swagger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAS9D,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD,QAAA,MAAM,aAAa,EAAE,kBAAkB,CAAC,oBAAoB,CAuG3D,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwD9B,CAAC;;AAMF,wBAIG;AAEH,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import fp from 'fastify-plugin';
|
|
2
|
+
import swagger from '@fastify/swagger';
|
|
3
|
+
import swaggerUi from '@fastify/swagger-ui';
|
|
4
|
+
// ============================================================
|
|
5
|
+
// Plugin Implementation
|
|
6
|
+
// ============================================================
|
|
7
|
+
const swaggerPlugin = async (fastify, opts) => {
|
|
8
|
+
const { title = 'mcctl-api', description = 'REST API for managing Docker Minecraft servers', version = '0.1.0', routePrefix = '/docs', } = opts;
|
|
9
|
+
// Register Swagger (OpenAPI spec generation)
|
|
10
|
+
await fastify.register(swagger, {
|
|
11
|
+
openapi: {
|
|
12
|
+
openapi: '3.1.0',
|
|
13
|
+
info: {
|
|
14
|
+
title,
|
|
15
|
+
description,
|
|
16
|
+
version,
|
|
17
|
+
license: {
|
|
18
|
+
name: 'Apache-2.0',
|
|
19
|
+
url: 'https://www.apache.org/licenses/LICENSE-2.0.html',
|
|
20
|
+
},
|
|
21
|
+
contact: {
|
|
22
|
+
name: 'smallmiro',
|
|
23
|
+
url: 'https://github.com/smallmiro/minecraft-server-manager',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
externalDocs: {
|
|
27
|
+
url: 'https://minecraft-server-manager.readthedocs.io/',
|
|
28
|
+
description: 'Full documentation',
|
|
29
|
+
},
|
|
30
|
+
servers: [
|
|
31
|
+
{
|
|
32
|
+
url: '/',
|
|
33
|
+
description: 'Current server (relative)',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
url: 'http://localhost:5000',
|
|
37
|
+
description: 'Local development server',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
url: 'http://192.168.20.37:5000',
|
|
41
|
+
description: 'LAN server',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
tags: [
|
|
45
|
+
{ name: 'health', description: 'Health check endpoints' },
|
|
46
|
+
{ name: 'servers', description: 'Minecraft server management' },
|
|
47
|
+
{ name: 'console', description: 'RCON console access' },
|
|
48
|
+
{ name: 'worlds', description: 'World management' },
|
|
49
|
+
{ name: 'players', description: 'Player management' },
|
|
50
|
+
],
|
|
51
|
+
components: {
|
|
52
|
+
securitySchemes: {
|
|
53
|
+
apiKey: {
|
|
54
|
+
type: 'apiKey',
|
|
55
|
+
name: 'X-API-Key',
|
|
56
|
+
in: 'header',
|
|
57
|
+
description: 'API key for authentication',
|
|
58
|
+
},
|
|
59
|
+
basicAuth: {
|
|
60
|
+
type: 'http',
|
|
61
|
+
scheme: 'basic',
|
|
62
|
+
description: 'Basic HTTP authentication',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
security: [{ apiKey: [] }],
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
// Register Swagger UI
|
|
70
|
+
await fastify.register(swaggerUi, {
|
|
71
|
+
routePrefix,
|
|
72
|
+
uiConfig: {
|
|
73
|
+
docExpansion: 'list',
|
|
74
|
+
deepLinking: true,
|
|
75
|
+
displayRequestDuration: true,
|
|
76
|
+
filter: true,
|
|
77
|
+
showExtensions: true,
|
|
78
|
+
showCommonExtensions: true,
|
|
79
|
+
syntaxHighlight: {
|
|
80
|
+
activate: true,
|
|
81
|
+
theme: 'monokai',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
uiHooks: {
|
|
85
|
+
onRequest: function (_request, _reply, next) {
|
|
86
|
+
next();
|
|
87
|
+
},
|
|
88
|
+
preHandler: function (_request, _reply, next) {
|
|
89
|
+
next();
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
staticCSP: false,
|
|
93
|
+
transformStaticCSP: (header) => header,
|
|
94
|
+
transformSpecification: (swaggerObject) => swaggerObject,
|
|
95
|
+
transformSpecificationClone: true,
|
|
96
|
+
});
|
|
97
|
+
fastify.log.info(`Swagger UI available at ${routePrefix}`);
|
|
98
|
+
fastify.log.info(`OpenAPI spec available at ${routePrefix}/json`);
|
|
99
|
+
};
|
|
100
|
+
// ============================================================
|
|
101
|
+
// Common Schemas
|
|
102
|
+
// ============================================================
|
|
103
|
+
/**
|
|
104
|
+
* Common response schemas for reuse across routes
|
|
105
|
+
*/
|
|
106
|
+
export const commonSchemas = {
|
|
107
|
+
// Error response schema
|
|
108
|
+
errorResponse: {
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: {
|
|
111
|
+
error: { type: 'string', description: 'Error type' },
|
|
112
|
+
message: { type: 'string', description: 'Error message' },
|
|
113
|
+
},
|
|
114
|
+
required: ['error', 'message'],
|
|
115
|
+
},
|
|
116
|
+
// Health check response schema
|
|
117
|
+
healthResponse: {
|
|
118
|
+
type: 'object',
|
|
119
|
+
properties: {
|
|
120
|
+
status: { type: 'string', enum: ['ok'], description: 'Health status' },
|
|
121
|
+
timestamp: { type: 'string', format: 'date-time', description: 'ISO 8601 timestamp' },
|
|
122
|
+
},
|
|
123
|
+
required: ['status', 'timestamp'],
|
|
124
|
+
},
|
|
125
|
+
// Common parameters
|
|
126
|
+
serverNameParam: {
|
|
127
|
+
type: 'string',
|
|
128
|
+
description: 'Server name (without mc- prefix)',
|
|
129
|
+
pattern: '^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$',
|
|
130
|
+
examples: ['survival', 'creative', 'modded'],
|
|
131
|
+
},
|
|
132
|
+
worldNameParam: {
|
|
133
|
+
type: 'string',
|
|
134
|
+
description: 'World name',
|
|
135
|
+
pattern: '^[a-zA-Z0-9][a-zA-Z0-9_-]*$',
|
|
136
|
+
examples: ['world', 'survival_world', 'creative-world'],
|
|
137
|
+
},
|
|
138
|
+
playerNameParam: {
|
|
139
|
+
type: 'string',
|
|
140
|
+
description: 'Minecraft player name',
|
|
141
|
+
pattern: '^[a-zA-Z0-9_]{3,16}$',
|
|
142
|
+
examples: ['Notch', 'Steve', 'Alex'],
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Common route options for consistent error responses
|
|
147
|
+
*/
|
|
148
|
+
export const commonRouteOptions = {
|
|
149
|
+
// 401 Unauthorized
|
|
150
|
+
unauthorizedResponse: {
|
|
151
|
+
description: 'Authentication required',
|
|
152
|
+
content: {
|
|
153
|
+
'application/json': {
|
|
154
|
+
schema: commonSchemas.errorResponse,
|
|
155
|
+
example: {
|
|
156
|
+
error: 'AuthenticationError',
|
|
157
|
+
message: 'Missing X-API-Key header',
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
// 403 Forbidden
|
|
163
|
+
forbiddenResponse: {
|
|
164
|
+
description: 'Access denied',
|
|
165
|
+
content: {
|
|
166
|
+
'application/json': {
|
|
167
|
+
schema: commonSchemas.errorResponse,
|
|
168
|
+
example: {
|
|
169
|
+
error: 'AuthenticationError',
|
|
170
|
+
message: 'IP address not allowed',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
// 404 Not Found
|
|
176
|
+
notFoundResponse: {
|
|
177
|
+
description: 'Resource not found',
|
|
178
|
+
content: {
|
|
179
|
+
'application/json': {
|
|
180
|
+
schema: commonSchemas.errorResponse,
|
|
181
|
+
example: {
|
|
182
|
+
error: 'NotFound',
|
|
183
|
+
message: 'Server not found',
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
// 500 Internal Server Error
|
|
189
|
+
internalErrorResponse: {
|
|
190
|
+
description: 'Internal server error',
|
|
191
|
+
content: {
|
|
192
|
+
'application/json': {
|
|
193
|
+
schema: commonSchemas.errorResponse,
|
|
194
|
+
example: {
|
|
195
|
+
error: 'InternalError',
|
|
196
|
+
message: 'An unexpected error occurred',
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
// ============================================================
|
|
203
|
+
// Export
|
|
204
|
+
// ============================================================
|
|
205
|
+
export default fp(swaggerPlugin, {
|
|
206
|
+
name: 'swagger',
|
|
207
|
+
fastify: '5.x',
|
|
208
|
+
dependencies: [], // No dependencies, should be registered early
|
|
209
|
+
});
|
|
210
|
+
export { swaggerPlugin };
|
|
211
|
+
//# sourceMappingURL=swagger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../src/plugins/swagger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAChC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAa5C,+DAA+D;AAC/D,wBAAwB;AACxB,+DAA+D;AAE/D,MAAM,aAAa,GAA6C,KAAK,EACnE,OAAwB,EACxB,IAA0B,EAC1B,EAAE;IACF,MAAM,EACJ,KAAK,GAAG,WAAW,EACnB,WAAW,GAAG,gDAAgD,EAC9D,OAAO,GAAG,OAAO,EACjB,WAAW,GAAG,OAAO,GACtB,GAAG,IAAI,CAAC;IAET,6CAA6C;IAC7C,MAAM,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE;QAC9B,OAAO,EAAE;YACP,OAAO,EAAE,OAAO;YAChB,IAAI,EAAE;gBACJ,KAAK;gBACL,WAAW;gBACX,OAAO;gBACP,OAAO,EAAE;oBACP,IAAI,EAAE,YAAY;oBAClB,GAAG,EAAE,kDAAkD;iBACxD;gBACD,OAAO,EAAE;oB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gB;IAChB,gBAAgB,EAAE;QAChB,WAAW,EAAE,oBAAoB;QACjC,OAAO,EAAE;YACP,kBAAkB,EAAE;gBAClB,MAAM,EAAE,aAAa,CAAC,aAAa;gBACnC,OAAO,EAAE;oBACP,KAAK,EAAE,UAAU;oBACjB,OAAO,EAAE,kBAAkB;iBAC5B;aACF;SACF;KACF;IAED,4BAA4B;IAC5B,qBAAqB,EAAE;QACrB,WAAW,EAAE,uBAAuB;QACpC,OAAO,EAAE;YACP,kBAAkB,EAAE;gBAClB,MAAM,EAAE,aAAa,CAAC,aAAa;gBACnC,OAAO,EAAE;oBACP,KAAK,EAAE,eAAe;oBACtB,OAAO,EAAE,8BAA8B;iBACxC;aACF;SACF;KACF;CACF,CAAC;AAEF,+DAA+D;AAC/D,SAAS;AACT,+DAA+D;AAE/D,eAAe,EAAE,CAAC,aAAa,EAAE;IAC/B,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,KAAK;IACd,YAAY,EAAE,EAAE,EAAE,8CAA8C;CACjE,CAAC,CAAC;AAEH,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authentication Routes
|
|
3
|
+
*
|
|
4
|
+
* Handles user authentication for the mcctl-console.
|
|
5
|
+
* Validates credentials against users.yaml file.
|
|
6
|
+
*/
|
|
7
|
+
import { FastifyInstance } from 'fastify';
|
|
8
|
+
/**
|
|
9
|
+
* Register authentication routes
|
|
10
|
+
*/
|
|
11
|
+
export default function authRoutes(app: FastifyInstance): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAgC,MAAM,SAAS,CAAC;AAYxE;;GAEG;AACH,wBAA8B,UAAU,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAyJ5E"}
|