Skip to content

Commit f7d319e

Browse files
committed
Use font files and not extern url
1 parent 746abee commit f7d319e

10 files changed

+26
-5
lines changed

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ group :development, :test do
3434
gem 'launchy'
3535
gem 'mocha'
3636
gem 'pry-byebug'
37+
gem 'rack-cors'
3738
gem 'rails-controller-testing'
3839
gem 'rails-erd'
3940
gem 'rspec-rails'

Gemfile.lock

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ GEM
214214
activesupport (>= 3.0.0)
215215
racc (1.6.2)
216216
rack (2.2.7)
217+
rack-cors (2.0.1)
218+
rack (>= 2.0.0)
217219
rack-oauth2 (1.21.3)
218220
activesupport
219221
attr_required
@@ -393,6 +395,7 @@ DEPENDENCIES
393395
pry-stack_explorer
394396
puma
395397
pundit
398+
rack-cors
396399
rails (~> 7.0)
397400
rails-controller-testing
398401
rails-erd

config/application.rb

+9
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ class Application < Rails::Application
6767
# Configure the default encoding used in templates for Ruby 1.9.
6868
config.encoding = "utf-8"
6969

70+
config.middleware.insert_before 0, Rack::Cors do
71+
allow do
72+
origins 'http://localhost:4200'
73+
resource '/text-security-disc.woff2', headers: :any, methods: [:get, :post]
74+
resource '/text-security-disc-compat.eot', headers: :any, methods: [:get, :post]
75+
resource '/text-security-disc-compat.ttf', headers: :any, methods: [:get, :post]
76+
end
77+
end
78+
7079
# https://stackoverflow.com/questions/72970170/upgrading-to-rails-6-1-6-1-causes-psychdisallowedclass-tried-to-load-unspecif
7180
# https://discuss.rubyonrails.org/t/cve-2022-32224-possible-rce-escalation-bug-with-serialized-columns-in-active-record/81017
7281
config.after_initialize do

config/initializers/content_security_policy.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
policy.connect_src :self, 'https://sentry.puzzle.ch'
2121

2222
policy.font_src :self
23-
policy.font_src :self, 'https://raw.githubusercontent.com' if Rails.env.development?
24-
23+
policy.font_src :self, :https, 'http://localhost:4200', :data if Rails.env.development?
2524

2625
policy.script_src :self
2726
policy.script_src :self, :unsafe_eval, "http://localhost:4200" if Rails.env.development?

config/initializers/mime_types.rb

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22

33
# Add new mime types for use in respond_to blocks:
44
# Mime::Type.register "text/richtext", :rtf
5+
6+
Mime::Type.register "font/woff2", :woff2
7+
Mime::Type.register "application/vnd.ms-fontobject", :eot
8+
Mime::Type.register "application/x-font-ttf", :ttf

frontend/app/styles/secret-input.scss

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// font from: https://github.com/noppa/text-security
22

33
@font-face {
4-
font-family: text-security-disc;
5-
src: url("https://raw.githubusercontent.com/noppa/text-security/master/dist/text-security-disc.woff");
4+
font-family: "text-security-disc";
5+
src: url("/text-security-disc-compat.eot");
6+
src: url("/text-security-disc-compat.eot?#iefix") format("embedded-opentype"),
7+
url("/text-security-disc.woff2") format("woff2"),
8+
url("/text-security-disc-compat.ttf") format("truetype");
69
}
710

811
input.secret {
912
font-family: text-security-disc;
10-
-webkit-text-security: disc;
1113
}
1214

1315
.secret input {

frontend/config/environment.js

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ module.exports = function (environment) {
44
let ENV = {
55
modulePrefix: "frontend",
66
environment,
7+
contentSecurityPolicy: {
8+
'font-src': "'self' http://localhost:4200"
9+
},
710
rootURL: "/",
811
locationType: "auto",
912
sentryDsn: "",
150 KB
Binary file not shown.
150 KB
Binary file not shown.
788 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)