trek 2.6.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/AGENTS.md +12 -11
  3. data/CHANGELOG.md +51 -0
  4. data/Gemfile.lock +124 -126
  5. data/Makefile +7 -1
  6. data/README.md +17 -21
  7. data/app/components/trek/form/content_editor_component/content_editor_component.css +4 -8
  8. data/app/components/trek/form/image_field_component/image_field_component.js +1 -2
  9. data/app/components/trek/form/password_strength_component/password_strength_component.css +2 -0
  10. data/app/components/trek/form/sound_field_component/sound_field_component.js +1 -2
  11. data/app/components/trek/security_check_component/security_check_component.css +69 -0
  12. data/app/components/trek/security_check_component/security_check_component.html.slim +19 -0
  13. data/app/components/trek/security_check_component/security_check_component.js +15 -0
  14. data/app/components/trek/security_check_component.rb +19 -0
  15. data/app/content/trek/content/cleaner.rb +1 -1
  16. data/app/content/trek/content/list_item.rb +1 -1
  17. data/app/content/trek/content/paragraph.rb +7 -2
  18. data/app/controllers/concerns/trek/auditable.rb +5 -2
  19. data/app/controllers/concerns/trek/localization.rb +6 -2
  20. data/app/jobs/trek/purge_expired_sign_in_codes_job.rb +15 -0
  21. data/app/policies/trek/security_check_policy.rb +8 -0
  22. data/app/uploaders/image_uploader.rb +77 -15
  23. data/config/locales/trek.en.yml +71 -0
  24. data/config/locales/trek.fr.yml +71 -0
  25. data/docs/.vitepress/config.mjs +1 -0
  26. data/docs/background-jobs.md +10 -5
  27. data/docs/deploy.md +69 -6
  28. data/docs/getting-started.md +15 -17
  29. data/docs/index.md +1 -1
  30. data/docs/personal-data.md +61 -0
  31. data/docs/proxies.md +2 -2
  32. data/docs/reference/components.md +2 -2
  33. data/docs/reference/concerns/fragmentable.md +12 -6
  34. data/docs/reference/concerns/orderable.md +2 -2
  35. data/docs/reference/concerns/search-engine-optimizable.md +1 -1
  36. data/docs/reference/concerns/searchable.md +14 -1
  37. data/docs/reference/concerns/sectionable.md +7 -3
  38. data/docs/reference/concerns/versionable.md +1 -1
  39. data/docs/reference/controllers.md +33 -1
  40. data/docs/reference/environment-variables.md +2 -2
  41. data/docs/reference/formatters.md +2 -1
  42. data/docs/reference/forms.md +6 -3
  43. data/docs/reference/generators/admin-user.md +1 -1
  44. data/docs/reference/generators/audit-log.md +12 -13
  45. data/docs/reference/generators/install.md +20 -9
  46. data/docs/reference/generators/public-accounts.md +21 -3
  47. data/docs/reference/generators/scaffold.md +28 -9
  48. data/docs/reference/generators/security-headers.md +4 -3
  49. data/docs/reference/generators/taxonomies.md +1 -1
  50. data/docs/reference/icons.md +5 -3
  51. data/docs/reference/index.md +10 -8
  52. data/docs/reference/models/current.md +5 -3
  53. data/docs/reference/models/page-version.md +1 -1
  54. data/docs/reference/models/user.md +5 -8
  55. data/docs/reference/uploaders.md +25 -0
  56. data/docs/reference/validators.md +1 -1
  57. data/docs/security.md +30 -9
  58. data/docs/what-is-trek.md +3 -3
  59. data/lib/generators/trek/USAGE +1 -1
  60. data/lib/generators/trek/audit_log_generator.rb +8 -0
  61. data/lib/generators/trek/helpers.rb +17 -0
  62. data/lib/generators/trek/install/admin/routes_generator.rb +2 -1
  63. data/lib/generators/trek/install/admin/security_check_generator.rb +36 -0
  64. data/lib/generators/trek/install/ci_generator.rb +19 -0
  65. data/lib/generators/trek/install/postcss_generator.rb +1 -2
  66. data/lib/generators/trek/install/translations_generator.rb +1 -2
  67. data/lib/generators/trek/install_generator.rb +8 -7
  68. data/lib/generators/trek/public_accounts_generator.rb +34 -7
  69. data/lib/generators/trek/scaffold_generator.rb +22 -21
  70. data/lib/generators/trek/scalingo_generator.rb +13 -1
  71. data/lib/generators/trek/templates/.gitlab-ci.yml +10 -1
  72. data/lib/generators/trek/templates/AGENTS.md +2 -2
  73. data/lib/generators/trek/templates/Makefile +1 -0
  74. data/lib/generators/trek/templates/config/i18n-tasks.yml.erb +0 -8
  75. data/lib/generators/trek/templates/controllers/admin/security_checks_controller.rb +11 -0
  76. data/lib/generators/trek/templates/controllers/concerns/trek/authentication.rb +13 -4
  77. data/lib/generators/trek/templates/initializers/good_job.rb.tt +7 -5
  78. data/lib/generators/trek/templates/layouts/admin.html.slim +5 -0
  79. data/lib/generators/trek/templates/policies/security_check.rb +4 -0
  80. data/lib/generators/trek/templates/public_accounts/api/controllers/sessions_controller.rb.tt +13 -1
  81. data/lib/generators/trek/templates/public_accounts/api/controllers/sign_in_codes_controller.rb.tt +5 -0
  82. data/lib/generators/trek/templates/public_accounts/jobs/sign_in_code_job.rb.tt +10 -0
  83. data/lib/generators/trek/templates/public_accounts/locales/accounts.en.yml.tt +10 -0
  84. data/lib/generators/trek/templates/public_accounts/locales/accounts.fr.yml.tt +10 -0
  85. data/lib/generators/trek/templates/public_accounts/models/account.rb.tt +16 -2
  86. data/lib/generators/trek/templates/public_accounts/spec/api/sign_ins_spec.rb.tt +30 -0
  87. data/lib/generators/trek/templates/public_accounts/spec/models/account/sign_in_code_spec.rb.tt +10 -0
  88. data/lib/generators/trek/templates/public_accounts/spec/models/account_spec.rb.tt +21 -1
  89. data/lib/generators/trek/templates/public_accounts/spec/web/sign_ins_spec.rb.tt +22 -0
  90. data/lib/generators/trek/templates/public_accounts/web/authentication.rb.tt +1 -1
  91. data/lib/generators/trek/templates/public_accounts/web/controllers/sessions_controller.rb.tt +8 -1
  92. data/lib/generators/trek/templates/public_accounts/web/controllers/sign_in_codes_controller.rb.tt +5 -0
  93. data/lib/generators/trek/templates/public_accounts/web/views/password_resets/edit.html.slim.tt +4 -1
  94. data/lib/generators/trek/templates/public_accounts/web/views/passwords/edit.html.slim.tt +4 -1
  95. data/lib/generators/trek/templates/public_accounts/web/views/registrations/new.html.slim.tt +3 -1
  96. data/lib/generators/trek/templates/public_accounts/web/views/sessions/new.html.slim.tt +3 -1
  97. data/lib/generators/trek/templates/spec/requests/admin/pages_spec.rb +11 -0
  98. data/lib/generators/trek/templates/spec/requests/admin/security_checks_spec.rb +24 -0
  99. data/lib/generators/trek/templates/spec/requests/admin/sign_in_notices_spec.rb +33 -0
  100. data/lib/generators/trek/templates/views/admin/pages/_form.html.slim +1 -1
  101. data/lib/generators/trek/templates/views/admin/security_checks/show.html.slim +9 -0
  102. data/lib/generators/trek/templates/views/admin/user_password_resets/edit.html.slim +6 -1
  103. data/lib/generators/trek/templates/views/admin/user_sessions/new.html.slim +4 -1
  104. data/lib/tasks/trek/attachments.rake +12 -0
  105. data/lib/tasks/trek/security.rake +10 -0
  106. data/lib/trek/disposable_email_domains.rb +9 -20
  107. data/lib/trek/engine.rb +5 -0
  108. data/lib/trek/json_compatibility.rb +20 -0
  109. data/lib/trek/security_check.rb +241 -0
  110. data/lib/trek/stored_image_metadata.rb +88 -0
  111. data/lib/trek/version.rb +1 -1
  112. data/lib/trek.rb +2 -1
  113. data/package.json +5 -6
  114. data/postcss.config.js +0 -3
  115. data/trek.gemspec +5 -6
  116. data/yarn.lock +983 -1042
  117. metadata +33 -31
