Revert "Quick workaround for heroku + cloudflare https problem"
This reverts commit d7823c3176
.
This commit is contained in:
parent
4d4c0972f3
commit
c71273f701
7 changed files with 26 additions and 12 deletions
7
app.js
7
app.js
|
@ -4,6 +4,7 @@ const logger = require('morgan');
|
||||||
const cookieParser = require('cookie-parser');
|
const cookieParser = require('cookie-parser');
|
||||||
const bodyParser = require('body-parser');
|
const bodyParser = require('body-parser');
|
||||||
const sassMiddleware = require('node-sass-middleware');
|
const sassMiddleware = require('node-sass-middleware');
|
||||||
|
const protocol = require("./src/utils/connection");
|
||||||
// const favicon = require('serve-favicon');
|
// const favicon = require('serve-favicon');
|
||||||
|
|
||||||
const subdomain = require('express-subdomain');
|
const subdomain = require('express-subdomain');
|
||||||
|
@ -37,9 +38,9 @@ app.use(express.static(path.join(__dirname, 'public')));
|
||||||
|
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
res.locals.userInfo = require('./data/api/ListaUczniow')[1];
|
res.locals.userInfo = require('./data/api/ListaUczniow')[1];
|
||||||
res.locals.uonetplusUrl = "//" + req.get('host').replace("uonetplus-opiekun", "uonetplus");
|
res.locals.uonetplusUrl = protocol(req) + "://" + req.get('host').replace("uonetplus-opiekun", "uonetplus");
|
||||||
res.locals.currentHost = "//" + req.get('host');
|
res.locals.currentHost = protocol(req) + "://" + req.get('host');
|
||||||
res.locals.mainHost = "//" + req.get('host')
|
res.locals.mainHost = protocol(req) + "://" + req.get('host')
|
||||||
.replace(/(api|cufs|uonetplus|uonetplus-opiekun|uonetplus-uzytkownik)\./, "");
|
.replace(/(api|cufs|uonetplus|uonetplus-opiekun|uonetplus-uzytkownik)\./, "");
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
const router = require('express').Router();
|
const router = require('express').Router();
|
||||||
|
const protocol = require('../../utils/connection');
|
||||||
|
|
||||||
router.all("/", (req, res) => {
|
router.all("/", (req, res) => {
|
||||||
let base = "//" + req.get('host');
|
let base = protocol(req) + "://" + req.get('host');
|
||||||
res.json({
|
res.json({
|
||||||
"status": "success",
|
"status": "success",
|
||||||
"start": base.replace("api.", ""),
|
"start": base.replace("api.", ""),
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
const router = require('express').Router({});
|
const router = require('express').Router({});
|
||||||
|
const protocol = require('../../utils/connection');
|
||||||
const api = require("../../utils/api");
|
const api = require("../../utils/api");
|
||||||
|
|
||||||
router.all("/Certyfikat", (req, res) => {
|
router.all("/Certyfikat", (req, res) => {
|
||||||
let base = "//" + req.get('host');
|
let base = protocol(req) + "://" + req.get('host');
|
||||||
|
|
||||||
// key gen
|
// key gen
|
||||||
// keytool -genkeypair -keystore myKeystore.p12 -storetype PKCS12 -storepass 012345678901234567890123456789AB -alias LoginCert -keyalg RSA -keysize 2048 -sigalg SHA1WithRSA -validity 99999 -dname "CN=Wulkanowy, OU=Wulkanowy, O=Wulkanowy, L=Jaroslaw, ST=podkarpackie, C=WLKNW" -ext san=dns:fakelog.cf,dns:localhost,ip:127.0.0.1
|
// keytool -genkeypair -keystore myKeystore.p12 -storetype PKCS12 -storepass 012345678901234567890123456789AB -alias LoginCert -keyalg RSA -keysize 2048 -sigalg SHA1WithRSA -validity 99999 -dname "CN=Wulkanowy, OU=Wulkanowy, O=Wulkanowy, L=Jaroslaw, ST=podkarpackie, C=WLKNW" -ext san=dns:fakelog.cf,dns:localhost,ip:127.0.0.1
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const protocol = require('../utils/connection');
|
||||||
|
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
res.redirect("/Default/Account/LogOn");
|
res.redirect("/Default/Account/LogOn");
|
||||||
|
@ -22,8 +23,8 @@ router.post("/Default/Account/LogOn", (req, res) => {
|
||||||
res.cookie("ARR_cufs.vulcan.net.pl", "1234567891012131314151617181920212223242526272829303132333435363");
|
res.cookie("ARR_cufs.vulcan.net.pl", "1234567891012131314151617181920212223242526272829303132333435363");
|
||||||
return res.redirect("/Default/FS/LS?" +
|
return res.redirect("/Default/FS/LS?" +
|
||||||
"wa=wsignin1.0&" +
|
"wa=wsignin1.0&" +
|
||||||
"wtrealm=%2f%2fuonetplus.fakelog.localhost%3A300%2fdemo123%2fLoginEndpoint.aspx&" +
|
"wtrealm=" + protocol(req) + "%3a%2f%2fuonetplus.fakelog.localhost%3A300%2fdemo123%2fLoginEndpoint.aspx&" +
|
||||||
"wctx=%2f%2fuonetplus.fakelog.localhost%3A300%2fdemo123%2fLoginEndpoint.aspx");
|
"wctx=" + protocol(req) + "%3a%2f%2fuonetplus.fakelog.localhost%3A300%2fdemo123%2fLoginEndpoint.aspx");
|
||||||
}
|
}
|
||||||
|
|
||||||
res.render("login-form", {title: "Logowanie (Default)", message: "Zła nazwa użytkownika lub hasło"});
|
res.render("login-form", {title: "Logowanie (Default)", message: "Zła nazwa użytkownika lub hasło"});
|
||||||
|
@ -32,7 +33,7 @@ router.post("/Default/Account/LogOn", (req, res) => {
|
||||||
router.get("/Default/FS/LS", (req, res) => {
|
router.get("/Default/FS/LS", (req, res) => {
|
||||||
res.render("login-cert", {
|
res.render("login-cert", {
|
||||||
cert: fs.readFileSync("public/cert.xml", "utf8"),
|
cert: fs.readFileSync("public/cert.xml", "utf8"),
|
||||||
uonetplusOpiekun: "//" + req.get('host').replace("cufs.", "uonetplus.")
|
uonetplusOpiekun: protocol(req) + "://" + req.get('host').replace("cufs.", "uonetplus.")
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const protocol = require('../utils/connection');
|
||||||
const {format, fromUnixTime, getYear, addYears, addMonths} = require('date-fns');
|
const {format, fromUnixTime, getYear, addYears, addMonths} = require('date-fns');
|
||||||
|
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
const base = "//" + req.get('host') + "/Default/123456";
|
const base = protocol(req) + "://" + req.get('host') + "/Default/123456";
|
||||||
res.json({
|
res.json({
|
||||||
status: "sucess",
|
status: "sucess",
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
const protocol = require('../utils/connection');
|
||||||
|
|
||||||
router.get("/", (req, res) => {
|
router.get("/", (req, res) => {
|
||||||
res.render("log-exception", {
|
res.render("log-exception", {
|
||||||
|
@ -23,7 +24,7 @@ router.all("/Default/LoginEndpoint.aspx", (req, res) => {
|
||||||
return res.redirect("/Default/?login=true");
|
return res.redirect("/Default/?login=true");
|
||||||
}
|
}
|
||||||
|
|
||||||
res.redirect("//" + req.get('host').replace("uonetplus", "cufs") + "/Default/Account/LogOn");
|
res.redirect(protocol(req) + "://" + req.get('host').replace("uonetplus", "cufs") + "/Default/Account/LogOn");
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post("(/*)?", (req, res) => {
|
router.post("(/*)?", (req, res) => {
|
||||||
|
@ -35,8 +36,8 @@ router.post("(/*)?", (req, res) => {
|
||||||
router.get("/Default/Start.mvc/Index", (req, res) => {
|
router.get("/Default/Start.mvc/Index", (req, res) => {
|
||||||
res.render("homepage", {
|
res.render("homepage", {
|
||||||
title: "Uonet+",
|
title: "Uonet+",
|
||||||
uonetplusOpiekun: "//" + req.get('host').replace("uonetplus", "uonetplus-opiekun"),
|
uonetplusOpiekun: protocol(req) + "://" + req.get('host').replace("uonetplus", "uonetplus-opiekun"),
|
||||||
uonetplusUczen: "//" + req.get('host').replace("uonetplus", "uonetplus-uczen")
|
uonetplusUczen: protocol(req) + "://" + req.get('host').replace("uonetplus", "uonetplus-uczen")
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
8
src/utils/connection.js
Normal file
8
src/utils/connection.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
function getProtocol(req) {
|
||||||
|
let proto = req.connection.encrypted ? 'https' : 'http';
|
||||||
|
// only do this if you trust the proxy
|
||||||
|
proto = req.headers['x-forwarded-proto'] || proto;
|
||||||
|
return proto.split(/\s*,\s*/)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getProtocol;
|
Loading…
Reference in a new issue