mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-24 19:25:40 +02:00
Rename hybrid to managed
This commit is contained in:
parent
5ff5660db3
commit
60d8831399
17 changed files with 39 additions and 39 deletions
|
@ -5,7 +5,7 @@ gerbil:
|
|||
start_port: 51820
|
||||
base_endpoint: "{{.DashboardDomain}}"
|
||||
{{if .HybridMode}}
|
||||
hybrid:
|
||||
managed:
|
||||
id: "{{.HybridId}}"
|
||||
secret: "{{.HybridSecret}}"
|
||||
|
||||
|
|
|
@ -623,5 +623,5 @@ func checkIsPangolinInstalledWithHybrid() bool {
|
|||
}
|
||||
|
||||
// Check for hybrid section
|
||||
return bytes.Contains(content, []byte("hybrid:"))
|
||||
return bytes.Contains(content, []byte("managed:"))
|
||||
}
|
||||
|
|
|
@ -65,9 +65,9 @@ export async function validateResourceSessionToken(
|
|||
token: string,
|
||||
resourceId: number
|
||||
): Promise<ResourceSessionValidationResult> {
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
try {
|
||||
const response = await axios.post(`${config.getRawConfig().hybrid?.endpoint}/api/v1/hybrid/resource/${resourceId}/session/validate`, {
|
||||
const response = await axios.post(`${config.getRawConfig().managed?.endpoint}/api/v1/hybrid/resource/${resourceId}/session/validate`, {
|
||||
token: token
|
||||
}, await tokenManager.getAuthHeader());
|
||||
return response.data.data;
|
||||
|
|
|
@ -37,9 +37,9 @@ export type UserSessionWithUser = {
|
|||
export async function getResourceByDomain(
|
||||
domain: string
|
||||
): Promise<ResourceWithAuth | null> {
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
try {
|
||||
const response = await axios.get(`${config.getRawConfig().hybrid?.endpoint}/api/v1/hybrid/resource/domain/${domain}`, await tokenManager.getAuthHeader());
|
||||
const response = await axios.get(`${config.getRawConfig().managed?.endpoint}/api/v1/hybrid/resource/domain/${domain}`, await tokenManager.getAuthHeader());
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
|
@ -89,9 +89,9 @@ export async function getResourceByDomain(
|
|||
export async function getUserSessionWithUser(
|
||||
userSessionId: string
|
||||
): Promise<UserSessionWithUser | null> {
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
try {
|
||||
const response = await axios.get(`${config.getRawConfig().hybrid?.endpoint}/api/v1/hybrid/session/${userSessionId}`, await tokenManager.getAuthHeader());
|
||||
const response = await axios.get(`${config.getRawConfig().managed?.endpoint}/api/v1/hybrid/session/${userSessionId}`, await tokenManager.getAuthHeader());
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
|
@ -130,9 +130,9 @@ export async function getUserSessionWithUser(
|
|||
* Get user organization role
|
||||
*/
|
||||
export async function getUserOrgRole(userId: string, orgId: string) {
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
try {
|
||||
const response = await axios.get(`${config.getRawConfig().hybrid?.endpoint}/api/v1/hybrid/user/${userId}/org/${orgId}/role`, await tokenManager.getAuthHeader());
|
||||
const response = await axios.get(`${config.getRawConfig().managed?.endpoint}/api/v1/hybrid/user/${userId}/org/${orgId}/role`, await tokenManager.getAuthHeader());
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
|
@ -169,9 +169,9 @@ export async function getUserOrgRole(userId: string, orgId: string) {
|
|||
* Check if role has access to resource
|
||||
*/
|
||||
export async function getRoleResourceAccess(resourceId: number, roleId: number) {
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
try {
|
||||
const response = await axios.get(`${config.getRawConfig().hybrid?.endpoint}/api/v1/hybrid/role/${roleId}/resource/${resourceId}/access`, await tokenManager.getAuthHeader());
|
||||
const response = await axios.get(`${config.getRawConfig().managed?.endpoint}/api/v1/hybrid/role/${roleId}/resource/${resourceId}/access`, await tokenManager.getAuthHeader());
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
|
@ -208,9 +208,9 @@ export async function getRoleResourceAccess(resourceId: number, roleId: number)
|
|||
* Check if user has direct access to resource
|
||||
*/
|
||||
export async function getUserResourceAccess(userId: string, resourceId: number) {
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
try {
|
||||
const response = await axios.get(`${config.getRawConfig().hybrid?.endpoint}/api/v1/hybrid/user/${userId}/resource/${resourceId}/access`, await tokenManager.getAuthHeader());
|
||||
const response = await axios.get(`${config.getRawConfig().managed?.endpoint}/api/v1/hybrid/user/${userId}/resource/${resourceId}/access`, await tokenManager.getAuthHeader());
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
|
@ -247,9 +247,9 @@ export async function getUserResourceAccess(userId: string, resourceId: number)
|
|||
* Get resource rules for a given resource
|
||||
*/
|
||||
export async function getResourceRules(resourceId: number): Promise<ResourceRule[]> {
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
try {
|
||||
const response = await axios.get(`${config.getRawConfig().hybrid?.endpoint}/api/v1/hybrid/resource/${resourceId}/rules`, await tokenManager.getAuthHeader());
|
||||
const response = await axios.get(`${config.getRawConfig().managed?.endpoint}/api/v1/hybrid/resource/${resourceId}/rules`, await tokenManager.getAuthHeader());
|
||||
return response.data.data;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
|
|
|
@ -6,7 +6,7 @@ import logger from "@server/logger";
|
|||
import SMTPTransport from "nodemailer/lib/smtp-transport";
|
||||
|
||||
function createEmailClient() {
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
// LETS NOT WORRY ABOUT EMAILS IN HYBRID
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ export async function createHybridClientServer() {
|
|||
// Create client
|
||||
const client = createWebSocketClient(
|
||||
token,
|
||||
config.getRawConfig().hybrid!.endpoint!,
|
||||
config.getRawConfig().managed!.endpoint!,
|
||||
{
|
||||
reconnectInterval: 5000,
|
||||
pingInterval: 30000,
|
||||
|
|
|
@ -27,7 +27,7 @@ async function startServers() {
|
|||
|
||||
let hybridClientServer;
|
||||
let nextServer;
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
hybridClientServer = await createHybridClientServer();
|
||||
} else {
|
||||
nextServer = await createNextServer();
|
||||
|
|
|
@ -96,8 +96,8 @@ export class Config {
|
|||
if (!this.rawConfig) {
|
||||
throw new Error("Config not loaded. Call load() first.");
|
||||
}
|
||||
if (this.rawConfig.hybrid) {
|
||||
// LETS NOT WORRY ABOUT THE SERVER SECRET WHEN HYBRID
|
||||
if (this.rawConfig.managed) {
|
||||
// LETS NOT WORRY ABOUT THE SERVER SECRET WHEN MANAGED
|
||||
return;
|
||||
}
|
||||
license.setServerSecret(this.rawConfig.server.secret!);
|
||||
|
@ -149,8 +149,8 @@ export class Config {
|
|||
return false;
|
||||
}
|
||||
|
||||
public isHybridMode() {
|
||||
return typeof this.rawConfig?.hybrid === "object";
|
||||
public isManagedMode() {
|
||||
return typeof this.rawConfig?.managed === "object";
|
||||
}
|
||||
|
||||
public async checkSupporterKey() {
|
||||
|
|
|
@ -39,7 +39,7 @@ export const configSchema = z
|
|||
anonymous_usage: true
|
||||
}
|
||||
}),
|
||||
hybrid: z
|
||||
managed: z
|
||||
.object({
|
||||
name: z.string().optional(),
|
||||
id: z.string().optional(),
|
||||
|
@ -306,7 +306,7 @@ export const configSchema = z
|
|||
return true;
|
||||
}
|
||||
// If hybrid is defined, domains are not required
|
||||
if (data.hybrid) {
|
||||
if (data.managed) {
|
||||
return true;
|
||||
}
|
||||
if (keys.length === 0) {
|
||||
|
@ -321,7 +321,7 @@ export const configSchema = z
|
|||
.refine(
|
||||
(data) => {
|
||||
// If hybrid is defined, server secret is not required
|
||||
if (data.hybrid) {
|
||||
if (data.managed) {
|
||||
return true;
|
||||
}
|
||||
// If hybrid is not defined, server secret must be defined
|
||||
|
@ -334,7 +334,7 @@ export const configSchema = z
|
|||
.refine(
|
||||
(data) => {
|
||||
// If hybrid is defined, dashboard_url is not required
|
||||
if (data.hybrid) {
|
||||
if (data.managed) {
|
||||
return true;
|
||||
}
|
||||
// If hybrid is not defined, dashboard_url must be defined
|
||||
|
|
|
@ -24,7 +24,7 @@ export async function getValidCertificatesForDomainsHybrid(domains: Set<string>)
|
|||
|
||||
try {
|
||||
const response = await axios.get(
|
||||
`${config.getRawConfig().hybrid?.endpoint}/api/v1/hybrid/certificates/domains`,
|
||||
`${config.getRawConfig().managed?.endpoint}/api/v1/hybrid/certificates/domains`,
|
||||
{
|
||||
params: {
|
||||
domains: domainArray
|
||||
|
|
|
@ -18,7 +18,7 @@ export const proxyToRemote = async (
|
|||
endpoint: string
|
||||
): Promise<any> => {
|
||||
try {
|
||||
const remoteUrl = `${config.getRawConfig().hybrid?.endpoint?.replace(/\/$/, '')}/api/v1/${endpoint}`;
|
||||
const remoteUrl = `${config.getRawConfig().managed?.endpoint?.replace(/\/$/, '')}/api/v1/${endpoint}`;
|
||||
|
||||
logger.debug(`Proxying request to remote server: ${remoteUrl}`);
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ export class TokenManager {
|
|||
this.isRefreshing = true;
|
||||
|
||||
try {
|
||||
const hybridConfig = config.getRawConfig().hybrid;
|
||||
const hybridConfig = config.getRawConfig().managed;
|
||||
|
||||
if (
|
||||
!hybridConfig?.id ||
|
||||
|
|
|
@ -281,7 +281,7 @@ export class TraefikConfigManager {
|
|||
|
||||
if (this.shouldFetchCertificates(domains)) {
|
||||
// Get valid certificates for active domains
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
validCertificates =
|
||||
await getValidCertificatesForDomainsHybrid(domains);
|
||||
} else {
|
||||
|
@ -383,9 +383,9 @@ export class TraefikConfigManager {
|
|||
} | null> {
|
||||
let traefikConfig;
|
||||
try {
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
const resp = await axios.get(
|
||||
`${config.getRawConfig().hybrid?.endpoint}/api/v1/hybrid/traefik-config`,
|
||||
`${config.getRawConfig().managed?.endpoint}/api/v1/hybrid/traefik-config`,
|
||||
await tokenManager.getAuthHeader()
|
||||
);
|
||||
|
||||
|
|
|
@ -192,8 +192,8 @@ export async function verifyResourceSession(
|
|||
}
|
||||
|
||||
let endpoint: string;
|
||||
if (config.isHybridMode()) {
|
||||
endpoint = config.getRawConfig().hybrid?.redirect_endpoint || config.getRawConfig().hybrid?.endpoint || "";
|
||||
if (config.isManagedMode()) {
|
||||
endpoint = config.getRawConfig().managed?.redirect_endpoint || config.getRawConfig().managed?.endpoint || "";
|
||||
} else {
|
||||
endpoint = config.getRawConfig().app.dashboard_url!;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ export async function getConfig(
|
|||
}
|
||||
|
||||
// STOP HERE IN HYBRID MODE
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
req.body = {
|
||||
...req.body,
|
||||
endpoint: exitNode[0].endpoint,
|
||||
|
|
|
@ -51,7 +51,7 @@ internalRouter.get("/idp/:idpId", idp.getIdp);
|
|||
const gerbilRouter = Router();
|
||||
internalRouter.use("/gerbil", gerbilRouter);
|
||||
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
// Use proxy router to forward requests to remote cloud server
|
||||
// Proxy endpoints for each gerbil route
|
||||
gerbilRouter.post("/receive-bandwidth", (req, res, next) =>
|
||||
|
@ -90,7 +90,7 @@ internalRouter.use("/badger", badgerRouter);
|
|||
|
||||
badgerRouter.post("/verify-session", badger.verifyResourceSession);
|
||||
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
badgerRouter.post("/exchange-session", (req, res, next) =>
|
||||
proxyToRemote(req, res, next, "hybrid/badger/exchange-session")
|
||||
);
|
||||
|
|
|
@ -23,7 +23,7 @@ function generateId(length: number): string {
|
|||
}
|
||||
|
||||
export async function ensureSetupToken() {
|
||||
if (config.isHybridMode()) {
|
||||
if (config.isManagedMode()) {
|
||||
// LETS NOT WORRY ABOUT THE SERVER SECRET WHEN HYBRID
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue