Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ result/
.aider*
.env
.zellij_layout.kdl
docker-compose-dev.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/defguard_core/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub mod openid_clients;
pub mod openid_flow;
pub(crate) mod pagination;
pub mod proxy;
pub mod resource_display;
pub mod session_info;
pub mod settings;
pub(crate) mod ssh_authorized_keys;
Expand Down
25 changes: 25 additions & 0 deletions crates/defguard_core/src/handlers/resource_display.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use axum::{Extension, http::StatusCode};
use serde::Serialize;

use super::{ApiResponse, ApiResult};
use crate::auth::AdminRole;

#[derive(Serialize, Debug)]
pub struct ResourceDisplay {
pub id: i64,
Comment thread
filipslezaklab marked this conversation as resolved.
pub display: String,
}
Comment thread
filipslezaklab marked this conversation as resolved.

pub async fn get_locations_display(
_admin: AdminRole,
Extension(pool): Extension<sqlx::PgPool>,
) -> ApiResult {
let resources = sqlx::query_as!(
ResourceDisplay,
"SELECT id, name AS display FROM wireguard_network ORDER BY id"
)
Comment thread
filipslezaklab marked this conversation as resolved.
.fetch_all(&pool)
.await?;

Ok(ApiResponse::json(resources, StatusCode::OK))
}
2 changes: 2 additions & 0 deletions crates/defguard_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ use crate::{
userinfo,
},
proxy::{delete_proxy, proxy_details, proxy_list, update_proxy},
resource_display::get_locations_display,
settings::{
get_settings, get_settings_essentials, patch_settings, set_default_branding,
test_ldap_settings, update_settings,
Expand Down Expand Up @@ -533,6 +534,7 @@ pub fn build_webapp(
post(start_network_device_setup_for_device),
)
.route("/network", post(create_network).get(list_networks))
.route("/network/display", get(get_locations_display))
.route("/network/import", post(import_network))
.route("/network/stats", get(locations_overview_stats))
.route("/network/gateways", get(all_gateways_status))
Expand Down
8 changes: 7 additions & 1 deletion crates/defguard_setup/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use defguard_core::{
mfa_enable, recovery_code, request_email_mfa_code, totp_code, totp_enable, totp_secret,
webauthn_end, webauthn_finish, webauthn_init, webauthn_start,
},
component_setup::setup_proxy_tls_stream,
component_setup::{setup_gateway_tls_stream, setup_proxy_tls_stream},
resource_display::get_locations_display,
session_info::get_session_info,
settings::{get_settings, get_settings_essentials, patch_settings},
wireguard::list_networks,
Expand Down Expand Up @@ -121,6 +122,11 @@ pub fn build_migration_webapp(
.route("/auth/email/verify", post(email_mfa_code))
.route("/auth/recovery", post(recovery_code))
.route("/network", get(list_networks))
.route("/network/display", get(get_locations_display))
.route(
"/network/{network_id}/gateways/setup",
get(setup_gateway_tls_stream),
)
.nest(
"/migration",
Router::new()
Expand Down
6 changes: 5 additions & 1 deletion crates/defguard_setup/src/setup_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ use defguard_common::VERSION;
use defguard_core::{
auth::failed_login::FailedLoginMap,
handle_404,
handlers::{component_setup::setup_proxy_tls_stream, settings::get_settings_essentials},
handlers::{
component_setup::setup_proxy_tls_stream, resource_display::get_locations_display,
settings::get_settings_essentials,
},
health_check,
};
use defguard_web_ui::{index, svg, web_asset};
Expand Down Expand Up @@ -45,6 +48,7 @@ pub fn build_setup_webapp(pool: PgPool, version: Version, setup_shutdown_tx: Sen
.route("/health", get(health_check))
.route("/settings_essentials", get(get_settings_essentials))
.route("/session-info", get(get_session_info))
.route("/network/display", get(get_locations_display))
.route("/wizard", get(get_wizard_state))
.route("/proxy/setup/stream", get(setup_proxy_tls_stream))
.nest(
Expand Down
8 changes: 7 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
- db

gateway:
image: ghcr.io/defguard/gateway:latest
image: ghcr.io/defguard/gateway
environment:
DEFGUARD_GRPC_URL: http://core:50055
DEFGUARD_STATS_PERIOD: 60
Expand All @@ -35,6 +35,7 @@ services:
ports:
# WireGuard endpoint
- "50051:50051/udp"
- "50066:50066"
depends_on:
Comment thread
filipslezaklab marked this conversation as resolved.
- core
cap_add:
Expand All @@ -50,6 +51,11 @@ services:
- ./.volumes/db:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U defguard"]
interval: 3s
timeout: 5s
retries: 5
Comment thread
filipslezaklab marked this conversation as resolved.

device:
build:
Expand Down
29 changes: 15 additions & 14 deletions web/src/pages/AddLocationPage/steps/AddLocationAccessStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { useQuery } from '@tanstack/react-query';
import { useCallback, useMemo, useState } from 'react';
import { m } from '../../../paraglide/messages';
import api from '../../../shared/api/api';
import { Controls } from '../../../shared/components/Controls/Controls';
import { SelectionSection } from '../../../shared/components/SelectionSection/SelectionSection';
import type { SelectionOption } from '../../../shared/components/SelectionSection/type';
import { WizardCard } from '../../../shared/components/wizard/WizardCard/WizardCard';
import { Button } from '../../../shared/defguard-ui/components/Button/Button';
import { ModalControls } from '../../../shared/defguard-ui/components/ModalControls/ModalControls';
import { AddLocationPageStep } from '../types';
import { useAddLocationStore } from '../useAddLocationStore';

Expand Down Expand Up @@ -44,18 +44,7 @@ export const AddLocationAccessStep = () => {
selection={selected}
onChange={setSelected}
/>
<ModalControls
submitProps={{
text: m.controls_continue(),
testId: 'acl-continue',
onClick: () => {
saveChanges(selected);
useAddLocationStore.setState({
activeStep: AddLocationPageStep.Firewall,
});
},
}}
>
<Controls>
<Button
variant="outlined"
text={m.controls_back()}
Expand All @@ -66,7 +55,19 @@ export const AddLocationAccessStep = () => {
});
}}
/>
</ModalControls>
<div className="right">
<Button
text={m.controls_continue()}
testId="acl-continue"
onClick={() => {
saveChanges(selected);
useAddLocationStore.setState({
activeStep: AddLocationPageStep.Firewall,
});
}}
/>
</div>
</Controls>
</WizardCard>
);
};
25 changes: 13 additions & 12 deletions web/src/pages/AddLocationPage/steps/AddLocationFirewallStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { useCallback, useMemo, useState } from 'react';
import { m } from '../../../paraglide/messages';
import api from '../../../shared/api/api';
import { ActionCard } from '../../../shared/components/ActionCard/ActionCard';
import { Controls } from '../../../shared/components/Controls/Controls';
import { WizardCard } from '../../../shared/components/wizard/WizardCard/WizardCard';
import { externalLink } from '../../../shared/constants';
import { Button } from '../../../shared/defguard-ui/components/Button/Button';
import { Checkbox } from '../../../shared/defguard-ui/components/Checkbox/Checkbox';
import { Divider } from '../../../shared/defguard-ui/components/Divider/Divider';
import { ModalControls } from '../../../shared/defguard-ui/components/ModalControls/ModalControls';
import { Radio } from '../../../shared/defguard-ui/components/Radio/Radio';
import { SizedBox } from '../../../shared/defguard-ui/components/SizedBox/SizedBox';
import { ThemeSpacing } from '../../../shared/defguard-ui/types';
Expand Down Expand Up @@ -145,16 +145,7 @@ export const AddLocationFirewallStep = () => {
}}
/>
</ActionCard>
<ModalControls
submitProps={{
testId: 'create-location',
text: 'Create location',
loading: isPending,
onClick: () => {
handleSubmit();
},
}}
>
<Controls>
<Button
variant="outlined"
text={m.controls_back()}
Expand All @@ -166,7 +157,17 @@ export const AddLocationFirewallStep = () => {
});
}}
/>
</ModalControls>
<div className="right">
<Button
testId="create-location"
text="Create location"
loading={isPending}
onClick={() => {
handleSubmit();
}}
/>
</div>
</Controls>
</WizardCard>
);
};
23 changes: 12 additions & 11 deletions web/src/pages/AddLocationPage/steps/AddLocationInternalVpnStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { useMemo } from 'react';
import z from 'zod';
import { useShallow } from 'zustand/react/shallow';
import { m } from '../../../paraglide/messages';
import { Controls } from '../../../shared/components/Controls/Controls';
import { DescriptionBlock } from '../../../shared/components/DescriptionBlock/DescriptionBlock';
import { WizardCard } from '../../../shared/components/wizard/WizardCard/WizardCard';
import { Button } from '../../../shared/defguard-ui/components/Button/Button';
import { ModalControls } from '../../../shared/defguard-ui/components/ModalControls/ModalControls';
import { SizedBox } from '../../../shared/defguard-ui/components/SizedBox/SizedBox';
import { Toggle } from '../../../shared/defguard-ui/components/Toggle/Toggle';
import { TooltipContent } from '../../../shared/defguard-ui/providers/tooltip/TooltipContent';
Expand Down Expand Up @@ -119,15 +119,7 @@ export const AddLocationInternalVpnStep = () => {
<form.AppField name="dns">
{(field) => <field.FormInput label={'DNS'} />}
</form.AppField>
<ModalControls
submitProps={{
text: m.controls_continue(),
testId: 'continue',
onClick: () => {
form.handleSubmit();
},
}}
>
<Controls>
<Button
variant="outlined"
text={m.controls_back()}
Expand All @@ -138,7 +130,16 @@ export const AddLocationInternalVpnStep = () => {
});
}}
/>
</ModalControls>
<div className="right">
<Button
text={m.controls_continue()}
testId="continue"
onClick={() => {
form.handleSubmit();
}}
/>
</div>
</Controls>
</form.AppForm>
</form>
</WizardCard>
Expand Down
25 changes: 13 additions & 12 deletions web/src/pages/AddLocationPage/steps/AddLocationMfaStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import z from 'zod';
import { m } from '../../../paraglide/messages';
import { LocationMfaMode, type NetworkLocation } from '../../../shared/api/types';
import { businessBadgeProps } from '../../../shared/components/badges/BusinessBadge';
import { Controls } from '../../../shared/components/Controls/Controls';
import { WizardCard } from '../../../shared/components/wizard/WizardCard/WizardCard';
import { Button } from '../../../shared/defguard-ui/components/Button/Button';
import { Input } from '../../../shared/defguard-ui/components/Input/Input';
import { InteractiveBlock } from '../../../shared/defguard-ui/components/InteractiveBlock/InteractiveBlock';
import { ModalControls } from '../../../shared/defguard-ui/components/ModalControls/ModalControls';
import { SizedBox } from '../../../shared/defguard-ui/components/SizedBox/SizedBox';
import { ThemeSpacing } from '../../../shared/defguard-ui/types';
import { isPresent } from '../../../shared/defguard-ui/utils/isPresent';
Expand Down Expand Up @@ -97,16 +97,7 @@ export const AddLocationMfaStep = () => {
/>
</>
)}
<ModalControls
submitProps={{
text: m.controls_continue(),
testId: 'finish',
disabled: isPresent(error),
onClick: () => {
handleSubmit();
},
}}
>
<Controls>
<Button
variant="outlined"
text={m.controls_back()}
Expand All @@ -118,7 +109,17 @@ export const AddLocationMfaStep = () => {
});
}}
/>
</ModalControls>
<div className="right">
<Button
text={m.controls_continue()}
testId="finish"
disabled={isPresent(error)}
onClick={() => {
handleSubmit();
}}
/>
</div>
</Controls>
</WizardCard>
);
};
Loading
Loading