mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-11 21:26:37 +00:00
parse request ip in exchange session
This commit is contained in:
@@ -62,7 +62,26 @@ export async function exchangeSession(
|
|||||||
cleanHost = cleanHost.slice(0, -1 * matched.length);
|
cleanHost = cleanHost.slice(0, -1 * matched.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
const clientIp = requestIp?.split(":")[0];
|
const clientIp = requestIp
|
||||||
|
? (() => {
|
||||||
|
if (requestIp.startsWith("[") && requestIp.includes("]")) {
|
||||||
|
const ipv6Match = requestIp.match(/\[(.*?)\]/);
|
||||||
|
if (ipv6Match) {
|
||||||
|
return ipv6Match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const ipv4Pattern = /^(\d{1,3}\.){3}\d{1,3}/;
|
||||||
|
if (ipv4Pattern.test(requestIp)) {
|
||||||
|
const lastColonIndex = requestIp.lastIndexOf(":");
|
||||||
|
if (lastColonIndex !== -1) {
|
||||||
|
return requestIp.substring(0, lastColonIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return requestIp;
|
||||||
|
})()
|
||||||
|
: undefined;
|
||||||
|
|
||||||
const [resource] = await db
|
const [resource] = await db
|
||||||
.select()
|
.select()
|
||||||
|
|||||||
@@ -87,8 +87,6 @@ export default async function OrgAuthPage(props: {
|
|||||||
redirect(env.app.dashboardUrl);
|
redirect(env.app.dashboardUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(user, forceLogin);
|
|
||||||
|
|
||||||
if (user && !forceLogin) {
|
if (user && !forceLogin) {
|
||||||
let redirectToken: string | undefined;
|
let redirectToken: string | undefined;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ export function OrgSelectionForm() {
|
|||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
{t("orgAuthWhatsThis")}{" "}
|
{t("orgAuthWhatsThis")}{" "}
|
||||||
<Link
|
<Link
|
||||||
href="https://docs.pangolin.net/manage/identity-providers/add-an-idp"
|
href="https://docs.pangolin.net/manage/organizations/org-id"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="underline"
|
className="underline"
|
||||||
|
|||||||
Reference in New Issue
Block a user