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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
target/
web/node_modules
web/dist
webnext/node_modules
webnext/dist
.volumes/
.github/
docs/
6 changes: 3 additions & 3 deletions .github/workflows/lint-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ jobs:
with:
node-version: 24
- name: install deps
working-directory: ./web
working-directory: ./webnext
run: |
npm i -g pnpm
pnpm i --frozen-lockfile
- name: Lint
working-directory: ./web
working-directory: ./webnext
run: pnpm lint
- name: Audit
working-directory: ./web
working-directory: ./webnext
run: pnpm audit --prod
8 changes: 5 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,20 @@ jobs:
with:
version: 10

- name: Use Node.js 24
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: "pnpm"
cache-dependency-path: ./webnext/pnpm-lock.yaml

- name: Install frontend dependencies
run: pnpm install --ignore-scripts --frozen-lockfile
working-directory: web
working-directory: webnext

- name: Build frontend
run: pnpm build
working-directory: web
working-directory: webnext

- name: Build release binary
uses: actions-rs/cargo@v1
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
FROM node:24-alpine AS web

WORKDIR /app
COPY web/package.json .
COPY web/pnpm-lock.yaml .
COPY web/.npmrc .
COPY webnext/package.json webnext/pnpm-lock.yaml webnext/.npmrc ./
RUN npm i -g pnpm
RUN pnpm install --ignore-scripts --frozen-lockfile
COPY web/ .
COPY webnext/ .
RUN pnpm run generate-translation-types
RUN pnpm build

Expand All @@ -31,8 +29,7 @@ COPY --from=planner /build/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json

# build project
COPY --from=web /app/dist ./web/dist
COPY web/src/shared/images/svg ./web/src/shared/images/svg
COPY --from=web /app/dist ./webnext/dist
RUN apt-get update && apt-get -y install protobuf-compiler libprotobuf-dev
COPY Cargo.toml Cargo.lock build.rs ./
# for vergen
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,30 @@ Find us on Matrix: [#defguard:teonite.com](https://matrix.to/#/#defguard:teonite

Please review the [Contributing guide](https://defguard.gitbook.io/defguard/for-developers/contributing) for information on how to get started contributing to the project. You might also find our [environment setup guide](https://defguard.gitbook.io/defguard/for-developers/dev-env-setup) handy.


## Development

Clone repository:

```bash
git@github.com:DefGuard/client.git
```

Initialize `proto` submodule:

```bash
git submodule update --init --recursive
```

To run API server:

```bash
cargo run
```

To run webapp dev server:

```bash
cd web/
cd webnext/
pnpm install
pnpm run dev
```
Expand Down Expand Up @@ -76,5 +79,3 @@ All release assets (binaries, packages, etc.) include SHA256 checksums that are
# Linux/macOS
echo known_sha256_checksum_of_the_file path/to/file | sha256sum --check
```


10 changes: 1 addition & 9 deletions src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,9 @@ pub async fn index() -> impl IntoResponse {
web_asset(Uri::from_static("/index.html")).await
}

pub async fn svg(uri: Uri) -> impl IntoResponse {
let mut path = uri.path().trim_start_matches('/').to_string();
// Rewrite the path to match the structure of the embedded files
path.insert_str(0, "src/shared/images/");
StaticFile(path)
}

#[derive(Embed)]
#[folder = "web/"]
#[folder = "webnext/"]
#[include = "dist/*"]
#[include = "src/shared/images/*"]
struct WebAsset;

pub struct StaticFile<T>(pub T);
Expand Down
3 changes: 1 addition & 2 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use tracing::{info_span, Level};
use url::Url;

use crate::{
assets::{index, svg, web_asset},
assets::{index, web_asset},
config::Config,
enterprise::handlers::openid_login::{self, FlowType},
error::ApiError,
Expand Down Expand Up @@ -265,7 +265,6 @@ pub async fn run_server(config: Config) -> anyhow::Result<()> {
.route("/{*path}", get(index))
.route("/fonts/{*path}", get(web_asset))
.route("/assets/{*path}", get(web_asset))
.route("/svg/{*path}", get(svg))
.nest(
"/api/v1",
Router::new()
Expand Down
11 changes: 11 additions & 0 deletions webnext/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = false

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2

[*.{ts,tsx,js,jsx,scss,html,json,yaml}]
rulers = 90
36 changes: 36 additions & 0 deletions webnext/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
* text=auto eol=lf

*.js text eol=lf
*.jsx text eol=lf
*.ts text eol=lf
*.tsx text eol=lf
*.css text eol=lf
*.scss text eol=lf
*.json text eol=lf
*.html text eol=lf
*.md text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.lock text eol=lf

*.woff binary
*.woff2 binary
*.ttf binary
*.otf binary
*.eot binary
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.webp binary
*.avif binary
*.ico binary
*.mp4 binary
*.webm binary
*.ogg binary
*.mp3 binary
*.wav binary
*.pdf binary
*.zip binary
*.tar binary
*.gz binary
26 changes: 26 additions & 0 deletions webnext/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local
project.inlang/cache

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.tanstack
4 changes: 4 additions & 0 deletions webnext/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/src/i18n/*.ts
/src/i18n/*.tsx
/src/**/*.tsx
/src/**/*.ts
8 changes: 8 additions & 0 deletions webnext/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"tabWidth": 2,
"singleQuote": true,
"useTabs": false,
"printWidth": 90,
"endOfLine": "lf"
}
10 changes: 10 additions & 0 deletions webnext/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": ["stylelint-config-standard-scss"],
"plugins": ["stylelint-scss"],
"rules": {
"at-rule-no-unknown": null,
"scss/at-rule-no-unknown": true,
"custom-property-empty-line-before": null,
"value-keyword-case": null
}
}
5 changes: 5 additions & 0 deletions webnext/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"inlang.vs-code-extension"
]
}
Empty file added webnext/README.md
Empty file.
67 changes: 67 additions & 0 deletions webnext/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"includes": [
"src/**",
"!src/messages",
"!src/paraglide/**/*.js",
"!src/routeTree.gen.ts"
]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"attributePosition": "auto",
"bracketSameLine": false,
"bracketSpacing": true,
"expand": "auto",
"lineEnding": "lf",
"lineWidth": 90,
"indentStyle": "space",
"useEditorconfig": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"a11y": "off",
"correctness": {
"useUniqueElementIds": "off"
},
"style": {
"useLiteralEnumMembers": "off",
"useBlockStatements": "off"
},
"suspicious": {
"noArrayIndexKey": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always",
"attributePosition": "auto",
"bracketSameLine": false,
"bracketSpacing": true
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
16 changes: 16 additions & 0 deletions webnext/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="en" data-theme="light">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Defguard</title>
</head>

<body>
<div id="root"></div>
<div id="modals-root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>

</html>
3 changes: 3 additions & 0 deletions webnext/messages/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "https://inlang.com/schema/inlang-message-format"
}
Loading