mirror of
https://github.com/samsonjs/vibetunnel.git
synced 2026-04-27 15:17:38 +00:00
bypass localhost / route
This commit is contained in:
parent
17cffe7424
commit
ef9a757608
2 changed files with 12 additions and 1 deletions
|
|
@ -10,6 +10,7 @@ interface AuthRoutesConfig {
|
||||||
enableSSHKeys?: boolean;
|
enableSSHKeys?: boolean;
|
||||||
disallowUserPassword?: boolean;
|
disallowUserPassword?: boolean;
|
||||||
noAuth?: boolean;
|
noAuth?: boolean;
|
||||||
|
allowLocalBypass?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createAuthRoutes(config: AuthRoutesConfig): Router {
|
export function createAuthRoutes(config: AuthRoutesConfig): Router {
|
||||||
|
|
@ -174,10 +175,19 @@ export function createAuthRoutes(config: AuthRoutesConfig): Router {
|
||||||
*/
|
*/
|
||||||
router.get('/config', (req, res) => {
|
router.get('/config', (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
// Check if this is a local request and local bypass is enabled
|
||||||
|
const clientIp = req.ip || req.socket.remoteAddress || '';
|
||||||
|
const localIPs = ['127.0.0.1', '::1', '::ffff:127.0.0.1', 'localhost'];
|
||||||
|
const isLocalRequest =
|
||||||
|
localIPs.includes(clientIp) && !req.headers['x-forwarded-for'] && !req.headers['x-real-ip'];
|
||||||
|
|
||||||
|
// If local bypass is enabled and this is a local request, report as noAuth
|
||||||
|
const effectiveNoAuth = config.noAuth || (config.allowLocalBypass && isLocalRequest);
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
enableSSHKeys: config.enableSSHKeys || false,
|
enableSSHKeys: config.enableSSHKeys || false,
|
||||||
disallowUserPassword: config.disallowUserPassword || false,
|
disallowUserPassword: config.disallowUserPassword || false,
|
||||||
noAuth: config.noAuth || false,
|
noAuth: effectiveNoAuth,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error getting auth config:', error);
|
console.error('Error getting auth config:', error);
|
||||||
|
|
|
||||||
|
|
@ -479,6 +479,7 @@ export async function createApp(): Promise<AppInstance> {
|
||||||
enableSSHKeys: config.enableSSHKeys,
|
enableSSHKeys: config.enableSSHKeys,
|
||||||
disallowUserPassword: config.disallowUserPassword,
|
disallowUserPassword: config.disallowUserPassword,
|
||||||
noAuth: config.noAuth,
|
noAuth: config.noAuth,
|
||||||
|
allowLocalBypass: config.allowLocalBypass,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
logger.debug('Mounted authentication routes');
|
logger.debug('Mounted authentication routes');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue