mbkauthe 4.7.2 → 4.8.1

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/README.md CHANGED
@@ -22,8 +22,8 @@
22
22
  - PostgreSQL session management
23
23
  - Multi-session support (configurable concurrent sessions per user)
24
24
  - Optional TOTP-based 2FA with trusted devices
25
- - OAuth login (GitHub & Google)
26
- - Role-based access: SuperAdmin, NormalUser, Guest
25
+ - Social login (GitHub App & Google OAuth)
26
+ - Role-based access: SuperAdmin, NormalUser, Guest, member
27
27
  - CSRF protection & rate limiting
28
28
  - Easy Express.js integration
29
29
  - Customizable Handlebars templates
@@ -101,9 +101,9 @@ These are only mounted when `process.env.env === "dev"`:
101
101
 
102
102
  Enable via `MBKAUTH_TWO_FA_ENABLE=true`. Trusted devices can skip 2FA for a set duration.
103
103
 
104
- ## 🔄 OAuth Integration
104
+ ## 🔄 Social Login Integration
105
105
 
106
- **GitHub / Google OAuth:** Configure apps and credentials via `.env` or `mbkautheVar`. Users must link accounts before login.
106
+ **GitHub App / Google OAuth:** Configure credentials via `.env` or `mbkautheVar`. Users must link accounts before login.
107
107
 
108
108
  ## 🎨 Customization
109
109
 
package/docs/api.md CHANGED
@@ -179,7 +179,7 @@ Renders the main login page.
179
179
  **Response:** HTML page with login form
180
180
 
181
181
  **Template Variables:**
182
- - `githubLoginEnabled` - Whether GitHub OAuth is enabled
182
+ - `githubLoginEnabled` - Whether GitHub App login is enabled
183
183
  - `googleLoginEnabled` - Whether Google OAuth is enabled
184
184
  - `customURL` - Redirect URL after login
185
185
  - `userLoggedIn` - Whether user is already authenticated
@@ -317,8 +317,8 @@ The endpoints below are active in the router but are not fully expanded above. U
317
317
 
318
318
  **OAuth:**
319
319
 
320
- - `GET /mbkauthe/api/github/login` - Starts GitHub OAuth login flow.
321
- - `GET /mbkauthe/api/github/login/callback` - GitHub OAuth callback.
320
+ - `GET /mbkauthe/api/github/login` - Starts GitHub App login flow.
321
+ - `GET /mbkauthe/api/github/login/callback` - GitHub App callback.
322
322
  - `GET /mbkauthe/api/google/login` - Starts Google OAuth login flow.
323
323
  - `GET /mbkauthe/api/google/login/callback` - Google OAuth callback.
324
324
 
@@ -1222,11 +1222,11 @@ GET /mbkauthe/test
1222
1222
 
1223
1223
  ### OAuth Endpoints
1224
1224
 
1225
- #### GitHub OAuth
1225
+ #### GitHub App
1226
1226
 
1227
1227
  ##### `GET /mbkauthe/api/github/login`
1228
1228
 
1229
- Initiates the GitHub OAuth authentication flow.
1229
+ Initiates the GitHub App authentication flow.
1230
1230
 
1231
1231
  **Rate Limit:** 10 requests per 5 minutes
1232
1232
 
@@ -1235,11 +1235,11 @@ Initiates the GitHub OAuth authentication flow.
1235
1235
  **Query Parameters:**
1236
1236
  - `redirect` (optional) - Relative URL to redirect after successful authentication (must start with `/` to prevent open redirect attacks)
1237
1237
 
1238
- **Response:** Redirects to GitHub OAuth authorization page
1238
+ **Response:** Redirects to GitHub authorization page
1239
1239
 
1240
1240
  **Prerequisites:**
1241
1241
  - `GITHUB_LOGIN_ENABLED=true` in environment
