Commit c28d866a authored by CarlosGC1989's avatar CarlosGC1989
Browse files

Arregla claves secretas

Soluciona el issue #1.

Fix #1
parent 182fc464
Loading
Loading
Loading
Loading
+27 −3
Original line number Diff line number Diff line
var express = require('express'),
	fs = require('fs'),
	path = require('path');

var params, app, version;
	path = require('path'),
	request = require('request');

var params, app, version,
	oauthClientCredentials = process.env.OAUTH_CLIENT_CREDENTIALS || '';

function getLang(req) {

@@ -86,6 +87,27 @@ function onUnknownRequest(req, res, next) {
	res.redirect('/404');
}

function onOauthTokenRequest(req, res) {

	var password = req.params.password,
		username = req.params.username,
		options = {
			url: req.headers.origin + '/api' + req.url,
			method: 'POST',
			body: "grant_type=password&username=" + username + "&password=" + password + "&scope=write",
			headers: {
				'Content-Type': 'application/x-www-form-urlencoded',
				'Authorization': 'Basic ' + oauthClientCredentials
			}
		};

	request(options, function(res, error, response, body) {

		res.statusCode = response.statusCode;
		res.send(body);
	}.bind(this, res));
}

function exposeRoutes() {

	app.get(
@@ -108,6 +130,8 @@ function exposeRoutes() {

		.get(/.*\/jquery.js/, onJqueryRequest)

		.post('/oauth/token', onOauthTokenRequest)

		.use(onUnknownRequest);
}

+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
    "prom-client": "^11.0.0",
    "pug": "^2.0.3",
    "response-time": "^2.3.2",
    "request": "^2.71.0",
    "winston": "^2.4.2"
  },
  "devDependencies": {
+3 −1
Original line number Diff line number Diff line
define([
	'alertify/alertify.min'
	, 'app/redmicConfig'
	, "dojo/_base/declare"
	, "dojo/_base/lang"
	, "dojo/i18n!app/nls/translation"
	, "redmic/base/Credentials"
], function(
	alertify
	, redmicConfig
	, declare
	, lang
	, i18n
@@ -114,7 +116,7 @@ define([
				m.parentNode.insertBefore(a,m);
			})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

			ga('create', '<GoogleAnalyticsID>', 'auto');
			ga('create', redmicConfig.googleAnalyticsId, 'auto');
			ga('send', 'pageview');
		}
	});
+2 −2
Original line number Diff line number Diff line
@@ -18,8 +18,8 @@ define([
				callback: null,
				node: null,

				_siteKey: '<ReCaptchaSiteKey>',
				_siteKeyForDebug: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI',
				_siteKey: redmicConfig.siteKeyReCaptcha,
				_siteKeyForDebug: redmicConfig.siteKeyForDebugReCaptcha,
				_theme: 'dark',
				_instanceId: null
			};
+5 −2
Original line number Diff line number Diff line
@@ -5,7 +5,10 @@ define([], function() {
	var retObj = {
		"numMaxView": 10,
		"apiVersion": 1,
		"pathSeparator": '/'
		"pathSeparator": "/",
		"siteKeyReCaptcha": "6LfA6_0SAAAAACT3i8poH1NqztZCtIW1OahT0cXs",
		"siteKeyForDebugReCaptcha": "6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI",
		"googleAnalyticsId": "UA-58848624-1"
	};

	retObj.viewPaths = {
@@ -252,7 +255,7 @@ define([], function() {
		"speciesValidity": baseUri + "speciesvalidities",
		"themes": baseUri + "themes",
		"thematicType": baseUri + "thematictypes",
		"token": baseUri + "oauth/token",
		"token": "/oauth/token",
		"logout": baseUri + "oauth/token/revoke",
		"unit": baseUri + "units",
		"unitType": baseUri + "unittypes",
Loading