@cloudron/tegel 1.0.0 → 1.0.2

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.
Files changed (4) hide show
  1. package/index.js +14 -5
  2. package/logo.png +0 -0
  3. package/logo.svg +82 -0
  4. package/package.json +3 -3
package/index.js CHANGED
@@ -9,7 +9,9 @@ export async function createExpressApp({ sessionSecret = 'changeme', oidcConfig
9
9
 
10
10
  const app = express();
11
11
 
12
- app.set('trust proxy', 1);
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
 
@@ -31,7 +33,7 @@ export async function createExpressApp({ sessionSecret = 'changeme', oidcConfig
31
33
 
32
34
  app.use(lastMile());
33
35
 
34
- return { app, router };
36
+ return { app, router, express };
35
37
  }
36
38
 
37
39
  export const servePath = express.static;
@@ -46,6 +48,7 @@ export async function oidcRedirectToLoginProvider(req, res, next) {
46
48
  const refererUrl = new URL(referer);
47
49
  // Store the origin (e.g., http://localhost:5173) to redirect back after auth
48
50
  req.session.frontendOrigin = refererUrl.origin;
51
+ // eslint-disable-next-line no-unused-vars
49
52
  } catch (e) {
50
53
  // Invalid referer, ignore
51
54
  }
@@ -60,9 +63,10 @@ export async function oidcRedirectToLoginProvider(req, res, next) {
60
63
  }
61
64
  }
62
65
 
63
- export function oidcCallback(successRedirectTo, errorRedirectTo) {
66
+ export function oidcCallback(successRedirectTo, errorRedirectTo, successHook = async () => {}) {
64
67
  if (!successRedirectTo || typeof successRedirectTo !== 'string') throw new Error('oidcCallback needs a successRedirectTo path as non-empty string');
65
68
  if (!errorRedirectTo || typeof errorRedirectTo !== 'string') throw new Error('oidcCallback needs a errorRedirectTo path as non-empty string');
69
+ if (!successHook || typeof successHook !== 'function') throw new Error('oidcCallback needs a successHook path as a function');
66
70
 
67
71
  return async (req, res) => {
68
72
  // Redirect to the frontend origin that initiated the login (supports Vite dev server)
@@ -74,6 +78,8 @@ export function oidcCallback(successRedirectTo, errorRedirectTo) {
74
78
 
75
79
  req.session.user = user;
76
80
 
81
+ await successHook(user);
82
+
77
83
  res.redirect((frontendOrigin || '') + successRedirectTo);
78
84
  } catch (error) {
79
85
  console.error('Callback error:', error);
@@ -96,6 +102,7 @@ export function logout(redirectTo) {
96
102
  try {
97
103
  const refererUrl = new URL(referer);
98
104
  redirectUri = refererUrl.origin;
105
+ // eslint-disable-next-line no-unused-vars
99
106
  } catch (e) {
100
107
  // Invalid referer, use default
101
108
  }
@@ -108,8 +115,8 @@ export function logout(redirectTo) {
108
115
  };
109
116
  }
110
117
 
111
- export function requireAuth(redirectTo) {
112
- if (!redirectTo || typeof redirectTo !== 'string') throw new Error('requireAuth needs a redirectTo path as non-empty string');
118
+ export function requireAuth(redirectTo = '') {
119
+ if (typeof redirectTo !== 'string') throw new Error('requireAuth needs a redirectTo path as non-empty string');
113
120
 
114
121
  return (req, res, next) => {
115
122
  if (req.session && req.session.user) {
@@ -117,6 +124,8 @@ export function requireAuth(redirectTo) {
117
124
  return next();
118
125
  }
119
126
 
127
+ if (!redirectTo) return next(new HttpError(401, 'Unauthorized'));
128
+
120
129
  res.redirect(redirectTo);
121
130
  };
122
131
  }
package/logo.png ADDED
Binary file
package/logo.svg ADDED
@@ -0,0 +1,82 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ width="512"
4
+ height="512"
5
+ viewBox="0 0 384 384.00001"
6
+ version="1.2"
7
+ id="svg177"
8
+ sodipodi:docname="Flughafen_Berlin-Tegel_(2003).svg"
9
+ inkscape:version="1.4.3 (0d15f75042, 2025-12-25)"
10
+ inkscape:export-filename="logo.png"
11
+ inkscape:export-xdpi="96"
12
+ inkscape:export-ydpi="96"
13
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
14
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ xmlns:svg="http://www.w3.org/2000/svg"
17
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
18
+ xmlns:cc="http://creativecommons.org/ns#"
19
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
20
+ <title
21
+ id="title80827">Berlin Tegel (2003)</title>
22
+ <sodipodi:namedview
23
+ id="namedview179"
24
+ pagecolor="#ffffff"
25
+ bordercolor="#111111"
26
+ borderopacity="1"
27
+ inkscape:pageshadow="0"
28
+ inkscape:pageopacity="0"
29
+ inkscape:pagecheckerboard="1"
30
+ inkscape:document-units="pt"
31
+ showgrid="false"
32
+ inkscape:zoom="1.3634758"
33
+ inkscape:cx="254.86334"
34
+ inkscape:cy="262.19754"
35
+ inkscape:window-width="1920"
36
+ inkscape:window-height="1014"
37
+ inkscape:window-x="0"
38
+ inkscape:window-y="0"
39
+ inkscape:window-maximized="1"
40
+ inkscape:current-layer="svg177"
41
+ inkscape:showpageshadow="2"
42
+ inkscape:deskcolor="#d1d1d1"
43
+ showguides="true" />
44
+ <defs
45
+ id="defs62" />
46
+ <g
47
+ id="g1"
48
+ transform="translate(11.511545,8.6889135)">
49
+ <path
50
+ style="fill:#19458f;fill-opacity:1;fill-rule:nonzero;stroke:#19458f;stroke-width:0.571433;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:3.864;stroke-opacity:1"
51
+ d="m 207.17908,0.28571635 h 67.31829 L 191.08988,144.84555 l 42.32259,74.76617 h -66.69954 l -43.2508,-74.63363 z m 0,0"
52
+ id="path68" />
53
+ <path
54
+ style="fill:#19458f;fill-opacity:1;fill-rule:nonzero;stroke:#19458f;stroke-width:0.571433;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:3.864;stroke-opacity:1"
55
+ d="M 67.8129,364.4809 H 0.49464934 L 83.880064,219.92115 41.557479,145.15489 h 66.699461 l 43.27291,74.63363 z m 0,0"
56
+ id="path70" />
57
+ <path
58
+ style="fill:#19458f;fill-opacity:1;fill-rule:nonzero;stroke:#19458f;stroke-width:0.571433;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:3.864;stroke-opacity:1"
59
+ d="m 328.06913,231.81123 32.42152,58.19078 H 195.42156 l -43.75908,76.04802 -34.63162,-59.98091 42.87513,-74.25789 z m 0,0"
60
+ id="path72" />
61
+ </g>
62
+ <text
63
+ xml:space="preserve"
64
+ style="font-weight:bold;font-size:45px;line-height:1.25;font-family:'Helvetica Neue LT Std';-inkscape-font-specification:'Helvetica Neue LT Std Bold';stroke-width:0.75"
65
+ x="109.5576"
66
+ y="67.842606"
67
+ id="text32536"><tspan
68
+ sodipodi:role="line"
69
+ id="tspan32534"
70
+ style="font-size:45px;stroke-width:0.75"
71
+ x="109.5576"
72
+ y="67.842606" /></text>
73
+ <metadata
74
+ id="metadata80825">
75
+ <rdf:RDF>
76
+ <cc:Work
77
+ rdf:about="">
78
+ <dc:title>Berlin Tegel (2003)</dc:title>
79
+ </cc:Work>
80
+ </rdf:RDF>
81
+ </metadata>
82
+ </svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudron/tegel",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "license": "GPL-2.0",
6
6
  "author": "Cloudron Developers",
@@ -18,8 +18,8 @@
18
18
  "openid-client": "^6.8.1"
19
19
  },
20
20
  "devDependencies": {
21
- "@eslint/js": "^9.18.0",
21
+ "@eslint/js": "^9.39.2",
22
22
  "eslint": "^9.39.2",
23
- "globals": "^16.0.0"
23
+ "globals": "^17.3.0"
24
24
  }
25
25
  }