@@ -0,0 +1,69 @@
1
+ /* Use component-local class names and add them to HTML via #class_for(name) helper */
2
+
3
+ .root {
4
+ list-style: none;
5
+ margin: 0;
6
+ max-width: 96rem;
7
+ padding: 0;
8
+ }
9
+
10
+ .result {
11
+ align-items: baseline;
12
+ border-top: 1px solid var(--slate-6);
13
+ display: flex;
14
+ gap: 1.2rem;
15
+ line-height: 1.4;
16
+ padding: 1.2rem 0;
17
+ }
18
+
19
+ .status {
20
+ align-self: center;
21
+ color: var(--slate-9);
22
+ display: flex;
23
+ flex: none;
24
+ justify-content: center;
25
+ width: 2rem;
26
+ }
27
+
28
+ .icon {
29
+ height: 1.8rem;
30
+ width: 1.8rem;
31
+ }
32
+
33
+ .dot {
34
+ background-color: currentcolor;
35
+ border-radius: 50%;
36
+ height: 0.6rem;
37
+ width: 0.6rem;
38
+ }
39
+
40
+ .message {
41
+ color: var(--slate-12);
42
+ flex: 1;
43
+ }
44
+
45
+ .message code {
46
+ background-color: var(--slate-3);
47
+ border-radius: 0.3rem;
48
+ font-family: monospace;
49
+ font-size: 0.9em;
50
+ padding: 0.1rem 0.4rem;
51
+ }
52
+
53
+ .docs {
54
+ color: var(--slate-11);
55
+ font-size: 0.9em;
56
+ white-space: nowrap;
57
+ }
58
+
59
+ .result[data-status="ok"] .status {
60
+ color: var(--grass-11);
61
+ }
62
+
63
+ .result[data-status="warning"] .status {
64
+ color: var(--amber-11);
65
+ }
66
+
67
+ .result[data-status="failure"] .status {
68
+ color: var(--tomato-11);
69
+ }
@@ -0,0 +1,19 @@
1
+ ul(class=root_class)
2
+ - results.each do |result|
3
+ li(class=class_for("result") data-status=result.status)
4
+ span(class=class_for("status"))
5
+ - if (icon = ICONS[result.status])
6
+ = render Trek::IconComponent.new( \
7
+ icon,
8
+ classnames: class_for("icon"),
9
+ title: t(".statuses.#{result.status}"),
10
+ )
11
+ - else
12
+ span(class=class_for("dot") role="img" aria-label=t(".statuses.info"))
13
+ span(class=class_for("message"))
14
+ = formatted(result.message)
15
+ = link_to t(".docs"),
16
+ result.docs,
17
+ class: class_for("docs"),
18
+ target: "_blank",
19
+ rel: "noopener"
@@ -0,0 +1,15 @@
1
+ import "./security_check_component.css";
2
+
3
+ // Add a Stimulus controller for this component.
4
+ // It will automatically registered and its name will be available
5
+ // via #component_name in the component class.
6
+ //
7
+ // import { Controller as BaseController } from "@hotwired/stimulus";
8
+ //
9
+ // export class Controller extends BaseController {
10
+ // connect() {
11
+ // }
12
+ //
13
+ // disconnect() {
14
+ // }
15
+ // }
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trek
4
+ # The results of Trek::SecurityCheck, each with its status and a link to the docs explaining it
5
+ #
6
+ # = render Trek::SecurityCheckComponent.new(results: Trek::SecurityCheck.new(request:).results)
7
+ class SecurityCheckComponent < Trek::Component
8
+ # An info has no icon: a dot, as it calls for nothing
9
+ ICONS = { ok: "trek/check", warning: "trek/danger", failure: "trek/close" }.freeze
10
+
11
+ option :results
12
+
13
+ # The message, with the code it names between backticks (`ADMIN_ALLOWED_IPS`, a class…) in <code>.
14
+ # Escaped part by part: it holds the IP addresses of the request's headers.
15
+ def formatted(message)
16
+ safe_join(message.split(/`([^`]+)`/).each_with_index.map { |part, index| index.odd? ? tag.code(part) : part })
17
+ end
18
+ end
19
+ end
@@ -46,7 +46,7 @@ module Trek
46
46
  end
47
47
 
48
48
  def empty_paragraph?(node)
49
- node.type == :paragraph && node.content.empty?
49
+ node.type == :paragraph && Paragraph.empty?(node)
50
50
  end
51
51
  end
52
52
  end
@@ -3,7 +3,7 @@ module Trek
3
3
  # Empty list items, with no content or only empty paragraphs, render nothing, like empty paragraphs.
4
4
  class ListItem < Prosemirror::Nodes::ListItem
5
5
  def self.empty?(node)
6
- node.content.all? { |child| child.type == :paragraph && child.content.empty? }
6
+ node.content.all? { |child| child.type == :paragraph && Paragraph.empty?(child) }
7
7
  end
8
8
 
9
9
  # Whether a list has no item to render: only empty items, and whitespace.
@@ -1,9 +1,14 @@
1
1
  module Trek
2
2
  module Content
3
- # Empty paragraphs, often left by the editor, render nothing.
3
+ # Empty paragraphs, often left by the editor, render nothing: with no content, or only line breaks
4
+ # (Shift+Enter), which would show as a blank space.
4
5
  class Paragraph < Prosemirror::Nodes::Paragraph
6
+ def self.empty?(node)
7
+ node.content.all? { |child| child.type == :hard_break }
8
+ end
9
+
5
10
  def view_template(&)
6
- p(&) unless node.content.empty?
11
+ p(&) unless self.class.empty?(node)
7
12
  end
8
13
  end
9
14
  end
@@ -6,7 +6,7 @@ module Trek
6
6
  # status, or the class of the error raised).
7
7
  #
8
8
  # Only mutations are recorded: GET and HEAD are skipped, unless a controller sets
9
- # `self.audit_reads = true`. A read on sensitive data can be logged explicitly with `audit!`.
9
+ # `self.audit_reads = true`, and so are the actions of `audit_read_actions`. A read on sensitive data can be logged explicitly with `audit!`.
10
10
  #
11
11
  # Auditing never breaks the request: a failed write is reported through `Rails.error`.
12
12
  # FEATURE_AUDIT_LOG=false switches it off, read on each request.
@@ -15,6 +15,9 @@ module Trek
15
15
 
16
16
  included do
17
17
  class_attribute :audit_reads, default: false
18
+ # Actions that only read although they're not a GET, e.g. hotwire_combobox's `chips`, which a
19
+ # multiselect requests with a POST: skipped as reads are.
20
+ class_attribute :audit_read_actions, default: []
18
21
  # The parameters whose values are recorded, at any depth; the others are recorded by name only,
19
22
  # so the log doesn't copy the data the forms send. `config.filter_parameters` still applies.
20
23
  class_attribute :audit_param_values, default: %w[id role]
@@ -49,7 +52,7 @@ module Trek
49
52
 
50
53
  # Rails answers `get?` with false for a HEAD, which uptime monitors use.
51
54
  def read_only_request?
52
- request.get? || request.head?
55
+ request.get? || request.head? || audit_read_actions.map(&:to_s).include?(action_name)
53
56
  end
54
57
 
55
58
  def write_audit_log(action: action_name, target: audit_target, status: nil, error: nil)
@@ -10,7 +10,8 @@ module Trek
10
10
 
11
11
  def set_locale
12
12
  old_locale = I18n.locale
13
- I18n.locale = locale_for_request
13
+ # The default locale when no source gives one: plain I18n refuses a nil locale.
14
+ I18n.locale = locale_for_request || I18n.default_locale
14
15
 
15
16
  yield
16
17
  ensure
@@ -29,8 +30,11 @@ module Trek
29
30
  locale_from_params || locale_from_current_user || locale_from_headers
30
31
  end
31
32
 
33
+ # Only one of the app's locales: any other value (`?locale=xx`, an array) would make
34
+ # I18n.locale= raise I18n::InvalidLocale, and the request end in a 500.
32
35
  def locale_from_params
33
- params[:locale]
36
+ locale = params[:locale]
37
+ locale if I18n.locale_available?(locale)
34
38
  end
35
39
 
36
40
  def locale_from_current_user
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Trek
4
+ # Deletes the sign-in codes past their validity (Trek::Users::SignInCode): they can't sign anyone in
5
+ # anymore, and each holds an email. A new code deletes the expired ones too, but nothing deletes the
6
+ # last ones requested. Schedule it daily with the app's Active Job backend, e.g. a GoodJob cron
7
+ # entry, with the code model named ("Customer::SignInCode").
8
+ # rubocop:disable Rails/ApplicationJob -- the gem can't rely on the host app's ApplicationJob
9
+ class PurgeExpiredSignInCodesJob < ActiveJob::Base
10
+ def perform(code_class)
11
+ code_class.constantize.expired.in_batches(of: 1000).delete_all
12
+ end
13
+ end
14
+ # rubocop:enable Rails/ApplicationJob
15
+ end
@@ -0,0 +1,8 @@
1
+ module Trek
2
+ # The security check lists the app's weak spots: admins only (Admin::SecurityChecksController)
3
+ class SecurityCheckPolicy < Trek::ApplicationPolicy
4
+ def show?
5
+ user.admin?
6
+ end
7
+ end
8
+ end
@@ -1,28 +1,90 @@
1
1
  require "image_processing/vips"
2
2
 
3
3
  class ImageUploader < Shrine
4
+ TYPES = %w[image/jpeg image/png image/webp].freeze
5
+ # libvips' default (75) visibly degrades a photo
6
+ QUALITY = 90
7
+ # The sizes (thumbnails…), in WebP whatever the original's type
8
+ SIZE_QUALITY = 80
9
+
4
10
  plugin :blurhash
5
11
  plugin :determine_mime_type
6
12
  plugin :remote_url, max_size: nil
7
13
  plugin :store_dimensions
8
14
  plugin :validation_helpers
9
- # plugin :derivation_endpoint,
10
- # secret_key: Rails.application.credentials.dig(:shrine, :derivation_endpoint, :secret_key),
11
- # prefix: "derivations/image",
12
- # upload: true,
13
- # upload_location: lambda {
14
- # # e.g. "derivatives/9a7d1bfdad24a76f9cfaff137fe1b5c7/thumbnail-1000-800"
15
- # ["derivatives", File.basename(source.id, ".*"), [name, *args].join("-")].join("/")
16
- # }
17
- #
18
- # derivation :thumbnail do |file, width, height|
19
- # ImageProcessing::Vips
20
- # .source(file)
21
- # .resize_to_limit!(width.to_i, height.to_i)
22
- # end
15
+ # The sizes Trek::ThumbnailHelper asks for (`derivation_url(:thumbnail, width, height)`), made on
16
+ # their first request, then stored and served from the store. The secret signs their URLs: from
17
+ # the credentials trek:install:attachments writes, or derived from secret_key_base.
18
+ plugin :derivation_endpoint,
19
+ secret_key: Rails.application.credentials.dig(:shrine, :derivation_endpoint, :secret_key) ||
20
+ Rails.application.key_generator.generate_key("shrine/derivation_endpoint"),
21
+ prefix: "derivations/image",
22
+ upload: true,
23
+ upload_location: lambda {
24
+ # e.g. "derivatives/9a7d1bfdad24a76f9cfaff137fe1b5c7/thumbnail-1000-800"
25
+ [shrine_class.sizes_location(source.id), [name, *args].join("-")].join("/")
26
+ }
27
+
28
+ derivation :thumbnail do |file, width, height|
29
+ ImageProcessing::Vips
30
+ .source(file)
31
+ .convert("webp")
32
+ .saver(Q: SIZE_QUALITY, **shrine_class.metadata_saver_options)
33
+ .resize_to_limit!(width.to_i, height.to_i)
34
+ end
23
35
 
24
36
  Attacher.validate do
25
37
  validate_max_size 20.megabytes
26
- validate_max_dimensions [8000, 8000] if validate_mime_type %w[image/jpeg image/png]
38
+ validate_max_dimensions [8000, 8000] if validate_mime_type TYPES
39
+ end
40
+
41
+ # Shrine deletes an image when its record is destroyed, or the image replaced or removed, but
42
+ # not the sizes it stored: they go with it, as they're published too.
43
+ class Attacher
44
+ def destroy
45
+ super
46
+ file.storage.delete_prefixed("#{shrine_class.sizes_location(file.id)}/") if file
47
+ end
48
+ end
49
+
50
+ # Where the sizes of the image stored as `id` are
51
+ def self.sizes_location(id)
52
+ "derivatives/#{File.basename(id, ".*")}"
53
+ end
54
+
55
+ # Strips the metadata libvips writes back, keeping the color profile (libvips 8.15 or later; older
56
+ # ones strip that too)
57
+ def self.metadata_saver_options
58
+ Vips.at_least_libvips?(8, 15) ? { keep: :icc } : { strip: true }
59
+ end
60
+
61
+ # A photo's metadata would be published with it: its EXIF (the GPS location, the camera's serial
62
+ # number…), XMP and IPTC. It is stripped from a new file before it is stored, in the cache too,
63
+ # by re-encoding the image after applying its orientation, keeping its color profile. A file
64
+ # promoted from the cache is stored as it is.
65
+ def upload(io, **options)
66
+ return super if io.is_a?(Shrine::UploadedFile)
67
+
68
+ mime_type = self.class.determine_mime_type(io)
69
+ return super unless TYPES.include?(mime_type)
70
+
71
+ filename = extract_filename(io)
72
+ stripped = Shrine.with_file(io) { |file| strip_metadata(file, mime_type) }
73
+ io.close if options.fetch(:close, true)
74
+ metadata = { "filename" => filename }.merge(options[:metadata].is_a?(Hash) ? options[:metadata] : {})
75
+ super(stripped, **options, metadata:, delete: true)
76
+ end
77
+
78
+ private
79
+
80
+ def strip_metadata(file, mime_type)
81
+ format = mime_type.delete_prefix("image/").sub("jpeg", "jpg")
82
+ ImageProcessing::Vips
83
+ .source(file)
84
+ # Every frame of an animated WebP, not only the first
85
+ .loader(**(format == "webp" ? { n: -1 } : {}))
86
+ .convert(format)
87
+ .saver(**self.class.metadata_saver_options, **(format == "png" ? {} : { Q: QUALITY }))
88
+ .call
27
89
  end
28
90
  end
@@ -247,6 +247,10 @@ en:
247
247
  success: Section added
248
248
  update:
249
249
  success: Section updated
250
+ security_checks:
251
+ show:
252
+ intro: Checked %{time}, with Trek %{trek} and Rails %{rails}, against the recommended settings
253
+ title: Security
250
254
  seo: SEO
251
255
  settings: Settings
252
256
  user_password_resets:
@@ -384,6 +388,73 @@ en:
384
388
  search_component:
385
389
  reset: Reset search
386
390
  search: Search
391
+ security_check:
392
+ admin_allowed_ips:
393
+ set: The admin is restricted to %{count} IP addresses or ranges (`ADMIN_ALLOWED_IPS`)
394
+ unset: The admin is open to every IP address (`ADMIN_ALLOWED_IPS` isn't set)
395
+ admins:
396
+ count: "%{privileged} users can sign in to the admin, %{admins} of them with the admin role"
397
+ audit_log:
398
+ not_installed: No audit log (`bin/rails g trek:audit_log`)
399
+ not_purged: The audit log's purge isn't scheduled (`Trek::AuditLog::PurgeJob` in GoodJob's cron)
400
+ purge_unknown: The audit log's purge can't be checked with this job backend (`Trek::AuditLog::PurgeJob`)
401
+ purged: Audit log installed, its purge scheduled
402
+ cache_store:
403
+ per_process: The cache store (`%{store}`) isn't shared by the app's processes, which the sign-in limits need
404
+ per_server: The cache store (`%{store}`) isn't shared by the app's servers, which the sign-in limits need
405
+ shared: Cache store shared by the app's processes (`%{store}`)
406
+ content_security_policy:
407
+ enforced: Content Security Policy enforced
408
+ none: No Content Security Policy (`bin/rails g trek:install:security_headers`)
409
+ report_only: The Content Security Policy only reports violations (`content_security_policy_report_only`)
410
+ cron:
411
+ disabled: "GoodJob's cron is off (`enable_cron`): scheduled jobs never run"
412
+ enabled: GoodJob's cron is on
413
+ other_backend: The scheduled jobs can't be checked with this job backend (`%{adapter}`)
414
+ dormant:
415
+ none: Every admin user signed in less than %{duration} ago
416
+ some:
417
+ one: "%{count} admin user hasn't signed in for %{duration}"
418
+ other: "%{count} admin users haven't signed in for %{duration}"
419
+ encryption:
420
+ configured: Active Record Encryption keys configured
421
+ not_configured: No Active Record Encryption keys (`bin/rails db:encryption:init`)
422
+ header: |-
423
+ Security check of %{app}, %{environment}, %{time}
424
+ Trek %{trek}, Rails %{rails}, Ruby %{ruby}
425
+ https:
426
+ no_hsts: HTTPS enforced, but without HSTS (`config.ssl_options`)
427
+ "off": HTTPS isn't enforced (`config.force_ssl`)
428
+ "on": HTTPS enforced, with HSTS for %{duration}
429
+ passkeys:
430
+ all: Every admin user has a passkey
431
+ password_only:
432
+ one: "%{count} admin user signs in with a password only, no passkey"
433
+ other: "%{count} admin users sign in with a password only, no passkey"
434
+ password_expiry:
435
+ after: Passwords expire after %{duration}
436
+ never: Passwords never expire (`password_expires_after`)
437
+ remote_ip:
438
+ cdn: "Rails sees your IP address as %{ip}, but the CDN forwards %{forwarded}: add its ranges to `trusted_proxies`"
439
+ seen: "Rails sees your IP address as %{ip}: check it's yours, not your network's proxy or the CDN's"
440
+ request_https:
441
+ http: "This page reached the app over HTTP: the proxy in front of it must forward the scheme (`X-Forwarded-Proto`)"
442
+ https: This page reached the app over HTTPS
443
+ session_purge:
444
+ not_scheduled: The expired sessions' purge isn't scheduled (`Trek::PurgeExpiredSessionsJob` in GoodJob's cron)
445
+ scheduled: Expired sessions' purge scheduled
446
+ unknown: The expired sessions' purge can't be checked with this job backend (`Trek::PurgeExpiredSessionsJob`)
447
+ summary: "%{ok} ok, %{info} for information, %{warning} warnings, %{failure} failures"
448
+ trusted_proxies:
449
+ default: "No trusted proxies besides the private networks (`trusted_proxies`): set them when a CDN is in front of the app"
450
+ set: "%{count} trusted proxies (`trusted_proxies`)"
451
+ security_check_component:
452
+ docs: Docs
453
+ statuses:
454
+ failure: Failure
455
+ info: Information
456
+ ok: OK
457
+ warning: Warning
387
458
  user_agents:
388
459
  browser_on_system: "%{browser} on %{system}"
389
460
  unknown: Unknown browser
@@ -256,6 +256,10 @@ fr:
256
256
  success: Section ajoutée
257
257
  update:
258
258
  success: Section mise à jour
259
+ security_checks:
260
+ show:
261
+ intro: Vérifié le %{time}, avec Trek %{trek} et Rails %{rails}, par rapport aux réglages recommandés
262
+ title: Sécurité
259
263
  seo: SEO
260
264
  settings: Paramètres
261
265
  user_password_resets:
@@ -393,6 +397,73 @@ fr:
393
397
  search_component:
394
398
  reset: Réinitialiser la recherche
395
399
  search: Rechercher
400
+ security_check:
401
+ admin_allowed_ips:
402
+ set: L’admin est réservée à %{count} adresses ou plages d’adresses IP (`ADMIN_ALLOWED_IPS`)
403
+ unset: L’admin est ouverte à toutes les adresses IP (`ADMIN_ALLOWED_IPS` n’est pas défini)
404
+ admins:
405
+ count: "%{privileged} utilisateurs peuvent se connecter à l’admin, dont %{admins} avec le rôle admin"
406
+ audit_log:
407
+ not_installed: Pas de journal d’audit (`bin/rails g trek:audit_log`)
408
+ not_purged: La purge du journal d’audit n’est pas planifiée (`Trek::AuditLog::PurgeJob` dans le cron de GoodJob)
409
+ purge_unknown: La purge du journal d’audit ne peut pas être vérifiée avec ce gestionnaire de tâches (`Trek::AuditLog::PurgeJob`)
410
+ purged: Journal d’audit installé, sa purge planifiée
411
+ cache_store:
412
+ per_process: Le cache (`%{store}`) n’est pas partagé par les processus de l’app, ce que les limites de connexion demandent
413
+ per_server: Le cache (`%{store}`) n’est pas partagé par les serveurs de l’app, ce que les limites de connexion demandent
414
+ shared: Cache partagé par les processus de l’app (`%{store}`)
415
+ content_security_policy:
416
+ enforced: Content Security Policy appliquée
417
+ none: Pas de Content Security Policy (`bin/rails g trek:install:security_headers`)
418
+ report_only: La Content Security Policy ne fait que signaler les violations (`content_security_policy_report_only`)
419
+ cron:
420
+ disabled: "Le cron de GoodJob est désactivé (`enable_cron`) : les tâches planifiées ne sont jamais lancées"
421
+ enabled: Le cron de GoodJob est activé
422
+ other_backend: Les tâches planifiées ne peuvent pas être vérifiées avec ce gestionnaire de tâches (`%{adapter}`)
423
+ dormant:
424
+ none: Tous les utilisateurs de l’admin se sont connectés il y a moins de %{duration}
425
+ some:
426
+ one: "%{count} utilisateur de l’admin ne s’est pas connecté depuis %{duration}"
427
+ other: "%{count} utilisateurs de l’admin ne se sont pas connectés depuis %{duration}"
428
+ encryption:
429
+ configured: Clés d’Active Record Encryption configurées
430
+ not_configured: Pas de clés d’Active Record Encryption (`bin/rails db:encryption:init`)
431
+ header: |-
432
+ Vérification de sécurité de %{app}, %{environment}, %{time}
433
+ Trek %{trek}, Rails %{rails}, Ruby %{ruby}
434
+ https:
435
+ no_hsts: HTTPS imposé, mais sans HSTS (`config.ssl_options`)
436
+ "off": HTTPS n’est pas imposé (`config.force_ssl`)
437
+ "on": HTTPS imposé, avec HSTS pendant %{duration}
438
+ passkeys:
439
+ all: Tous les utilisateurs de l’admin ont une clé d’accès
440
+ password_only:
441
+ one: "%{count} utilisateur de l’admin se connecte avec un mot de passe seul, sans clé d’accès"
442
+ other: "%{count} utilisateurs de l’admin se connectent avec un mot de passe seul, sans clé d’accès"
443
+ password_expiry:
444
+ after: Les mots de passe expirent après %{duration}
445
+ never: Les mots de passe n’expirent jamais (`password_expires_after`)
446
+ remote_ip:
447
+ cdn: "Rails voit votre adresse IP comme %{ip}, mais le CDN transmet %{forwarded} : ajoutez ses plages à `trusted_proxies`"
448
+ seen: "Rails voit votre adresse IP comme %{ip} : vérifiez que c’est la vôtre, et non celle du proxy de votre réseau ou du CDN"
449
+ request_https:
450
+ http: "Cette page est arrivée à l’app en HTTP : le proxy devant elle doit transmettre le protocole (`X-Forwarded-Proto`)"
451
+ https: Cette page est arrivée à l’app en HTTPS
452
+ session_purge:
453
+ not_scheduled: La purge des sessions expirées n’est pas planifiée (`Trek::PurgeExpiredSessionsJob` dans le cron de GoodJob)
454
+ scheduled: Purge des sessions expirées planifiée
455
+ unknown: La purge des sessions expirées ne peut pas être vérifiée avec ce gestionnaire de tâches (`Trek::PurgeExpiredSessionsJob`)
456
+ summary: "%{ok} ok, %{info} pour information, %{warning} avertissements, %{failure} échecs"
457
+ trusted_proxies:
458
+ default: "Pas de proxys de confiance en dehors des réseaux privés (`trusted_proxies`) : à définir quand un CDN est devant l’app"
459
+ set: "%{count} proxys de confiance (`trusted_proxies`)"
460
+ security_check_component:
461
+ docs: Documentation
462
+ statuses:
463
+ failure: Échec
464
+ info: Information
465
+ ok: OK
466
+ warning: Avertissement
396
467
  user_agents:
397
468
  browser_on_system: "%{browser} sur %{system}"
398
469
  unknown: Navigateur inconnu
@@ -57,6 +57,7 @@ export default defineConfig({
57
57
  { text: 'Deploying to Scalingo', link: '/deploy' },
58
58
  { text: 'IP addresses behind a proxy', link: '/proxies' },
59
59
  { text: 'Security and compliance', link: '/security' },
60
+ { text: 'Personal data', link: '/personal-data' },
60
61
  { text: 'Background jobs', link: '/background-jobs' }
61
62
  ]
62
63
  },
@@ -1,6 +1,6 @@
1
1
  # Background jobs
2
2
 
3
- Trek apps run Active Job on [GoodJob](https://github.com/bensheldon/good_job), installed by `rails g trek:install` (or on its own with `rails g trek:install:good_job`). GoodJob stores its queue in the application's own PostgreSQL database, so there is no second database to provision — which is why the installer removes the Solid Queue setup `rails new` generates.
3
+ Trek apps run Active Job on [GoodJob](https://github.com/bensheldon/good_job), installed by `bin/rails g trek:install` (or on its own with `bin/rails g trek:install:good_job`). GoodJob stores its queue in the application's own PostgreSQL database, so there is no second database to provision — which is why the installer removes the Solid Queue setup `rails new` generates.
4
4
 
5
5
  ## What the installer sets up
6
6
 
@@ -39,15 +39,20 @@ The thread counts have to stay within `GOOD_JOB_MAX_THREADS` — they are databa
39
39
 
40
40
  ## Scheduled jobs (cron)
41
41
 
42
- Recurring jobs are declared in the initializer, and only run in production (a development machine should not fire them):
42
+ Recurring jobs are declared in the initializer, and only run in production (a development machine should not fire them). The installer schedules the purge of the admin's expired sessions; [`trek:audit_log`](/reference/generators/audit-log#purging-old-rows) and [`trek:public_accounts`](/reference/generators/public-accounts) add their own purges at the top of the hash:
43
43
 
44
44
  ```ruby
45
45
  config.good_job.enable_cron = Rails.env.production?
46
46
  config.good_job.cron = {
47
- purge_old_sessions: {
47
+ purge_audit_logs: {
48
+ cron: "0 4 * * *",
49
+ class: "Trek::AuditLog::PurgeJob",
50
+ description: "Delete the audit log rows past the retention window"
51
+ },
52
+ purge_expired_sessions: {
48
53
  cron: "0 3 * * *", # every day at 3am
49
- class: "PurgeOldSessionsJob",
50
- description: "Delete the user sessions that expired more than a month ago"
54
+ class: "Trek::PurgeExpiredSessionsJob",
55
+ description: "Delete the admin's sessions past their idle timeout or lifetime"
51
56
  }
52
57
  }
53
58
  ```