1242
- - Valid `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` configured
1242
+ - Valid `GITHUB_APP_CLIENT_ID` and `GITHUB_APP_CLIENT_SECRET` configured
1243
1243
  - User's GitHub account must be linked to an MBKAuth account in `user_github` table
1244
1244
 
1245
1245
  **Example:**
@@ -1250,9 +1250,9 @@ GET /mbkauthe/api/github/login?redirect=/dashboard
1250
1250
  **Workflow:**
1251
1251
  1. User clicks "Login with GitHub"
1252
1252
  2. CSRF token generated and stored in session
1253
- 3. Redirects to GitHub for authorization
1254
- 4. GitHub redirects back to callback URL
1255
- 5. System verifies GitHub account is linked
1253
+ 3. Redirects to GitHub authorization page
1254
+ 4. GitHub redirects back to callback URL with authorization `code`
1255
+ 5. System verifies `github_id` is linked
1256
1256
  6. If 2FA enabled, prompts for 2FA
1257
1257
  7. Creates session and redirects to specified URL
1258
1258
 
@@ -1260,7 +1260,7 @@ GET /mbkauthe/api/github/login?redirect=/dashboard
1260
1260
 
1261
1261
  ##### `GET /mbkauthe/api/github/login/callback`
1262
1262
 
1263
- Handles the OAuth callback from GitHub after user authorization.
1263
+ Handles the callback from GitHub after user authorization.
1264
1264
 
1265
1265
  **Rate Limit:** Inherited from OAuth rate limiter (10 requests per 5 minutes)
1266
1266
 
@@ -1277,7 +1277,7 @@ Handles the OAuth callback from GitHub after user authorization.
1277
1277
  - **GitHub Not Linked**: Returns error if GitHub account is not in `user_github` table
1278
1278
  - **Account Inactive**: Returns error if user account is deactivated
1279
1279
  - **Not Authorized**: Returns error if user is not allowed to access the application
1280
- - **GitHub Auth Error**: Returns error for any OAuth-related failures
1280
+ - **GitHub Auth Error**: Returns error for provider authentication failures
1281
1281
 
1282
1282
  **Success Flow:**
