mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-26 20:25:42 +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";
|
||||
|
||||
// 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 __DIRNAME = path.dirname(__FILENAME);
|
||||
|
|
|
@ -44,7 +44,7 @@ export const configSchema = z
|
|||
name: z.string().optional(),
|
||||
id: 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()
|
||||
})
|
||||
.optional(),
|
||||
|
|
|
@ -195,7 +195,7 @@ export async function verifyResourceSession(
|
|||
if (config.isHybridMode()) {
|
||||
endpoint = config.getRawConfig().hybrid?.redirect_endpoint || config.getRawConfig().hybrid?.endpoint || "";
|
||||
} else {
|
||||
endpoint = config.getRawConfig().app.dashboard_url;
|
||||
endpoint = config.getRawConfig().app.dashboard_url!;
|
||||
}
|
||||
const redirectUrl = `${endpoint}/auth/resource/${encodeURIComponent(
|
||||
resource.resourceId
|
||||
|
|
|
@ -81,7 +81,7 @@ export async function createOidcIdp(
|
|||
autoProvision
|
||||
} = parsedBody.data;
|
||||
|
||||
const key = config.getRawConfig().server.secret;
|
||||
const key = config.getRawConfig().server.secret!;
|
||||
|
||||
const encryptedSecret = encrypt(clientSecret, key);
|
||||
const encryptedClientId = encrypt(clientId, key);
|
||||
|
|
|
@ -89,7 +89,7 @@ export async function generateOidcUrl(
|
|||
return scope.length > 0;
|
||||
});
|
||||
|
||||
const key = config.getRawConfig().server.secret;
|
||||
const key = config.getRawConfig().server.secret!;
|
||||
|
||||
const decryptedClientId = decrypt(
|
||||
existingIdp.idpOidcConfig.clientId,
|
||||
|
@ -124,7 +124,7 @@ export async function generateOidcUrl(
|
|||
state,
|
||||
codeVerifier
|
||||
},
|
||||
config.getRawConfig().server.secret
|
||||
config.getRawConfig().server.secret!
|
||||
);
|
||||
|
||||
res.cookie("p_oidc_state", stateJwt, {
|
||||
|
|
|
@ -65,7 +65,7 @@ export async function getIdp(
|
|||
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") {
|
||||
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
|
||||
? encrypt(clientSecret, key)
|
||||
: undefined;
|
||||
|
|
|
@ -96,7 +96,7 @@ export async function validateOidcCallback(
|
|||
);
|
||||
}
|
||||
|
||||
const key = config.getRawConfig().server.secret;
|
||||
const key = config.getRawConfig().server.secret!;
|
||||
|
||||
const decryptedClientId = decrypt(
|
||||
existingIdp.idpOidcConfig.clientId,
|
||||
|
@ -116,7 +116,7 @@ export async function validateOidcCallback(
|
|||
|
||||
const statePayload = jsonwebtoken.verify(
|
||||
storedState,
|
||||
config.getRawConfig().server.secret,
|
||||
config.getRawConfig().server.secret!,
|
||||
function (err, decoded) {
|
||||
if (err) {
|
||||
logger.error("Error verifying state JWT", { err });
|
||||
|
|
|
@ -71,8 +71,8 @@ export const handleNewtRegisterMessage: MessageHandler = async (context) => {
|
|||
.where(eq(sites.siteId, siteId))
|
||||
.limit(1);
|
||||
|
||||
if (!oldSite || !oldSite.exitNodeId) {
|
||||
logger.warn("Site not found or does not have exit node");
|
||||
if (!oldSite) {
|
||||
logger.warn("Site not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -137,13 +137,18 @@ export const handleNewtRegisterMessage: MessageHandler = async (context) => {
|
|||
.returning();
|
||||
}
|
||||
|
||||
if (!exitNodeIdToQuery) {
|
||||
logger.warn("No exit node ID to query");
|
||||
return;
|
||||
}
|
||||
|
||||
const [exitNode] = await db
|
||||
.select()
|
||||
.from(exitNodes)
|
||||
.where(eq(exitNodes.exitNodeId, exitNodeIdToQuery))
|
||||
.limit(1);
|
||||
|
||||
if (oldSite.pubKey && oldSite.pubKey !== publicKey) {
|
||||
if (oldSite.pubKey && oldSite.pubKey !== publicKey && oldSite.exitNodeId) {
|
||||
logger.info("Public key mismatch. Deleting old peer...");
|
||||
await deletePeer(oldSite.exitNodeId, oldSite.pubKey);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue