[PR #3058] [MERGED] Removed unsafe-inline JS from CSP and other fixes #3103

Closed
opened 2025-10-09 18:17:14 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/3058
Author: @BlackDex
Created: 12/28/2022
Status: Merged
Merged: 1/9/2023
Merged by: @dani-garcia

Base: mainHead: remove-inline-js


📝 Commits (1)

  • 613b251 Removed unsafe-inline JS from CSP and other fixes

📊 Changes

18 files changed (+946 additions, -718 deletions)

View changed files

📝 src/api/admin.rs (+14 -26)
📝 src/api/web.rs (+11 -0)
📝 src/config.rs (+15 -0)
src/static/scripts/404.css (+26 -0)
src/static/scripts/admin.css (+45 -0)
src/static/scripts/admin.js (+65 -0)
src/static/scripts/admin_diagnostics.js (+219 -0)
src/static/scripts/admin_organizations.js (+54 -0)
src/static/scripts/admin_settings.js (+180 -0)
src/static/scripts/admin_users.js (+246 -0)
📝 src/static/scripts/bootstrap.css (+0 -2)
📝 src/static/templates/404.hbs (+2 -26)
📝 src/static/templates/admin/base.hbs (+2 -94)
📝 src/static/templates/admin/diagnostics.hbs (+13 -194)
📝 src/static/templates/admin/organizations.hbs (+9 -36)
📝 src/static/templates/admin/settings.hbs (+11 -154)
📝 src/static/templates/admin/users.hbs (+29 -173)
📝 src/util.rs (+5 -13)

📄 Description

  • Removed unsafe-inline for javascript from CSP. The admin interface now uses files instead of inline javascript.
  • Modified javascript to work not being inline.
  • Run eslint over javascript and fixed some items.
  • Added a to_json Handlebars helper. Used at the diagnostics page.
  • Changed AdminTemplateData struct to be smaller. The config was always added, but only used at one page. Same goes for can_backup and version.
  • Also inlined CSS.
    We can't remove the unsafe-inline from css, because that seems to
    break the web-vault currently. That might need some further checks.
    But for now the 404 page and all the admin pages are clear of inline scripts and styles.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/dani-garcia/vaultwarden/pull/3058 **Author:** [@BlackDex](https://github.com/BlackDex) **Created:** 12/28/2022 **Status:** ✅ Merged **Merged:** 1/9/2023 **Merged by:** [@dani-garcia](https://github.com/dani-garcia) **Base:** `main` ← **Head:** `remove-inline-js` --- ### 📝 Commits (1) - [`613b251`](https://github.com/dani-garcia/vaultwarden/commit/613b2519edc53dfcc7f82ea4e402ff846ab9cc04) Removed unsafe-inline JS from CSP and other fixes ### 📊 Changes **18 files changed** (+946 additions, -718 deletions) <details> <summary>View changed files</summary> 📝 `src/api/admin.rs` (+14 -26) 📝 `src/api/web.rs` (+11 -0) 📝 `src/config.rs` (+15 -0) ➕ `src/static/scripts/404.css` (+26 -0) ➕ `src/static/scripts/admin.css` (+45 -0) ➕ `src/static/scripts/admin.js` (+65 -0) ➕ `src/static/scripts/admin_diagnostics.js` (+219 -0) ➕ `src/static/scripts/admin_organizations.js` (+54 -0) ➕ `src/static/scripts/admin_settings.js` (+180 -0) ➕ `src/static/scripts/admin_users.js` (+246 -0) 📝 `src/static/scripts/bootstrap.css` (+0 -2) 📝 `src/static/templates/404.hbs` (+2 -26) 📝 `src/static/templates/admin/base.hbs` (+2 -94) 📝 `src/static/templates/admin/diagnostics.hbs` (+13 -194) 📝 `src/static/templates/admin/organizations.hbs` (+9 -36) 📝 `src/static/templates/admin/settings.hbs` (+11 -154) 📝 `src/static/templates/admin/users.hbs` (+29 -173) 📝 `src/util.rs` (+5 -13) </details> ### 📄 Description - Removed `unsafe-inline` for javascript from CSP. The admin interface now uses files instead of inline javascript. - Modified javascript to work not being inline. - Run eslint over javascript and fixed some items. - Added a `to_json` Handlebars helper. Used at the diagnostics page. - Changed `AdminTemplateData` struct to be smaller. The `config` was always added, but only used at one page. Same goes for `can_backup` and `version`. - Also inlined CSS. We can't remove the `unsafe-inline` from css, because that seems to break the web-vault currently. That might need some further checks. But for now the 404 page and all the admin pages are clear of inline scripts and styles. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2025-10-09 18:17:14 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#3103