1283
1283
  ```
@@ -1474,7 +1474,7 @@ These cookies allow front-end UI to display a friendly name without making extra
1474
1474
  Checks if the authenticated user has the required role.
1475
1475
 
1476
1476
  **Parameters:**
1477
- - `requiredRole` (string) - Required role: `"SuperAdmin"`, `"NormalUser"`, `"Guest"`, or `"Any"`/`"any"`
1477
+ - `requiredRole` (string) - Required role: `"SuperAdmin"`, `"NormalUser"`, `"Guest"`, `"member"`, or `"Any"`/`"any"`
1478
1478
  - `notAllowed` (string, optional) - Role that is explicitly not allowed
1479
1479
 
1480
1480
  **Usage:**
package/docs/db.md CHANGED
@@ -12,7 +12,7 @@ The project uses a Postgres `ENUM` type for user roles:
12
12
  DO $$
13
13
  BEGIN
14
14
  IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'role') THEN
15
- CREATE TYPE role AS ENUM ('SuperAdmin', 'NormalUser', 'Guest');
15
+ CREATE TYPE role AS ENUM ('SuperAdmin', 'NormalUser', 'Guest', 'member');
16
16
  END IF;
17
17
  END
18
18
  $$;
@@ -85,7 +85,9 @@ CREATE TABLE IF NOT EXISTS user_github (
85
85
  user_name VARCHAR(50) REFERENCES "Users"("UserName"),
86
86
  github_id VARCHAR(255) UNIQUE,
87
87
  github_username VARCHAR(255),
88
- access_token TEXT,
88
+ installation_id BIGINT,
89
+ installation_target_type VARCHAR(32),
90
+ access_token VARCHAR(255),
89
91
  created_at TimeStamp WITH TIME ZONE DEFAULT NOW(),
90
92
  updated_at TimeStamp WITH TIME ZONE DEFAULT NOW()
91
93
  );
@@ -317,7 +319,7 @@ To add new users to the `Users` table, use the following SQL queries:
317
319
  - Replace `support` and `test` with the desired usernames.
318
320
  - For raw passwords: Replace `12345678` with the actual plain text passwords.
319
321
  - For encrypted passwords: Use the hashPassword function to generate the hash before inserting.
320
- - Adjust the `Role` values as needed (`SuperAdmin`, `NormalUser`, or `Guest`).
322
+ - Adjust the `Role` values as needed (`SuperAdmin`, `NormalUser`, `Guest`, or `member`).
321
323
  - Modify the `Active` and `HaveMailAccount` values as required.
322
324
 
323
325
  **Generating Encrypted Passwords:**
package/docs/db.sql CHANGED
@@ -2,7 +2,7 @@
2
2
  DO $$
3
3
  BEGIN
4
4
  IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'role') THEN
5
- CREATE TYPE role AS ENUM ('SuperAdmin', 'NormalUser', 'Guest');
5
+ CREATE TYPE role AS ENUM ('SuperAdmin', 'NormalUser', 'Guest', 'member');
6
6
  END IF;
7
7
  END
8
8
  $$;
@@ -49,11 +49,17 @@ CREATE TABLE IF NOT EXISTS user_github (
49
49
  user_name VARCHAR(50) REFERENCES "Users"("UserName"),
50
50
  github_id VARCHAR(255) UNIQUE,
51
51
  github_username VARCHAR(255),
52
+ installation_id BIGINT,
53
+ installation_target_type VARCHAR(32),
52
54
  access_token TEXT,
53
55
  created_at TimeStamp WITH TIME ZONE DEFAULT NOW(),
54
56
  updated_at TimeStamp WITH TIME ZONE DEFAULT NOW()
55
57
  );
56
58
 
59
+ ALTER TABLE user_github
60
+ ADD COLUMN IF NOT EXISTS installation_id BIGINT,
61
+ ADD COLUMN IF NOT EXISTS installation_target_type VARCHAR(32);
62
+
57
63
  -- Add indexes for performance optimization
58
64
  CREATE INDEX IF NOT EXISTS idx_user_github_github_id ON user_github (github_id);
59
65
  CREATE INDEX IF NOT EXISTS idx_user_github_user_name ON user_github (user_name);
@@ -88,6 +94,24 @@ CREATE TABLE IF NOT EXISTS "Sessions" (
88
94
  CREATE INDEX IF NOT EXISTS idx_sessions_username ON "Sessions" ("UserName");
89
95
  CREATE INDEX IF NOT EXISTS idx_sessions_user_created ON "Sessions" ("UserName", created_at);
90
96
 
97
+ -- Support expiry-based cleanup and validity checks
98
+ CREATE INDEX IF NOT EXISTS idx_sessions_username_expires
99
+ ON "Sessions" ("UserName", expires_at);
100
+
101
+ CREATE INDEX IF NOT EXISTS idx_sessions_expires
102
+ ON "Sessions" (expires_at)
103
+ WHERE expires_at IS NOT NULL;
104
+
105
+ -- Optional (Postgres 11+): covering indexes for hot-path lookups (validateSession)
106
+ -- These can enable index-only scans for the exact columns used in auth middleware.
107
+ CREATE INDEX IF NOT EXISTS idx_sessions_id_cover
108
+ ON "Sessions" (id)
109
+ INCLUDE ("UserName", expires_at);
110
+
111
+ CREATE INDEX IF NOT EXISTS idx_users_username_cover
112
+ ON "Users" ("UserName")
113
+ INCLUDE ("Active", "Role");
114
+
91
115
 
92
116
  CREATE TABLE IF NOT EXISTS "session" (
93
117
  sid VARCHAR(33) PRIMARY KEY NOT NULL,
package/docs/env.md CHANGED
@@ -95,14 +95,26 @@ This document describes the environment variables MBKAuth expects and keeps brie
95
95
  - Required: No
96
96
 
97
97
  - GITHUB_LOGIN_ENABLED / GOOGLE_LOGIN_ENABLED
98
- - Description: Enable OAuth providers.
98
+ - Description: Enable social login providers.
99
99
  - Default: `false`
100
- - If `true`, corresponding `*_CLIENT_ID` and `*_CLIENT_SECRET` are required.
100
+ - If `GOOGLE_LOGIN_ENABLED=true`, `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` are required.
101
+ - If `GITHUB_LOGIN_ENABLED=true`, GitHub App client credentials are required.
101
102
 
102
- - GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRET / GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET
103
- - Description: OAuth credentials (put in `mbkautheVar` preferred, or `mbkauthShared`).
104
- - Required when provider enabled.
105
- - Create Github OAuth App: https://github.com/settings/developers
103
+ - GITHUB_APP_SLUG
104
+ - Description: GitHub App slug (optional for login flow in this package; useful for install/link flows handled elsewhere).
105
+ - Required: No
106
+ - Create GitHub App: https://github.com/settings/apps
107
+
108
+ - GITHUB_APP_CLIENT_ID / GITHUB_APP_CLIENT_SECRET
109
+ - Description: GitHub App OAuth credentials used for user sign-in.
110
+ - Required when `GITHUB_LOGIN_ENABLED=true`.
111
+
112
+ - GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRET
113
+ - Description: Legacy fallback keys if app-prefixed keys are not provided.
114
+
115
+ - GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET
116
+ - Description: Google OAuth credentials.
117
+ - Required when `GOOGLE_LOGIN_ENABLED=true`.
106
118
  - Create Google OAuth: https://console.cloud.google.com/
107
119
 
108
120
  ---
package/index.d.ts CHANGED
@@ -55,8 +55,9 @@ declare module 'mbkauthe' {
55
55
  COOKIE_EXPIRE_TIME?: number;
56
56
  DEVICE_TRUST_DURATION_DAYS?: number;
57
57
  GITHUB_LOGIN_ENABLED?: 'true' | 'false' | 'f';
58
- GITHUB_CLIENT_ID?: string;
59
- GITHUB_CLIENT_SECRET?: string;
58
+ GITHUB_APP_SLUG?: string;
59
+ GITHUB_APP_CLIENT_ID?: string;
60
+ GITHUB_APP_CLIENT_SECRET?: string;
60
61
  GOOGLE_LOGIN_ENABLED?: 'true' | 'false' | 'f';
61
62
  GOOGLE_CLIENT_ID?: string;
62
63
  GOOGLE_CLIENT_SECRET?: string;
@@ -66,8 +67,9 @@ declare module 'mbkauthe' {
66
67
 
67
68
  export interface OAuthConfig {
68
69
  GITHUB_LOGIN_ENABLED?: 'true' | 'false' | 'f';
69
- GITHUB_CLIENT_ID?: string;
70
- GITHUB_CLIENT_SECRET?: string;
70
+ GITHUB_APP_SLUG?: string;
71
+ GITHUB_APP_CLIENT_ID?: string;
72
+ GITHUB_APP_CLIENT_SECRET?: string;
71
73
  GOOGLE_LOGIN_ENABLED?: 'true' | 'false' | 'f';
72
74
  GOOGLE_CLIENT_ID?: string;
73
75
  GOOGLE_CLIENT_SECRET?: string;
@@ -132,6 +134,8 @@ declare module 'mbkauthe' {
132
134
  user_name: string;
133
135
  github_id: string;
134
136
  github_username: string;
137
+ installation_id?: number;
138
+ installation_target_type?: string;
135
139
  access_token: string;
136
140
  created_at: Date;
137
141
  updated_at: Date;
@@ -238,6 +242,9 @@ declare module 'mbkauthe' {
238
242
  notAllowed?: UserRole
239
243
  ): AuthMiddleware;
240
244
 
245
+ export const sessVal: AuthMiddleware;
246
+ export const sessRole: AuthMiddleware;
247
+
241
248
  export const strictValidateSession: AuthMiddleware;
242
249
 
243
250
  export function strictValidateSessionAndRole(
package/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import express from "express";
2
- import router from "./lib/main.js";
3
- import { checkVersion } from "./lib/main.js";
2
+ import router, { checkVersion } from "./lib/main.js";
4
3
  import { engine } from "express-handlebars";
5
4
  import path from "path";
6
5
  import { fileURLToPath } from "url";
@@ -9,129 +8,95 @@ import { packageJson } from "#config.js";
9
8
 
10
9
  const __filename = fileURLToPath(import.meta.url);
11
10
  const __dirname = path.dirname(__filename);
11
+ const isDevMode = process.env.test === "dev";
12
+ const DEV_PORT = 5555;
13
+ const viewsPath = path.join(__dirname, "views");
14
+ const packageVersion = packageJson.version;
12
15
 
13
16
  const app = express();
14
17
 
15
18
  app.set("views", [
16
- path.join(__dirname, "views"),
19
+ viewsPath,
17
20
  path.join(__dirname, "node_modules/mbkauthe/views")
18
21
  ]);
19
22
 
23
+ const handlebarsHelpers = {
24
+ eq: (a, b) => a === b,
25
+ encodeURIComponent: (str) => encodeURIComponent(str),
26
+ formatTimestamp: (timestamp) => new Date(timestamp).toLocaleString(),
27
+ jsonStringify: (context) => JSON.stringify(context),
28
+ json: (obj) => JSON.stringify(obj, null, 2),
29
+ objectEntries: (obj) => {
30
+ if (!obj || typeof obj !== 'object') return [];
31
+ return Object.entries(obj).map(([key, value]) => ({ key, value }));
32
+ },
33
+ cacheBuster: () => `?v=${packageVersion}`
34
+ };
35
+
20
36
  app.engine("handlebars", engine({
21
37
  defaultLayout: false,
22
38
  cache: true,
23
39
  partialsDir: [
24
- path.join(__dirname, "views"),
40
+ viewsPath,
25
41
  path.join(__dirname, "node_modules/mbkauthe/views"),
26
42
  path.join(__dirname, "node_modules/mbkauthe/views/Error"),
27
43
  ],
28
- helpers: {
29
- eq: function (a, b) {
30
- return a === b;
31
- },
32
- encodeURIComponent: function (str) {
33
- return encodeURIComponent(str);
34
- },
35
- formatTimestamp: function (timestamp) {
36
- return new Date(timestamp).toLocaleString();
37
- },
38
- jsonStringify: function (context) {
39
- return JSON.stringify(context);
40
- },
41
- json: (obj) => JSON.stringify(obj, null, 2),
42
- objectEntries: function (obj) {
43
- if (!obj || typeof obj !== 'object') {
44
- return []; // Return an empty array if obj is undefined, null, or not an object
45
- }
46
- return Object.entries(obj).map(([key, value]) => ({ key, value }));
47
- },
48
- cacheBuster: function () {
49
- return "?v=" + packageJson.version;
50
- }
51
- }
52
-
44
+ helpers: handlebarsHelpers
53
45
  }));
54
46
 
55
47
  app.set("view engine", "handlebars");
56
-
57
48
  app.use(router);
58
49
 
59
- if (process.env.test === "dev") {
50
+ const renderDevError = (res, req, code, error, message, page, details) => renderError(res, req, {
51
+ layout: false,
52
+ code,
53
+ error,
54
+ message,
55
+ details,
56
+ pagename: "Home",
57
+ page,
58
+ });
59
+
60
+ if (isDevMode) {
60
61
  console.log("[mbkauthe] Dev mode is enabled. Starting server in dev mode.");
61
- const port = 5555;
62
- app.get(["/dashboard", "/home", "/"], (req, res) => {
63
- return res.redirect("/mbkauthe/");
64
- });
65
- app.get("/dev/2fa", (req, res) => {
66
- return renderPage(req, res, "pages/2fa.handlebars", {
67
- layout: false,
68
- pagename: "Two-Factor Authentication",
69
- page: "/home"
70
- });
71
- });
72
- app.get("/showmessage", (req, res) => {
73
- //uncomment line 26 on showmessage.handlebars for testing, after testing comment it back
74
- return renderPage(req, res, "showmessage", false);
75
- });
76
- app.get("/500", (req, res) => {
77
- return renderError(res, req, {
78
- layout: false,
79
- code: 500,
80
- error: "Internal Server Error",
81
- message: "Simulated 500 Error",
82
- details: "This is a simulated 500 error page for testing purposes.",
83
- pagename: "Home",
84
- page: "/mbkauthe/login",
85
- });
86
- });
62
+
63
+ app.get(["/dashboard", "/home", "/"], (req, res) => res.redirect("/mbkauthe/"));
64
+
65
+ app.get("/dev/2fa", (req, res) => renderPage(req, res, "pages/2fa.handlebars", false, {
66
+ pagename: "Two-Factor Authentication",
67
+ page: "/home"
68
+ }));
69
+
70
+ app.get("/showmessage", (req, res) => renderPage(req, res, "showmessage", false));
71
+
72
+ app.get("/500", (req, res) => renderDevError(res, req, 500,
73
+ "Internal Server Error", "Simulated 500 Error",
74
+ "/mbkauthe/login", "This is a simulated 500 error page for testing purposes."
75
+ ));
76
+
87
77
  app.use((req, res) => {
88
78
  console.log(`[mbkauthe] Path not found: ${req.method} ${req.url}`);
89
- return renderError(res, req, {
90
- layout: false,
91
- code: 404,
92
- error: "Not Found",
93
- message: "The requested page was not found.",
94
- pagename: "Home",
95
- page: "/mbkauthe/login",
96
- });
79
+ renderDevError(res, req, 404, "Not Found", "The requested page was not found.", "/mbkauthe/login");
97
80
  });
98
- app.listen(port, () => {
99
- console.log(`[mbkauthe] Server running on http://localhost:${port}`);
81
+
82
+ app.listen(DEV_PORT, () => {
83
+ console.log(`[mbkauthe] Server running on http://localhost:${DEV_PORT}`);
100
84
  });
