Quitar autenticacion del endpoint POST /token
El endpoint queda abierto para que cualquier servicio local pueda solicitar tokens sin necesitar el SERVER_TOKEN.
This commit is contained in:
@@ -25582,14 +25582,6 @@ var httpServer = createServer(async (req, res) => {
|
|||||||
const url2 = new URL(`http://${HOST}${req.url}`);
|
const url2 = new URL(`http://${HOST}${req.url}`);
|
||||||
if (url2.pathname === "/token" && req.method === "POST") {
|
if (url2.pathname === "/token" && req.method === "POST") {
|
||||||
try {
|
try {
|
||||||
if (serverToken) {
|
|
||||||
const authHeader = req.headers.authorization;
|
|
||||||
if (authHeader !== `Bearer ${serverToken}`) {
|
|
||||||
res.writeHead(401, { "Content-Type": "application/json" });
|
|
||||||
res.end(JSON.stringify({ error: "Unauthorized" }));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const token = await generateNewRegistrationToken();
|
const token = await generateNewRegistrationToken();
|
||||||
res.writeHead(200, { "Content-Type": "application/json" });
|
res.writeHead(200, { "Content-Type": "application/json" });
|
||||||
res.end(JSON.stringify({
|
res.end(JSON.stringify({
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -46,16 +46,6 @@ const httpServer = createServer(async (req, res) => {
|
|||||||
// Endpoint: POST /token - Genera un nuevo token de registro
|
// Endpoint: POST /token - Genera un nuevo token de registro
|
||||||
if (url.pathname === '/token' && req.method === 'POST') {
|
if (url.pathname === '/token' && req.method === 'POST') {
|
||||||
try {
|
try {
|
||||||
// Autenticacion con SERVER_TOKEN
|
|
||||||
if (serverToken) {
|
|
||||||
const authHeader = req.headers.authorization;
|
|
||||||
if (authHeader !== `Bearer ${serverToken}`) {
|
|
||||||
res.writeHead(401, { 'Content-Type': 'application/json' });
|
|
||||||
res.end(JSON.stringify({ error: 'Unauthorized' }));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = await generateNewRegistrationToken();
|
const token = await generateNewRegistrationToken();
|
||||||
res.writeHead(200, { 'Content-Type': 'application/json' });
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||||
res.end(JSON.stringify({
|
res.end(JSON.stringify({
|
||||||
|
|||||||
Reference in New Issue
Block a user