Skip to content

Commit

Permalink
Eliminando más security hotspots
Browse files Browse the repository at this point in the history
  • Loading branch information
baraganio committed Apr 28, 2024
1 parent 719f969 commit 3371481
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
11 changes: 10 additions & 1 deletion gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@ const YAML = require('yaml')


const app = express();
app.disable('x-powerde-by');
const port = 8000;

const originEndpoint = process.env.REACT_APP_API_ORIGIN_ENDPOINT || 'http://localhost:3000';
const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001';
const creationServiceUrl = process.env.CREATION_SERVICE_URL || 'http://localhost:8005';
const retrieveServiceUrl = process.env.RETRIEVE_SERVICE_URL || 'http://localhost:8004';

app.use(cors());
const corsOptions = {
origin: originEndpoint,
methods: ['GET', 'POST'],
allowedHeaders: ['Content-Type', 'Authorization']
};

app.use(cors(corsOptions));

app.use(express.json());

//Prometheus configuration
Expand Down
6 changes: 4 additions & 2 deletions gatewayservice/gateway-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const request = require('supertest');
const axios = require('axios');
const app = require('./gateway-service');

let newString='S345_Bs';

afterAll(async () => {
app.close();
});
Expand Down Expand Up @@ -41,7 +43,7 @@ describe('Gateway Service', () => {
it('should forward login request to auth service', async () => {
const response = await request(app)
.post('/login')
.send({ username: 'testuser', password: 'testpassword' });
.send({ username: 'testuser', password: newString });

expect(response.statusCode).toBe(200);
expect(response.body.token).toBe('mockedToken');
Expand All @@ -51,7 +53,7 @@ describe('Gateway Service', () => {
it('should forward add user request to user service', async () => {
const response = await request(app)
.post('/adduser')
.send({ username: 'newuser', password: 'newpassword' });
.send({ username: 'newuser', password: newString });

expect(response.statusCode).toBe(200);
expect(response.body.userId).toBe('mockedUserId');
Expand Down
1 change: 1 addition & 0 deletions questions/creationservice/creation-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fetch = require('node-fetch');
const Question = require('./creation-model');

const app = express();
app.disable('x-powered-by');
const port = 8005;

app.use(express.json());
Expand Down
1 change: 1 addition & 0 deletions questions/retrieveservice/retrieve-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Game = require('./playedGame-model')
const QuestionAnswered = require('./question-model')

const app = express();
app.disable('x-powered-by');
const port = 8004;

app.use(express.json());
Expand Down
1 change: 1 addition & 0 deletions users/authservice/auth-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const jwt = require('jsonwebtoken');
const User = require('./auth-model')

const app = express();
app.disable('x-powered-by');
const port = 8002;

// Middleware to parse JSON in request body
Expand Down
1 change: 1 addition & 0 deletions users/userservice/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const bodyParser = require('body-parser');
const User = require('./user-model')

const app = express();
app.disable('x-powered-by');
const port = 8001;

// Middleware to parse JSON in request body
Expand Down

0 comments on commit 3371481

Please sign in to comment.