@cloudron/tegel 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +10 -3
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -9,12 +9,17 @@ export async function createExpressApp({ sessionSecret = 'changeme', oidcConfig
|
|
|
9
9
|
|
|
10
10
|
const app = express();
|
|
11
11
|
|
|
12
|
-
app.set('trust proxy',
|
|
12
|
+
app.set('trust proxy', true);
|
|
13
|
+
app.set('json spaces', 2);
|
|
14
|
+
app.set('query parser', 'simple');
|
|
13
15
|
|
|
14
16
|
app.use(express.json());
|
|
15
17
|
|
|
18
|
+
const FileStore = require('session-file-store')(session);
|
|
19
|
+
|
|
16
20
|
app.use(session({
|
|
17
21
|
secret: sessionSecret,
|
|
22
|
+
store: new FileStore({ path: process.env.CLOUDRON ? '/app/data/.session.store' : '/tmp/session.store' }),
|
|
18
23
|
resave: false,
|
|
19
24
|
saveUninitialized: false,
|
|
20
25
|
cookie: {
|
|
@@ -113,8 +118,8 @@ export function logout(redirectTo) {
|
|
|
113
118
|
};
|
|
114
119
|
}
|
|
115
120
|
|
|
116
|
-
export function requireAuth(redirectTo) {
|
|
117
|
-
if (
|
|
121
|
+
export function requireAuth(redirectTo = '') {
|
|
122
|
+
if (typeof redirectTo !== 'string') throw new Error('requireAuth needs a redirectTo path as non-empty string');
|
|
118
123
|
|
|
119
124
|
return (req, res, next) => {
|
|
120
125
|
if (req.session && req.session.user) {
|
|
@@ -122,6 +127,8 @@ export function requireAuth(redirectTo) {
|
|
|
122
127
|
return next();
|
|
123
128
|
}
|
|
124
129
|
|
|
130
|
+
if (!redirectTo) return next(new HttpError(401, 'Unauthorized'));
|
|
131
|
+
|
|
125
132
|
res.redirect(redirectTo);
|
|
126
133
|
};
|
|
127
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudron/tegel",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "GPL-2.0",
|
|
6
6
|
"author": "Cloudron Developers",
|
|
@@ -20,6 +20,6 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@eslint/js": "^9.39.2",
|
|
22
22
|
"eslint": "^9.39.2",
|
|
23
|
-
"globals": "^17.
|
|
23
|
+
"globals": "^17.3.0"
|
|
24
24
|
}
|
|
25
25
|
}
|