mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-26 04:05:54 +02:00
Adjust again for uncertian config
This commit is contained in:
parent
49f0f6ec7d
commit
77796e8a75
9 changed files with 18 additions and 13 deletions
|
@ -2,7 +2,7 @@ import path from "path";
|
||||||
import { fileURLToPath } from "url";
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
// This is a placeholder value replaced by the build process
|
// This is a placeholder value replaced by the build process
|
||||||
export const APP_VERSION = "1.8.0";
|
export const APP_VERSION = "1.9.0";
|
||||||
|
|
||||||
export const __FILENAME = fileURLToPath(import.meta.url);
|
export const __FILENAME = fileURLToPath(import.meta.url);
|
||||||
export const __DIRNAME = path.dirname(__FILENAME);
|
export const __DIRNAME = path.dirname(__FILENAME);
|
||||||
|
|
|
@ -44,7 +44,7 @@ export const configSchema = z
|
||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
id: z.string().optional(),
|
id: z.string().optional(),
|
||||||
secret: z.string().optional(),
|
secret: z.string().optional(),
|
||||||
endpoint: z.string().optional(),
|
endpoint: z.string().optional().default("https://pangolin.fossorial.io"),
|
||||||
redirect_endpoint: z.string().optional()
|
redirect_endpoint: z.string().optional()
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
|
|
|
@ -195,7 +195,7 @@ export async function verifyResourceSession(
|
||||||
if (config.isHybridMode()) {
|
if (config.isHybridMode()) {
|
||||||
endpoint = config.getRawConfig().hybrid?.redirect_endpoint || config.getRawConfig().hybrid?.endpoint || "";
|
endpoint = config.getRawConfig().hybrid?.redirect_endpoint || config.getRawConfig().hybrid?.endpoint || "";
|
||||||
} else {
|
} else {
|
||||||
endpoint = config.getRawConfig().app.dashboard_url;
|
endpoint = config.getRawConfig().app.dashboard_url!;
|
||||||
}
|
}
|
||||||
const redirectUrl = `${endpoint}/auth/resource/${encodeURIComponent(
|
const redirectUrl = `${endpoint}/auth/resource/${encodeURIComponent(
|
||||||
resource.resourceId
|
resource.resourceId
|
||||||
|
|
|
@ -81,7 +81,7 @@ export async function createOidcIdp(
|
||||||
autoProvision
|
autoProvision
|
||||||
} = parsedBody.data;
|
} = parsedBody.data;
|
||||||
|
|
||||||
const key = config.getRawConfig().server.secret;
|
const key = config.getRawConfig().server.secret!;
|
||||||
|
|
||||||
const encryptedSecret = encrypt(clientSecret, key);
|
const encryptedSecret = encrypt(clientSecret, key);
|
||||||
const encryptedClientId = encrypt(clientId, key);
|
const encryptedClientId = encrypt(clientId, key);
|
||||||
|
|
|
@ -89,7 +89,7 @@ export async function generateOidcUrl(
|
||||||
return scope.length > 0;
|
return scope.length > 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
const key = config.getRawConfig().server.secret;
|
const key = config.getRawConfig().server.secret!;
|
||||||
|
|
||||||
const decryptedClientId = decrypt(
|
const decryptedClientId = decrypt(
|
||||||
existingIdp.idpOidcConfig.clientId,
|
existingIdp.idpOidcConfig.clientId,
|
||||||
|
@ -124,7 +124,7 @@ export async function generateOidcUrl(
|
||||||
state,
|
state,
|
||||||
codeVerifier
|
codeVerifier
|
||||||
},
|
},
|
||||||
config.getRawConfig().server.secret
|
config.getRawConfig().server.secret!
|
||||||
);
|
);
|
||||||
|
|
||||||
res.cookie("p_oidc_state", stateJwt, {
|
res.cookie("p_oidc_state", stateJwt, {
|
||||||
|
|
|
@ -65,7 +65,7 @@ export async function getIdp(
|
||||||
return next(createHttpError(HttpCode.NOT_FOUND, "Idp not found"));
|
return next(createHttpError(HttpCode.NOT_FOUND, "Idp not found"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const key = config.getRawConfig().server.secret;
|
const key = config.getRawConfig().server.secret!;
|
||||||
|
|
||||||
if (idpRes.idp.type === "oidc") {
|
if (idpRes.idp.type === "oidc") {
|
||||||
const clientSecret = idpRes.idpOidcConfig!.clientSecret;
|
const clientSecret = idpRes.idpOidcConfig!.clientSecret;
|
||||||
|
|
|
@ -119,7 +119,7 @@ export async function updateOidcIdp(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const key = config.getRawConfig().server.secret;
|
const key = config.getRawConfig().server.secret!;
|
||||||
const encryptedSecret = clientSecret
|
const encryptedSecret = clientSecret
|
||||||
? encrypt(clientSecret, key)
|
? encrypt(clientSecret, key)
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
|
@ -96,7 +96,7 @@ export async function validateOidcCallback(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const key = config.getRawConfig().server.secret;
|
const key = config.getRawConfig().server.secret!;
|
||||||
|
|
||||||
const decryptedClientId = decrypt(
|
const decryptedClientId = decrypt(
|
||||||
existingIdp.idpOidcConfig.clientId,
|
existingIdp.idpOidcConfig.clientId,
|
||||||
|
@ -116,7 +116,7 @@ export async function validateOidcCallback(
|
||||||
|
|
||||||
const statePayload = jsonwebtoken.verify(
|
const statePayload = jsonwebtoken.verify(
|
||||||
storedState,
|
storedState,
|
||||||
config.getRawConfig().server.secret,
|
config.getRawConfig().server.secret!,
|
||||||
function (err, decoded) {
|
function (err, decoded) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.error("Error verifying state JWT", { err });
|
logger.error("Error verifying state JWT", { err });
|
||||||
|
|
|
@ -71,8 +71,8 @@ export const handleNewtRegisterMessage: MessageHandler = async (context) => {
|
||||||
.where(eq(sites.siteId, siteId))
|
.where(eq(sites.siteId, siteId))
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (!oldSite || !oldSite.exitNodeId) {
|
if (!oldSite) {
|
||||||
logger.warn("Site not found or does not have exit node");
|
logger.warn("Site not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,13 +137,18 @@ export const handleNewtRegisterMessage: MessageHandler = async (context) => {
|
||||||
.returning();
|
.returning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!exitNodeIdToQuery) {
|
||||||
|
logger.warn("No exit node ID to query");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const [exitNode] = await db
|
const [exitNode] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(exitNodes)
|
.from(exitNodes)
|
||||||
.where(eq(exitNodes.exitNodeId, exitNodeIdToQuery))
|
.where(eq(exitNodes.exitNodeId, exitNodeIdToQuery))
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (oldSite.pubKey && oldSite.pubKey !== publicKey) {
|
if (oldSite.pubKey && oldSite.pubKey !== publicKey && oldSite.exitNodeId) {
|
||||||
logger.info("Public key mismatch. Deleting old peer...");
|
logger.info("Public key mismatch. Deleting old peer...");
|
||||||
await deletePeer(oldSite.exitNodeId, oldSite.pubKey);
|
await deletePeer(oldSite.exitNodeId, oldSite.pubKey);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue