Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminando más security hotspots #171

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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