101
85
  }
102
86
 
103
- if (process.env.test !== "dev") {
87
+ if (!isDevMode) {
104
88
  await checkVersion();
105
89
  }
106
90
 
107
- export {
108
- validateSession, validateApiSession, checkRolePermission,
109
- validateSessionAndRole, authenticate, reloadSessionUser,
110
- strictValidateSession, strictValidateSessionAndRole
111
- } from "./lib/middleware/auth.js";
112
- export {
113
- sessionConfig,
114
- corsMiddleware,
115
- sessionRestorationMiddleware,
116
- sessionCookieSyncMiddleware,
117
- requestContextMiddleware
118
- } from "./lib/middleware/index.js";
91
+ export * from "./lib/middleware/auth.js";
92
+ export * from "./lib/middleware/index.js";
119
93
  export { validateTokenScope } from "./lib/middleware/scopeValidator.js";
120
- export { renderError, getUserContext, renderPage, proxycall } from "#response.js";
94
+ export * from "#response.js";
121
95
  export { dblogin } from "#pool.js";
122
96
  export { getLatestVersion } from "./lib/routes/misc.js";
123
- export { checkTrustedDevice, completeLoginProcess } from "./lib/routes/auth.js";
124
- export {
125
- ErrorCodes, ErrorMessages, getErrorByCode,
126
- createErrorResponse, logError
127
- } from "./lib/utils/errors.js";
128
- export {
129
- encryptSessionId, decryptSessionId, cachedCookieOptions, cachedClearCookieOptions,
130
- DEVICE_TRUST_DURATION_DAYS, DEVICE_TRUST_DURATION_MS,
131
- generateDeviceToken, hashDeviceToken, getDeviceTokenCookieOptions,
132
- getCookieOptions, getClearCookieOptions, clearSessionCookies,
133
- readAccountListFromCookie, upsertAccountListCookie, removeAccountFromCookie, clearAccountListCookie
134
- } from "./lib/config/cookies.js";
135
- export { hashPassword, hashApiToken } from "./lib/config/security.js";
97
+ export * from "./lib/routes/auth.js";
98
+ export * from "./lib/utils/errors.js";
99
+ export * from "./lib/config/cookies.js";
100
+ export * from "./lib/config/security.js";
136
101
  export { mbkautheVar } from "#config.js";
137
102
  export default app;
@@ -64,7 +64,7 @@ function validateConfiguration() {
64
64
  const keysToCheck = [
65
65
  "APP_NAME", "DEVICE_TRUST_DURATION_DAYS", "EncPass", "Main_SECRET_TOKEN", "SESSION_SECRET_KEY",
66
66
  "IS_DEPLOYED", "LOGIN_DB", "MBKAUTH_TWO_FA_ENABLE", "COOKIE_EXPIRE_TIME", "DOMAIN", "loginRedirectURL",
67
- "GITHUB_LOGIN_ENABLED", "GITHUB_CLIENT_ID", "GITHUB_CLIENT_SECRET", "GOOGLE_LOGIN_ENABLED", "GOOGLE_CLIENT_ID",
67
+ "GITHUB_LOGIN_ENABLED", "GITHUB_APP_SLUG", "GITHUB_APP_CLIENT_ID", "GITHUB_APP_CLIENT_SECRET", "GITHUB_CLIENT_ID", "GITHUB_CLIENT_SECRET", "GOOGLE_LOGIN_ENABLED", "GOOGLE_CLIENT_ID",
68
68
  "GOOGLE_CLIENT_SECRET", "MAX_SESSIONS_PER_USER"
69
69
  ];
70
70
 
@@ -145,11 +145,14 @@ function validateConfiguration() {
145
145
 
146
146
  // Validate GitHub login configuration
147
147
  if (mbkautheVar.GITHUB_LOGIN_ENABLED === "true") {
148
- if (!mbkautheVar.GITHUB_CLIENT_ID || mbkautheVar.GITHUB_CLIENT_ID.trim() === '') {
149
- errors.push("mbkautheVar.GITHUB_CLIENT_ID is required when GITHUB_LOGIN_ENABLED is 'true'");
148
+ const hasGithubClientId = !!(mbkautheVar.GITHUB_APP_CLIENT_ID || mbkautheVar.GITHUB_CLIENT_ID);
149
+ const hasGithubClientSecret = !!(mbkautheVar.GITHUB_APP_CLIENT_SECRET || mbkautheVar.GITHUB_CLIENT_SECRET);
150
+
151
+ if (!hasGithubClientId) {
152
+ errors.push("mbkautheVar.GITHUB_APP_CLIENT_ID (or GITHUB_CLIENT_ID) is required when GITHUB_LOGIN_ENABLED is 'true'");
150
153
  }
151
- if (!mbkautheVar.GITHUB_CLIENT_SECRET || mbkautheVar.GITHUB_CLIENT_SECRET.trim() === '') {
152
- errors.push("mbkautheVar.GITHUB_CLIENT_SECRET is required when GITHUB_LOGIN_ENABLED is 'true'");
154
+ if (!hasGithubClientSecret) {
155
+ errors.push("mbkautheVar.GITHUB_APP_CLIENT_SECRET (or GITHUB_CLIENT_SECRET) is required when GITHUB_LOGIN_ENABLED is 'true'");
153
156
  }
154
157
  }
155
158