roda-gen 1.0.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +21 -0
- data/README.md +94 -0
- data/bin/roda +11 -0
- data/lib/roda-gen.rb +3 -0
- data/lib/roda_gen/app_name.rb +29 -0
- data/lib/roda_gen/cli.rb +122 -0
- data/lib/roda_gen/generators/daemon.rb +78 -0
- data/lib/roda_gen/generators/migration.rb +68 -0
- data/lib/roda_gen/generators/migration_numbering.rb +21 -0
- data/lib/roda_gen/generators/model.rb +75 -0
- data/lib/roda_gen/generators/project.rb +145 -0
- data/lib/roda_gen/generators/route.rb +71 -0
- data/lib/roda_gen/generators/templates/daemon/bin/%daemon_name%.tt +13 -0
- data/lib/roda_gen/generators/templates/daemon/lib/daemon/%daemon_name%.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/daemon/spec/daemons/%daemon_name%_spec.rb.tt +18 -0
- data/lib/roda_gen/generators/templates/migration/db/migrate/%migration_filename%.rb.tt +6 -0
- data/lib/roda_gen/generators/templates/model/db/migrate/%migration_filename%.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/model/models/%resource_name%.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/model/spec/models/%resource_name%_spec.rb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/%app_name%.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/.bundle/config.tt +3 -0
- data/lib/roda_gen/generators/templates/project/.erb_lint.yml.tt +29 -0
- data/lib/roda_gen/generators/templates/project/.gitignore.tt +19 -0
- data/lib/roda_gen/generators/templates/project/.reek.yml.tt +45 -0
- data/lib/roda_gen/generators/templates/project/.rspec.tt +4 -0
- data/lib/roda_gen/generators/templates/project/.rubocop.yml.tt +119 -0
- data/lib/roda_gen/generators/templates/project/.ruby-version.tt +1 -0
- data/lib/roda_gen/generators/templates/project/.rubycritic.yml.tt +15 -0
- data/lib/roda_gen/generators/templates/project/Gemfile.tt +109 -0
- data/lib/roda_gen/generators/templates/project/Procfile.dev.tt +7 -0
- data/lib/roda_gen/generators/templates/project/README.md.tt +891 -0
- data/lib/roda_gen/generators/templates/project/Rakefile.tt +3 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/admin.js.tt +84 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/app.js.tt +29 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/push.js.tt +53 -0
- data/lib/roda_gen/generators/templates/project/assets/javascripts/upload.js.tt +200 -0
- data/lib/roda_gen/generators/templates/project/assets/stylesheets/app.css.tt +52 -0
- data/lib/roda_gen/generators/templates/project/assets/stylesheets/typography.css.tt +85 -0
- data/lib/roda_gen/generators/templates/project/bin/console.tt +2 -0
- data/lib/roda_gen/generators/templates/project/bin/dev.tt +8 -0
- data/lib/roda_gen/generators/templates/project/bin/gdpr_worker.tt +13 -0
- data/lib/roda_gen/generators/templates/project/bin/push_sender.tt +13 -0
- data/lib/roda_gen/generators/templates/project/bin/setup.tt +224 -0
- data/lib/roda_gen/generators/templates/project/bin/shrine_clean_cache.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/boot.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/config/console.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/database.rb.tt +45 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/00_environments.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/01_logger.rb.tt +46 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/02_app_config.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/10_database.rb.tt +3 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/15_mail.rb.tt +53 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/20_redis.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/25_rack_attack.rb.tt +96 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/30_i18n.rb.tt +37 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/35_listen_job.rb.tt +4 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/37_shrine.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/40_routing.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/41_render.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/43_static.rb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/44_sessions.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/45_security.rb.tt +49 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/46_flash.rb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/47_json.rb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/48_errors.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/49_misc.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/50_mailer.rb.tt +52 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/51_locale_kit.rb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/52_consent_kit.rb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/55_audit_log.rb.tt +16 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/56_form_helper.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/57_rodauth.rb.tt +304 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/60_web_push.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/61_flipper.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/config/initializers/62_split.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/config/puma.rb.tt +24 -0
- data/lib/roda_gen/generators/templates/project/config/settings/development.yml.tt +9 -0
- data/lib/roda_gen/generators/templates/project/config/settings/production.yml.tt +13 -0
- data/lib/roda_gen/generators/templates/project/config/settings/test.yml.tt +9 -0
- data/lib/roda_gen/generators/templates/project/config/settings.yml.tt +45 -0
- data/lib/roda_gen/generators/templates/project/config.ru.tt +36 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_account_profiles.rb.tt +66 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_accounts.rb.tt +70 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_audit_log.rb.tt +185 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_authorization.rb.tt +68 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_countries.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_calling_codes.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_exit_codes.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_languages.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_country_time_zones.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_currencies.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_gdpr_requests.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_languages.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_push_subscriptions.rb.tt +16 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_rodauth_features.rb.tt +105 -0
- data/lib/roda_gen/generators/templates/project/db/migrate/create_settings.rb.tt +60 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_countries.csv.tt +250 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_currencies.csv.tt +162 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/01_languages.csv.tt +144 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_calling_codes.csv.tt +237 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_exit_codes.csv.tt +239 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_languages.csv.tt +226 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/02_country_time_zones.csv.tt +369 -0
- data/lib/roda_gen/generators/templates/project/db/seeds/03_setting_system_defaults.yml.tt +35 -0
- data/lib/roda_gen/generators/templates/project/db/seeds.rb.tt +69 -0
- data/lib/roda_gen/generators/templates/project/deploy/Caddyfile.tt +69 -0
- data/lib/roda_gen/generators/templates/project/deploy/logrotate/%app_name%-caddy.tt +11 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-audit-partition.service.tt +21 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-audit-partition.timer.tt +16 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-gdpr-worker.service.tt +25 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-push-sender.service.tt +25 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-shrine-cleanup.service.tt +21 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%-shrine-cleanup.timer.tt +16 -0
- data/lib/roda_gen/generators/templates/project/deploy/systemd/%app_name%.service.tt +36 -0
- data/lib/roda_gen/generators/templates/project/helpers/audit_helper.rb.tt +59 -0
- data/lib/roda_gen/generators/templates/project/helpers/authorization_helper.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/helpers/current_account_helper.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/helpers/feature_flag_helper.rb.tt +34 -0
- data/lib/roda_gen/generators/templates/project/helpers/form_helper.rb.tt +50 -0
- data/lib/roda_gen/generators/templates/project/helpers/http_cache_helper.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/helpers/logger_helper.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/helpers/split_helper.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/lib/audit_context.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/lib/audit_lookup.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/base.rb.tt +104 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/gdpr_worker.rb.tt +53 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/push_sender.rb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/daemon/shrine_cache_cleaner.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/lib/deploy_check.rb.tt +96 -0
- data/lib/roda_gen/generators/templates/project/lib/filtered_logger.rb.tt +54 -0
- data/lib/roda_gen/generators/templates/project/lib/gdpr.rb.tt +106 -0
- data/lib/roda_gen/generators/templates/project/lib/rbac_audit.rb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/.rubocop.yml.tt +4 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/audit.rake.tt +85 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/console.rake.tt +8 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/db.rake.tt +104 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/deploy.rake.tt +38 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/flags.rake.tt +47 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/gdpr.rake.tt +31 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/parser_current_shim.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/quality.rake.tt +84 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/secrets.rake.tt +154 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/spec.rake.tt +136 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/split.rake.tt +27 -0
- data/lib/roda_gen/generators/templates/project/lib/tasks/tailwind.rake.tt +35 -0
- data/lib/roda_gen/generators/templates/project/locales/de.yml.tt +325 -0
- data/lib/roda_gen/generators/templates/project/locales/en.yml.tt +321 -0
- data/lib/roda_gen/generators/templates/project/locales/es.yml.tt +326 -0
- data/lib/roda_gen/generators/templates/project/locales/fr.yml.tt +329 -0
- data/lib/roda_gen/generators/templates/project/locales/it.yml.tt +325 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/de.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/en.yml.tt +6 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/es.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/fr.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/it.yml.tt +5 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/sv.yml.tt +274 -0
- data/lib/roda_gen/generators/templates/project/locales/rodauth/tru.yml.tt +274 -0
- data/lib/roda_gen/generators/templates/project/locales/sv.yml.tt +319 -0
- data/lib/roda_gen/generators/templates/project/locales/tru.yml.tt +294 -0
- data/lib/roda_gen/generators/templates/project/log/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/models/account.rb.tt +50 -0
- data/lib/roda_gen/generators/templates/project/models/account_privilege.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/models/account_profile.rb.tt +115 -0
- data/lib/roda_gen/generators/templates/project/models/account_role.rb.tt +14 -0
- data/lib/roda_gen/generators/templates/project/models/audit_action.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/models/audit_actor_type.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/models/audit_log.rb.tt +257 -0
- data/lib/roda_gen/generators/templates/project/models/audit_status.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/models/country.rb.tt +17 -0
- data/lib/roda_gen/generators/templates/project/models/country_calling_code.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/country_exit_code.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/country_language.rb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/models/country_time_zone.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/currency.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/gdpr_request.rb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/models/gender.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/models/language.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/models/privilege.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/models/push_subscription.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/models/role.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/models/role_privilege.rb.tt +14 -0
- data/lib/roda_gen/generators/templates/project/models/setting_system_default.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/models/setting_user_value.rb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/models/settings.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/models/signup_form_data.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/models.rb.tt +6 -0
- data/lib/roda_gen/generators/templates/project/package.json.tt +13 -0
- data/lib/roda_gen/generators/templates/project/public/apple-touch-icon.png +0 -0
- data/lib/roda_gen/generators/templates/project/public/favicon.ico +0 -0
- data/lib/roda_gen/generators/templates/project/public/favicon.svg.tt +5 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/JetBrainsMono-Italic-Variable.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/JetBrainsMono-Variable.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-BoldItalic.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Italic.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/Lato-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NOTICE.md +17 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriac-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriac-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriacWestern-Bold.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/fonts/NotoSansSyriacWestern-Regular.woff2 +0 -0
- data/lib/roda_gen/generators/templates/project/public/manifest.webmanifest.tt +12 -0
- data/lib/roda_gen/generators/templates/project/public/robots.txt.tt +4 -0
- data/lib/roda_gen/generators/templates/project/public/service-worker.js.tt +27 -0
- data/lib/roda_gen/generators/templates/project/routes/account.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/routes/admin.rb.tt +118 -0
- data/lib/roda_gen/generators/templates/project/routes/gdpr.rb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/routes/heartbeat.rb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/routes/legal.rb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/routes/profile.rb.tt +56 -0
- data/lib/roda_gen/generators/templates/project/routes/push.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/role_boundary_spec.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/spec_helper.rb.tt +146 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/support/auth_helpers.rb.tt +71 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/auth_spec.rb.tt +25 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/consent_nojs_spec.rb.tt +60 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/create_account_form_spec.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/otp_lifecycle_spec.rb.tt +67 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/profile_form_spec.rb.tt +17 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/uat/upload_spec.rb.tt +102 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/wcag/auth_pages_spec.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/spec/browser/wcag/legal_pages_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/base_spec.rb.tt +106 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/gdpr_worker_spec.rb.tt +72 -0
- data/lib/roda_gen/generators/templates/project/spec/daemons/push_sender_spec.rb.tt +74 -0
- data/lib/roda_gen/generators/templates/project/spec/locale_parity_spec.rb.tt +58 -0
- data/lib/roda_gen/generators/templates/project/spec/models/account_profile_spec.rb.tt +180 -0
- data/lib/roda_gen/generators/templates/project/spec/models/account_spec.rb.tt +104 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_actor_type_spec.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_log_spec.rb.tt +398 -0
- data/lib/roda_gen/generators/templates/project/spec/models/audit_status_spec.rb.tt +7 -0
- data/lib/roda_gen/generators/templates/project/spec/models/authorization_spec.rb.tt +82 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_calling_code_spec.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_exit_code_spec.rb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_language_spec.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_spec.rb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/spec/models/country_time_zone_spec.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/spec/models/currency_spec.rb.tt +9 -0
- data/lib/roda_gen/generators/templates/project/spec/models/deploy_check_spec.rb.tt +143 -0
- data/lib/roda_gen/generators/templates/project/spec/models/gdpr_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/models/language_spec.rb.tt +15 -0
- data/lib/roda_gen/generators/templates/project/spec/models/rbac_audit_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/models/setting_system_default_spec.rb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/spec/models/setting_user_value_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/models/settings_spec.rb.tt +63 -0
- data/lib/roda_gen/generators/templates/project/spec/models/signup_form_data_spec.rb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/spec/spec_helper.rb.tt +93 -0
- data/lib/roda_gen/generators/templates/project/spec/support/audit_log_helpers.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/support/audit_lookup_shared_examples.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/spec/support/auth_helpers.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/support/faker.rb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/spec/web/admin_spec.rb.tt +155 -0
- data/lib/roda_gen/generators/templates/project/spec/web/audit_log_spec.rb.tt +159 -0
- data/lib/roda_gen/generators/templates/project/spec/web/auth_spec.rb.tt +492 -0
- data/lib/roda_gen/generators/templates/project/spec/web/authorization_spec.rb.tt +110 -0
- data/lib/roda_gen/generators/templates/project/spec/web/boot_spec.rb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/spec/web/consent_banner_spec.rb.tt +46 -0
- data/lib/roda_gen/generators/templates/project/spec/web/feature_flag_helper_spec.rb.tt +33 -0
- data/lib/roda_gen/generators/templates/project/spec/web/flags_spec.rb.tt +67 -0
- data/lib/roda_gen/generators/templates/project/spec/web/gdpr_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/heartbeat_spec.rb.tt +65 -0
- data/lib/roda_gen/generators/templates/project/spec/web/host_allowlist_spec.rb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/spec/web/legal_spec.rb.tt +61 -0
- data/lib/roda_gen/generators/templates/project/spec/web/locale_resolver_spec.rb.tt +34 -0
- data/lib/roda_gen/generators/templates/project/spec/web/logger_helper_spec.rb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/spec/web/logger_spec.rb.tt +82 -0
- data/lib/roda_gen/generators/templates/project/spec/web/otp_audit_spec.rb.tt +147 -0
- data/lib/roda_gen/generators/templates/project/spec/web/profile_spec.rb.tt +97 -0
- data/lib/roda_gen/generators/templates/project/spec/web/push_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rack_attack_runtime_spec.rb.tt +52 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rack_attack_spec.rb.tt +81 -0
- data/lib/roda_gen/generators/templates/project/spec/web/rbac_audit_spec.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/web/request_id_spec.rb.tt +62 -0
- data/lib/roda_gen/generators/templates/project/spec/web/role_boundary_spec.rb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/spec/web/session_skip_spec.rb.tt +74 -0
- data/lib/roda_gen/generators/templates/project/spec/web/split_helper_spec.rb.tt +38 -0
- data/lib/roda_gen/generators/templates/project/spec/web/type_routing_spec.rb.tt +55 -0
- data/lib/roda_gen/generators/templates/project/spec/web/upload_zone_spec.rb.tt +91 -0
- data/lib/roda_gen/generators/templates/project/tmp/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/vendor/.keep.tt +0 -0
- data/lib/roda_gen/generators/templates/project/views/403.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/404.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/500.erb.tt +12 -0
- data/lib/roda_gen/generators/templates/project/views/_head_meta.erb.tt +29 -0
- data/lib/roda_gen/generators/templates/project/views/_impersonate_picker.erb.tt +21 -0
- data/lib/roda_gen/generators/templates/project/views/_language_switcher.erb.tt +22 -0
- data/lib/roda_gen/generators/templates/project/views/_locked_accounts.erb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/views/_upload_zone.erb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/views/account/profile.erb.tt +149 -0
- data/lib/roda_gen/generators/templates/project/views/admin/flags.erb.tt +51 -0
- data/lib/roda_gen/generators/templates/project/views/consent_kit/_banner.erb.tt +59 -0
- data/lib/roda_gen/generators/templates/project/views/consent_kit/_preferences.erb.tt +87 -0
- data/lib/roda_gen/generators/templates/project/views/gdpr/erased.erb.tt +6 -0
- data/lib/roda_gen/generators/templates/project/views/gdpr/index.erb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/views/layout.erb.tt +112 -0
- data/lib/roda_gen/generators/templates/project/views/legal/contact.erb.tt +44 -0
- data/lib/roda_gen/generators/templates/project/views/legal/cookies.erb.tt +47 -0
- data/lib/roda_gen/generators/templates/project/views/legal/disclaimer.erb.tt +19 -0
- data/lib/roda_gen/generators/templates/project/views/legal/privacy.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/account_unlocked.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/data_erased.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/mailers/data_export.erb.tt +5 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/add-recovery-codes.erb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/change-login.erb.tt +44 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/change-password.erb.tt +41 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/close-account.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/confirm-password.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/create-account.erb.tt +183 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/login.erb.tt +51 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/logout.erb.tt +10 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-auth.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-disable.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-setup.erb.tt +48 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-unlock-not-available.erb.tt +18 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/otp-unlock.erb.tt +28 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/recovery-auth.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/recovery-codes.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/remember.erb.tt +35 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/reset-password-request.erb.tt +27 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/reset-password.erb.tt +30 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-auth.erb.tt +8 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-disable.erb.tt +20 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/two-factor-manage.erb.tt +36 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/unlock-account-request.erb.tt +13 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/unlock-account.erb.tt +23 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-account-resend.erb.tt +26 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-account.erb.tt +32 -0
- data/lib/roda_gen/generators/templates/project/views/rodauth/verify-login-change.erb.tt +8 -0
- data/lib/roda_gen/generators/templates/route/routes/%plural%.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/route/spec/web/%plural%_spec.rb.tt +36 -0
- data/lib/roda_gen/generators/templates/route/views/%plural%/index.erb.tt +11 -0
- data/lib/roda_gen/generators/templates/route/views/%plural%/show.erb.tt +7 -0
- data/lib/roda_gen/generators/templates/upload/db/migrate/%migration_filename%.rb.tt +13 -0
- data/lib/roda_gen/generators/templates/upload/helpers/upload_serving.rb.tt +43 -0
- data/lib/roda_gen/generators/templates/upload/models/%resource_name%.rb.tt +11 -0
- data/lib/roda_gen/generators/templates/upload/models/%resource_name%_uploader.rb.tt +19 -0
- data/lib/roda_gen/generators/templates/upload/routes/%plural%.rb.tt +44 -0
- data/lib/roda_gen/generators/templates/upload/spec/web/%plural%_spec.rb.tt +56 -0
- data/lib/roda_gen/generators/templates/upload/views/%plural%/index.erb.tt +18 -0
- data/lib/roda_gen/generators/upload.rb +83 -0
- data/lib/roda_gen/project_context.rb +30 -0
- data/lib/roda_gen/version.rb +5 -0
- data/lib/roda_gen.rb +16 -0
- metadata +497 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Served from / so the scope covers the whole origin. Payload is the JSON
|
|
2
|
+
// lib/daemon/push_sender.rb sends: { title, body, icon, url, tag }
|
|
3
|
+
self.addEventListener('push', function (event) {
|
|
4
|
+
var data = {};
|
|
5
|
+
try { data = event.data ? event.data.json() : {}; } catch (e) { data = {}; }
|
|
6
|
+
var title = data.title || '<%= @app.human %>';
|
|
7
|
+
var options = {
|
|
8
|
+
body: data.body || '',
|
|
9
|
+
icon: data.icon || '/apple-touch-icon.png',
|
|
10
|
+
data: { url: data.url || '/' },
|
|
11
|
+
tag: data.tag
|
|
12
|
+
};
|
|
13
|
+
event.waitUntil(self.registration.showNotification(title, options));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
self.addEventListener('notificationclick', function (event) {
|
|
17
|
+
event.notification.close();
|
|
18
|
+
var url = (event.notification.data && event.notification.data.url) || '/';
|
|
19
|
+
event.waitUntil(
|
|
20
|
+
self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then(function (windowClients) {
|
|
21
|
+
for (var i = 0; i < windowClients.length; i++) {
|
|
22
|
+
if (windowClients[i].url === url && 'focus' in windowClients[i]) return windowClients[i].focus();
|
|
23
|
+
}
|
|
24
|
+
return self.clients.openWindow ? self.clients.openWindow(url) : null;
|
|
25
|
+
})
|
|
26
|
+
);
|
|
27
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Rodauth's own /account/* routes (login, change-*) never reach this branch, <%= @app.snake %>.rb runs
|
|
4
|
+
# r.rodauth before r.hash_branches so only the app's own /account/* pages fall through
|
|
5
|
+
class <%= @app.camel %>
|
|
6
|
+
hash_branch('account') do |r|
|
|
7
|
+
rodauth.require_authentication
|
|
8
|
+
r.hash_branches('account')
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# POST actions take the target id in the body so one route_csrf token covers each fixed path
|
|
4
|
+
class <%= @app.camel %>
|
|
5
|
+
ADMIN_ACCOUNT_COLUMNS = [
|
|
6
|
+
Sequel[:accounts][:id].as(:id),
|
|
7
|
+
Sequel[:accounts][:email].as(:email),
|
|
8
|
+
Sequel[:account_profiles][:first_name].as(:first_name),
|
|
9
|
+
Sequel[:account_profiles][:last_name].as(:last_name)
|
|
10
|
+
].freeze
|
|
11
|
+
|
|
12
|
+
hash_branch('admin') do |r|
|
|
13
|
+
rodauth.require_authentication
|
|
14
|
+
|
|
15
|
+
r.on 'accounts' do
|
|
16
|
+
r.get 'search' do
|
|
17
|
+
require_privilege! 'accounts.impersonate'
|
|
18
|
+
query = r.params['q'].to_s.strip
|
|
19
|
+
next [] if query.empty?
|
|
20
|
+
|
|
21
|
+
term = "%#{query.gsub(/[%_\\]/, '\\\\\\0')}%"
|
|
22
|
+
admin_account_rows(
|
|
23
|
+
Account
|
|
24
|
+
.exclude(Sequel[:accounts][:id] => DB[:account_lockouts].select(:id))
|
|
25
|
+
.where(Sequel.ilike(Sequel[:accounts][:email], term) |
|
|
26
|
+
Sequel.ilike(Sequel[:account_profiles][:first_name], term) |
|
|
27
|
+
Sequel.ilike(Sequel[:account_profiles][:last_name], term))
|
|
28
|
+
.limit(10)
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
r.get 'locked' do
|
|
33
|
+
require_privilege! 'accounts.unlock'
|
|
34
|
+
admin_account_rows(
|
|
35
|
+
Account.where(Sequel[:accounts][:id] => DB[:account_lockouts].select(:id)).limit(50)
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
r.post 'unlock' do
|
|
40
|
+
require_privilege! 'accounts.unlock'
|
|
41
|
+
target = admin_target!(r)
|
|
42
|
+
DB[:account_lockouts].where(id: target.id).delete
|
|
43
|
+
DB[:account_login_failures].where(id: target.id).delete
|
|
44
|
+
<%= @app.camel %>Mailer.sendmail('/account-unlocked', target.email, I18n.locale.to_s)
|
|
45
|
+
audit_admin_action('admin.account.unlock', target)
|
|
46
|
+
flash[:notice] = t('admin.locked_accounts.unlocked', email: target.email)
|
|
47
|
+
r.redirect '/'
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
r.on 'flags' do
|
|
52
|
+
r.get true do
|
|
53
|
+
require_privilege! 'flags.read'
|
|
54
|
+
@flags = Flipper.features.sort_by(&:key)
|
|
55
|
+
@can_manage = current_account.privilege?('flags.manage')
|
|
56
|
+
view('admin/flags')
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
r.post true do
|
|
60
|
+
require_privilege! 'flags.manage'
|
|
61
|
+
key = r.params['key'].to_s.strip
|
|
62
|
+
r.halt(422) if key.empty?
|
|
63
|
+
|
|
64
|
+
Flipper.add(key)
|
|
65
|
+
audit_flag(key, 'add')
|
|
66
|
+
flash[:notice] = t('admin.flags.created', key: key)
|
|
67
|
+
r.redirect '/admin/flags'
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
r.post String do |key|
|
|
71
|
+
require_privilege! 'flags.manage'
|
|
72
|
+
apply_flag_op(Flipper[key], r.params['op'].to_s, r.params['value'])
|
|
73
|
+
audit_flag(key, r.params['op'].to_s)
|
|
74
|
+
flash[:notice] = t('admin.flags.updated', key: key)
|
|
75
|
+
r.redirect '/admin/flags'
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Audit before setting the session key, current_account becomes the target once it is set
|
|
80
|
+
r.post 'impersonate' do
|
|
81
|
+
require_privilege! 'accounts.impersonate'
|
|
82
|
+
target = admin_target!(r)
|
|
83
|
+
audit_admin_action('admin.impersonate.start', target)
|
|
84
|
+
session['impersonating_as'] = target.id
|
|
85
|
+
r.redirect '/'
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# current_account is the target while impersonating, resolve the admin before clearing the key
|
|
89
|
+
r.post 'stop-impersonating' do
|
|
90
|
+
admin = impersonating? ? Account.with_pk(impersonator_account_id) : current_account
|
|
91
|
+
session.delete('impersonating_as')
|
|
92
|
+
log_audit(action: 'admin.impersonate.stop', actor_type: :admin,
|
|
93
|
+
actor_id: admin.id, actor_label: admin.email, status: :success)
|
|
94
|
+
r.redirect '/'
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def admin_target!(request)
|
|
99
|
+
target = Account.with_pk(request.params['account_id'].to_i)
|
|
100
|
+
request.halt(404) unless target
|
|
101
|
+
target
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# current_account is the admin here, privilege-gated routes never run while impersonating
|
|
105
|
+
def audit_admin_action(action, target)
|
|
106
|
+
log_audit(action: action, actor_type: :admin, actor_id: current_account.id,
|
|
107
|
+
actor_label: current_account.email, status: :success,
|
|
108
|
+
payload: { target_account_id: target.id })
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def admin_account_rows(dataset)
|
|
112
|
+
dataset
|
|
113
|
+
.join(:account_profiles, account_id: :id)
|
|
114
|
+
.select(*ADMIN_ACCOUNT_COLUMNS)
|
|
115
|
+
.naked.all
|
|
116
|
+
.map { |row| { id: row[:id], email: row[:email], name: "#{row[:first_name]} #{row[:last_name]}".strip } }
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Actions only enqueue, lib/daemon/gdpr_worker.rb does the audit-log redaction the web role can't
|
|
4
|
+
class <%= @app.camel %>
|
|
5
|
+
hash_branch('account', 'gdpr') do |r|
|
|
6
|
+
rodauth.require_password_authentication
|
|
7
|
+
|
|
8
|
+
r.get { view('gdpr/index') }
|
|
9
|
+
|
|
10
|
+
r.post('export') do
|
|
11
|
+
log_audit(action: 'user.data.export', actor_type: :user, actor_id: current_account.id)
|
|
12
|
+
GdprRequest.enqueue(current_account.id, :export)
|
|
13
|
+
flash[:notice] = t('gdpr.export.queued')
|
|
14
|
+
r.redirect '/account/gdpr'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
r.post('erase') do
|
|
18
|
+
r.redirect '/account/gdpr' unless r.params['confirm'] == '1'
|
|
19
|
+
|
|
20
|
+
account = current_account
|
|
21
|
+
log_audit(action: 'user.data.erase', actor_type: :user, actor_id: account.id)
|
|
22
|
+
account.update(status_id: 3)
|
|
23
|
+
GdprRequest.enqueue(account.id, :erase)
|
|
24
|
+
rodauth.clear_session
|
|
25
|
+
r.redirect '/data-erased'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
hash_branch('data-erased') do |r|
|
|
30
|
+
r.get { view('gdpr/erased') }
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Responses stay opaque ('ok'/'not ok'), diagnostic detail belongs in the app log
|
|
4
|
+
# Path is excluded from locale-prefix and consent gating in 51_locale_kit.rb and 52_consent_kit.rb
|
|
5
|
+
|
|
6
|
+
class <%= @app.camel %>
|
|
7
|
+
hash_branch('heartbeat') do |r|
|
|
8
|
+
r.get('live') { 'ok' }
|
|
9
|
+
r.get('db') { db_alive? ? 'ok' : r.halt(503, 'not ok') }
|
|
10
|
+
r.get('redis') { redis_alive? ? 'ok' : r.halt(503, 'not ok') }
|
|
11
|
+
|
|
12
|
+
r.get do
|
|
13
|
+
checks = { db: db_alive?, redis: redis_alive? }
|
|
14
|
+
status = checks.values.all? ? 200 : 503
|
|
15
|
+
summary = checks.transform_values { |ok| ok ? 'ok' : 'down' }
|
|
16
|
+
|
|
17
|
+
response['Content-Type'] = 'application/json'
|
|
18
|
+
r.halt(status, summary.to_json)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def db_alive?
|
|
23
|
+
DB.fetch('SELECT 1').first
|
|
24
|
+
true
|
|
25
|
+
rescue StandardError
|
|
26
|
+
false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def redis_alive?
|
|
30
|
+
REDIS.with(&:ping)
|
|
31
|
+
true
|
|
32
|
+
rescue StandardError
|
|
33
|
+
false
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Legally required on a Swedish commercial site: contact/Impressum (E-handelslag 2 § 7, EU 2000/31/EC Art. 5),
|
|
4
|
+
# privacy (GDPR Art. 13/14), cookies (ePrivacy + GDPR), disclaimer
|
|
5
|
+
|
|
6
|
+
class <%= @app.camel %>
|
|
7
|
+
hash_branch('legal') do |r|
|
|
8
|
+
r.get('contact') { cache_page(view('contact')) }
|
|
9
|
+
r.get('privacy') { cache_page(view('privacy')) }
|
|
10
|
+
r.get('disclaimer') { cache_page(view('disclaimer')) }
|
|
11
|
+
|
|
12
|
+
r.get('cookies') do
|
|
13
|
+
@categories = ConsentKit.categories
|
|
14
|
+
@services_by_cat = ConsentKit.categories.to_h do |cat|
|
|
15
|
+
[cat, ConsentKit.registry.by_category(cat)]
|
|
16
|
+
end
|
|
17
|
+
cache_page(view('cookies'))
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Email changes go through Rodauth's /account/change-login, personal_identity_number is immutable after signup
|
|
4
|
+
class <%= @app.camel %>
|
|
5
|
+
hash_branch('account', 'profile') do |r|
|
|
6
|
+
r.get do
|
|
7
|
+
@profile = current_account.profile
|
|
8
|
+
view('account/profile')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
r.post do
|
|
12
|
+
profile = current_account.profile
|
|
13
|
+
# Blank optional fields submit "", coerce to nil so the gender FK accepts them
|
|
14
|
+
optional = ->(key) { (v = r.params[key]) && !v.empty? ? v : nil }
|
|
15
|
+
attrs = {
|
|
16
|
+
first_name: r.params['first_name'],
|
|
17
|
+
last_name: r.params['last_name'],
|
|
18
|
+
address: r.params['address'],
|
|
19
|
+
postal_code: r.params['postal_code'],
|
|
20
|
+
city: r.params['city'],
|
|
21
|
+
country: r.params['country'],
|
|
22
|
+
language: r.params['language'],
|
|
23
|
+
time_zone: r.params['time_zone'],
|
|
24
|
+
mobile_number: r.params['mobile_number'],
|
|
25
|
+
gender: optional.call('gender')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
profile.set(attrs)
|
|
29
|
+
if profile.valid?
|
|
30
|
+
DB.transaction do
|
|
31
|
+
profile.save_changes
|
|
32
|
+
# previous_changes (:dirty plugin) is nil when save_changes was a no-op and empty when nothing
|
|
33
|
+
# stayed dirty, no audit either way
|
|
34
|
+
changes = profile.previous_changes
|
|
35
|
+
if changes&.any?
|
|
36
|
+
log_audit(
|
|
37
|
+
action: 'user.profile.update',
|
|
38
|
+
actor_type: :user,
|
|
39
|
+
actor_id: current_account.id,
|
|
40
|
+
payload: {
|
|
41
|
+
before: changes.transform_values(&:first),
|
|
42
|
+
after: changes.transform_values(&:last)
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
flash[:notice] = t('forms.profile.updated_flash')
|
|
48
|
+
r.redirect '/account/profile'
|
|
49
|
+
else
|
|
50
|
+
@profile = profile
|
|
51
|
+
@field_errors = profile.errors
|
|
52
|
+
view('account/profile')
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# assets/javascripts/push.js posts form-encoded so the route_csrf token rides in _csrf
|
|
4
|
+
class <%= @app.camel %>
|
|
5
|
+
hash_branch('push') do |r|
|
|
6
|
+
rodauth.require_authentication
|
|
7
|
+
|
|
8
|
+
r.post 'subscribe' do
|
|
9
|
+
endpoint = r.params['endpoint'].to_s
|
|
10
|
+
p256dh = r.params['p256dh'].to_s
|
|
11
|
+
auth = r.params['auth'].to_s
|
|
12
|
+
r.halt(422) if [endpoint, p256dh, auth].any?(&:empty?)
|
|
13
|
+
|
|
14
|
+
PushSubscription.upsert(account_id: current_account.id, endpoint:, p256dh:, auth_key: auth)
|
|
15
|
+
response.status = 204
|
|
16
|
+
''
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
r.post 'unsubscribe' do
|
|
20
|
+
PushSubscription.where(account_id: current_account.id, endpoint: r.params['endpoint'].to_s).delete
|
|
21
|
+
response.status = 204
|
|
22
|
+
''
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'browser-suite role boundary' do
|
|
6
|
+
it 'browser specs drive the in-process app as the foo_web role' do
|
|
7
|
+
role = DB[Sequel.lit('SELECT current_user')].get(:current_user)
|
|
8
|
+
expect(role).to end_with('_web')
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
ENV['RACK_ENV'] ||= 'test'
|
|
4
|
+
|
|
5
|
+
# Web role so the production GRANT boundary is exercised end-to-end
|
|
6
|
+
ENV['DATABASE_ROLE'] ||= 'web'
|
|
7
|
+
|
|
8
|
+
require_relative '../spec_helper'
|
|
9
|
+
|
|
10
|
+
require 'capybara/rspec'
|
|
11
|
+
require 'capybara/playwright'
|
|
12
|
+
# Only for the bundled axe.min.js
|
|
13
|
+
require 'axe/configuration'
|
|
14
|
+
|
|
15
|
+
PLAYWRIGHT_BROWSER = ENV.fetch('PLAYWRIGHT_BROWSER', 'firefox').to_sym
|
|
16
|
+
|
|
17
|
+
Capybara.register_driver(:playwright) do |app|
|
|
18
|
+
Capybara::Playwright::Driver.new(
|
|
19
|
+
app,
|
|
20
|
+
browser_type: PLAYWRIGHT_BROWSER,
|
|
21
|
+
headless: true,
|
|
22
|
+
# Project-local CLI, pinned to the playwright-ruby-client version
|
|
23
|
+
playwright_cli_executable_path: File.expand_path('../../node_modules/.bin/playwright', __dir__)
|
|
24
|
+
)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Capybara.default_driver = :playwright
|
|
28
|
+
Capybara.javascript_driver = :playwright
|
|
29
|
+
# Freeze a subclass, not the class, Roda refuses to subclass a frozen app and uat/upload_spec.rb
|
|
30
|
+
# mounts its own Class.new(<%= @app.camel %>)
|
|
31
|
+
Capybara.app = Class.new(<%= @app.camel %>).freeze.app
|
|
32
|
+
Capybara.server = :puma, { Silent: true }
|
|
33
|
+
|
|
34
|
+
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f }
|
|
35
|
+
|
|
36
|
+
# axe-core-rspec's matcher needs Selenium APIs the Playwright driver lacks, so inject and run axe
|
|
37
|
+
# through Capybara. axe.run with no options covers WCAG 2.0/2.1 A + AA
|
|
38
|
+
module AxeAudit
|
|
39
|
+
module_function
|
|
40
|
+
|
|
41
|
+
def violations(page, run_options = {}) # rubocop:disable Metrics/MethodLength -- inline JS heredoc dominates the line count
|
|
42
|
+
page.execute_script(Axe::Configuration.instance.jslib)
|
|
43
|
+
page.evaluate_async_script(<<~JS, run_options)
|
|
44
|
+
var options = arguments[0] || {};
|
|
45
|
+
var done = arguments[arguments.length - 1];
|
|
46
|
+
// Wait for fonts and stylesheets, axe otherwise scans mid-paint and trips color-contrast on
|
|
47
|
+
// default-styled elements. 2s per-resource cap so one slow asset can't hang the suite
|
|
48
|
+
var sheetReady = function(link) {
|
|
49
|
+
if (link.sheet) return Promise.resolve();
|
|
50
|
+
return new Promise(function(resolve) {
|
|
51
|
+
var done = function() { resolve(); };
|
|
52
|
+
link.addEventListener('load', done, { once: true });
|
|
53
|
+
link.addEventListener('error', done, { once: true });
|
|
54
|
+
setTimeout(done, 2000);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
// Two rAF ticks buy a full paint cycle so computed styles read final colors, not mid-paint values
|
|
58
|
+
var nextPaint = function() {
|
|
59
|
+
return new Promise(function(resolve) {
|
|
60
|
+
requestAnimationFrame(function() {
|
|
61
|
+
requestAnimationFrame(function() { resolve(); });
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
// Rodauth autofocuses the login field and its focus-ring transition left axe reading a mid-transition
|
|
66
|
+
// colour, an intermittent color-contrast fail. 1s cap per animation so an infinite one can't hang
|
|
67
|
+
var animationsSettled = function() {
|
|
68
|
+
var anims = document.getAnimations ? document.getAnimations() : [];
|
|
69
|
+
return Promise.all(anims.map(function(a) {
|
|
70
|
+
return Promise.race([
|
|
71
|
+
a.finished.catch(function() {}),
|
|
72
|
+
new Promise(function(resolve) { setTimeout(resolve, 1000); })
|
|
73
|
+
]);
|
|
74
|
+
}));
|
|
75
|
+
};
|
|
76
|
+
Promise.all([
|
|
77
|
+
document.fonts.ready,
|
|
78
|
+
Promise.all(Array.from(document.querySelectorAll('link[rel="stylesheet"]')).map(sheetReady))
|
|
79
|
+
])
|
|
80
|
+
.then(nextPaint)
|
|
81
|
+
.then(animationsSettled)
|
|
82
|
+
.then(nextPaint)
|
|
83
|
+
.then(function() { return window.axe.run(document, options); })
|
|
84
|
+
.then(function(r) { done(r.violations); })
|
|
85
|
+
.catch(function(e) { done([{ id: 'axe-run-error', impact: 'critical', help: e.message, helpUrl: '', nodes: [{}] }]); });
|
|
86
|
+
JS
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
RSpec::Matchers.define :be_axe_clean do |run_options = {}|
|
|
91
|
+
match do |page|
|
|
92
|
+
# WCAG audits the page at rest, not the consent interstitial
|
|
93
|
+
page.execute_script("document.querySelectorAll('dialog[open]').forEach(function(d){ d.close(); })")
|
|
94
|
+
@violations = AxeAudit.violations(page, run_options)
|
|
95
|
+
@violations.empty?
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
failure_message do |_page|
|
|
99
|
+
details = @violations.map do |v|
|
|
100
|
+
count = Array(v['nodes']).size
|
|
101
|
+
" • [#{v['impact']}] #{v['id']} — #{v['help']} (#{count} node#{'s' unless count == 1})\n #{v['helpUrl']}"
|
|
102
|
+
end
|
|
103
|
+
'expected the page to have no axe-core accessibility violations, ' \
|
|
104
|
+
"but found #{@violations.size}:\n\n#{details.join("\n")}"
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Accept consent via fetch on first visit so the open <dialog> banner doesn't intercept later clicks.
|
|
109
|
+
# Specs testing the first-visit flow use their own session (uat/consent_nojs_spec.rb)
|
|
110
|
+
module AcceptConsentOnVisit # rubocop:disable Style/OneClassPerFile
|
|
111
|
+
def visit(*args, **kwargs)
|
|
112
|
+
result = super
|
|
113
|
+
page.evaluate_async_script(<<~JS)
|
|
114
|
+
var done = arguments[arguments.length - 1];
|
|
115
|
+
var dialog = document.getElementById('consent-banner-dialog');
|
|
116
|
+
if (!dialog || !dialog.open) { done(true); return; }
|
|
117
|
+
// Close visually so the next click can land while fetch is in flight
|
|
118
|
+
dialog.close();
|
|
119
|
+
var form = document.getElementById('consent-kit-accept-all-form');
|
|
120
|
+
if (!form) { done(true); return; }
|
|
121
|
+
fetch(form.action, { method: 'POST', body: new FormData(form), credentials: 'same-origin' })
|
|
122
|
+
.then(function(){ done(true); })
|
|
123
|
+
.catch(function(){ done(true); });
|
|
124
|
+
JS
|
|
125
|
+
result
|
|
126
|
+
rescue Capybara::NotSupportedByDriverError
|
|
127
|
+
result
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
RSpec.configure do |config|
|
|
132
|
+
config.define_derived_metadata(file_path: %r{/spec/browser/}) do |meta|
|
|
133
|
+
meta[:type] = :browser
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# capybara/rspec auto-includes only on :feature/:system
|
|
137
|
+
config.include Capybara::DSL, type: :browser
|
|
138
|
+
config.include Capybara::RSpecMatchers, type: :browser
|
|
139
|
+
config.include BrowserAuthHelpers, type: :browser
|
|
140
|
+
config.prepend AcceptConsentOnVisit, type: :browser
|
|
141
|
+
|
|
142
|
+
# One Playwright session per file, reset cookies and storage between examples
|
|
143
|
+
config.before(:each, type: :browser) do
|
|
144
|
+
Capybara.reset_sessions!
|
|
145
|
+
end
|
|
146
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module BrowserAuthHelpers
|
|
4
|
+
DEFAULT_PASSWORD = 'correct horse battery staple'
|
|
5
|
+
|
|
6
|
+
# URLs locked to /en/ so the labels stay English. Selecting Sweden fires the chain JS that auto-picks
|
|
7
|
+
# Swedish, pass language: 'en' when later assertions rely on English Rodauth button text
|
|
8
|
+
def sign_up(email:, password: DEFAULT_PASSWORD, country: 'Sweden', language: nil, **overrides)
|
|
9
|
+
fields = default_profile_fields.merge(overrides)
|
|
10
|
+
visit '/en/account/create-account'
|
|
11
|
+
fill_in 'login', with: email
|
|
12
|
+
fill_in 'password', with: password
|
|
13
|
+
fill_in 'password-confirm', with: password if has_field?('password-confirm')
|
|
14
|
+
fields.each { |name, value| fill_in name.to_s, with: value }
|
|
15
|
+
select country, from: 'country'
|
|
16
|
+
if language
|
|
17
|
+
# Options are grouped by country, so both label and value match several nodes. select_option on
|
|
18
|
+
# any matching option sets the parent select's value, which is all the server reads
|
|
19
|
+
first("select[name=\"language\"] option[value=\"#{language}\"]").select_option
|
|
20
|
+
end
|
|
21
|
+
click_button 'Create Account'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Unverified to Verified without the verify-account mail link
|
|
25
|
+
def verify(account)
|
|
26
|
+
account.update(status_id: 2)
|
|
27
|
+
DB[:account_verification_keys].where(id: account.id).delete
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def log_in(email:, password: DEFAULT_PASSWORD)
|
|
31
|
+
visit '/en/account/login'
|
|
32
|
+
fill_in 'login', with: email
|
|
33
|
+
fill_in 'password', with: password
|
|
34
|
+
click_button 'Login'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def log_out
|
|
38
|
+
visit '/en/account/logout'
|
|
39
|
+
click_button 'Logout' if has_button?('Logout')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def sign_up_and_verify(email:, password: DEFAULT_PASSWORD, **overrides)
|
|
43
|
+
sign_up(email: email, password: password, **overrides)
|
|
44
|
+
account = Account.first(email: email)
|
|
45
|
+
verify(account)
|
|
46
|
+
account
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def sign_up_and_log_in(email: Faker::Internet.email(name: "browser-#{SecureRandom.hex(4)}"),
|
|
50
|
+
password: DEFAULT_PASSWORD,
|
|
51
|
+
**overrides)
|
|
52
|
+
account = sign_up_and_verify(email: email, password: password, **overrides)
|
|
53
|
+
log_in(email: email, password: password)
|
|
54
|
+
account
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
# personnummer is column-unique, reusing it would 23505 on the second signup
|
|
60
|
+
def default_profile_fields
|
|
61
|
+
{
|
|
62
|
+
first_name: Faker::Name.first_name,
|
|
63
|
+
last_name: Faker::Name.last_name,
|
|
64
|
+
address: Faker::Address.street_address,
|
|
65
|
+
postal_code: Faker::Address.zip_code,
|
|
66
|
+
city: Faker::Address.city,
|
|
67
|
+
mobile_number: Faker::PhoneNumber.cell_phone,
|
|
68
|
+
personal_identity_number: Faker::IDNumber.swedish_personal_identity_number
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'UAT: authentication flow' do
|
|
6
|
+
let(:email) { "uat-#{SecureRandom.hex(4)}@example.com" }
|
|
7
|
+
let(:password) { 'correct horse battery staple' }
|
|
8
|
+
|
|
9
|
+
it 'signs up, verifies, logs in, logs out' do
|
|
10
|
+
account = sign_up_and_log_in(email: email, password: password, first_name: 'UAT')
|
|
11
|
+
expect(page).to have_current_path('/', ignore_query: true)
|
|
12
|
+
.or have_no_text('Login') # adjust to your landing route
|
|
13
|
+
|
|
14
|
+
visit '/en/account/profile'
|
|
15
|
+
expect(page).to have_field('first_name', with: 'UAT')
|
|
16
|
+
fill_in 'first_name', with: 'Updated'
|
|
17
|
+
fill_in 'city', with: 'Göteborg'
|
|
18
|
+
click_button 'Save profile'
|
|
19
|
+
expect(account.reload.profile.first_name).to eq('Updated')
|
|
20
|
+
expect(account.profile.city).to eq('Göteborg')
|
|
21
|
+
|
|
22
|
+
log_out
|
|
23
|
+
expect(DB[:account_active_session_keys].where(account_id: account.id).count).to eq(0)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
|
|
5
|
+
# A private Capybara::Session on its own driver, javaScriptEnabled: false applies to the whole context and
|
|
6
|
+
# visit on the private session bypasses AcceptConsentOnVisit, which would otherwise accept consent and defeat the test
|
|
7
|
+
Capybara.register_driver(:playwright_nojs) do |app|
|
|
8
|
+
Capybara::Playwright::Driver.new(
|
|
9
|
+
app,
|
|
10
|
+
browser_type: PLAYWRIGHT_BROWSER,
|
|
11
|
+
headless: true,
|
|
12
|
+
playwright_cli_executable_path: File.expand_path('../../../node_modules/.bin/playwright', __dir__),
|
|
13
|
+
# Declarative HTML (form submits, popovertarget) keeps working
|
|
14
|
+
javaScriptEnabled: false
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
RSpec.describe 'UAT: consent without JavaScript' do
|
|
19
|
+
let(:nojs_session) { Capybara::Session.new(:playwright_nojs, Capybara.app) }
|
|
20
|
+
# Any public layout-rendering page would do
|
|
21
|
+
let(:layout_path) { '/legal/disclaimer' }
|
|
22
|
+
|
|
23
|
+
# reset_sessions! only iterates Capybara's registered sessions, this private one is not among them
|
|
24
|
+
after { nojs_session.driver.reset! }
|
|
25
|
+
|
|
26
|
+
it 'shows the banner open with both choices' do
|
|
27
|
+
nojs_session.visit layout_path
|
|
28
|
+
expect(nojs_session).to have_css('dialog[open]#consent-banner-dialog')
|
|
29
|
+
expect(nojs_session).to have_button(I18n.t('consent_kit.banner.only_necessary'))
|
|
30
|
+
expect(nojs_session).to have_button(I18n.t('consent_kit.banner.accept_all'))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# The card is taller than a headless viewport, so the Save button sits below the popover's scroll box
|
|
34
|
+
# and the driver reports it hidden. Assert on the popover state and title instead
|
|
35
|
+
it 'opens the preferences popover from the banner through popovertarget alone' do
|
|
36
|
+
nojs_session.visit layout_path
|
|
37
|
+
nojs_session.click_button I18n.t('consent_kit.banner.customize')
|
|
38
|
+
expect(nojs_session).to have_css('#consent-preferences:popover-open')
|
|
39
|
+
expect(nojs_session).to have_css('#consent-preferences-title', text: I18n.t('consent_kit.preferences.title'))
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'records consent when Accept all is submitted' do
|
|
43
|
+
nojs_session.visit layout_path
|
|
44
|
+
nojs_session.click_button I18n.t('consent_kit.banner.accept_all')
|
|
45
|
+
|
|
46
|
+
# The positive footer probe anchors the wait, the negation alone could pass on a page not yet loaded
|
|
47
|
+
nojs_session.visit layout_path
|
|
48
|
+
expect(nojs_session).to have_css('footer')
|
|
49
|
+
expect(nojs_session).to have_no_css('dialog[open]')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'records consent when Only necessary is submitted' do
|
|
53
|
+
nojs_session.visit layout_path
|
|
54
|
+
nojs_session.click_button I18n.t('consent_kit.banner.only_necessary')
|
|
55
|
+
|
|
56
|
+
nojs_session.visit layout_path
|
|
57
|
+
expect(nojs_session).to have_css('footer')
|
|
58
|
+
expect(nojs_session).to have_no_css('dialog[open]')
|
|
59
|
+
end
|
|
60
|
+
end
|