├── .babelrc ├── .circleci └── config.yml ├── .gitignore ├── .postcssrc.yml ├── Gemfile ├── Gemfile.lock ├── Procfile ├── README.md ├── Rakefile ├── app ├── assets │ ├── config │ │ └── manifest.js │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── application.js │ │ ├── cable.js │ │ └── channels │ │ │ └── .keep │ └── stylesheets │ │ └── application.css ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── controllers │ ├── application_controller.rb │ ├── concerns │ │ └── .keep │ └── welcome_controller.rb ├── helpers │ └── application_helper.rb ├── javascript │ ├── components │ │ └── App.vue │ ├── hello_vue.js │ └── packs │ │ └── application.js ├── jobs │ └── application_job.rb ├── mailers │ └── application_mailer.rb ├── models │ ├── application_record.rb │ └── concerns │ │ └── .keep └── views │ ├── layouts │ ├── application.html.erb │ ├── mailer.html.erb │ └── mailer.text.erb │ └── welcome │ └── index.html.erb ├── bin ├── bundle ├── rails ├── rake ├── rspec ├── setup ├── spring ├── update ├── webpack ├── webpack-dev-server └── yarn ├── config.ru ├── config ├── application.rb ├── boot.rb ├── cable.yml ├── credentials.yml.enc ├── database.yml.ci ├── database.yml.example ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── application_controller_renderer.rb │ ├── assets.rb │ ├── backtrace_silencers.rb │ ├── content_security_policy.rb │ ├── cookies_serializer.rb │ ├── filter_parameter_logging.rb │ ├── inflections.rb │ ├── mime_types.rb │ └── wrap_parameters.rb ├── locales │ └── en.yml ├── puma.rb ├── routes.rb ├── spring.rb ├── ssl │ └── .keep ├── storage.yml ├── webpack │ ├── development.js │ ├── environment.js │ ├── loaders │ │ └── vue.js │ ├── production.js │ └── test.js └── webpacker.yml ├── db ├── schema.rb └── seeds.rb ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── local-ssl-demo.png ├── log └── .keep ├── package.json ├── public ├── 404.html ├── 422.html ├── 500.html ├── apple-touch-icon-precomposed.png ├── apple-touch-icon.png ├── favicon.ico └── robots.txt ├── script └── generate-ssl-certificate.sh ├── spec ├── application_system_test_case.rb ├── controllers │ └── .keep ├── fixtures │ ├── .keep │ └── files │ │ └── .keep ├── helpers │ └── .keep ├── integration │ └── .keep ├── mailers │ └── .keep ├── models │ └── .keep ├── rails_helper.rb ├── spec_helper.rb ├── system │ ├── .keep │ └── welcomes_spec.rb └── test_helper.rb ├── storage └── .keep ├── vendor └── .keep └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["env", { 4 | "modules": false, 5 | "targets": { 6 | "browsers": "> 1%", 7 | "uglify": true 8 | }, 9 | "useBuiltIns": true 10 | }] 11 | ], 12 | 13 | "plugins": [ 14 | "syntax-dynamic-import", 15 | "transform-object-rest-spread", 16 | ["transform-class-properties", { "spec": true }] 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | defaults: &defaults 3 | jobs: 4 | build: 5 | working_directory: ~/app 6 | parallelism: 1 7 | # CircleCI 2.0 does not support environment variables that refer to each other the same way as 1.0 did. 8 | # If any of these refer to each other, rewrite them so that they don't or see https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables . 9 | environment: 10 | RACK_ENV: test 11 | RAILS_ENV: test 12 | NODE_ENV: test 13 | 14 | docker: 15 | - image: circleci/ruby:2.4.2-node-browsers 16 | environment: 17 | SELENIUM_DRIVER_URL: http://localhost:4444/wd/hub 18 | - image: circleci/postgres:9.4.12-alpine 19 | - image: selenium/standalone-chrome:3.14.0 20 | 21 | steps: 22 | - checkout 23 | 24 | - run: #STABLE 25 | name: Install Chromedriver latest version 26 | command: | 27 | sudo apt-get update 28 | sudo apt-get install lsb-release libappindicator3-1 29 | curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 30 | sudo dpkg -i google-chrome.deb 31 | sudo sed -i 's|HERE/chrome"|HERE/chrome" --no-sandbox|g' /opt/google/chrome/google-chrome 32 | rm google-chrome.deb 33 | 34 | - run: echo 127.0.0.1 localhost.ross subdomain.localhost.ross | sudo tee -a /etc/hosts 35 | 36 | # Bundle 37 | - run: 38 | name: Which bundler? 39 | command: bundle -v 40 | - restore_cache: 41 | keys: 42 | - app-bundle-v1-{{ checksum "Gemfile.lock" }} 43 | - app-bundle-v1- 44 | - run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 45 | - save_cache: 46 | key: app-bundle-v1-{{ checksum "Gemfile.lock" }} 47 | paths: vendor/bundle 48 | - persist_to_workspace: 49 | root: . 50 | paths: vendor/bundle 51 | 52 | # Yarn 53 | - run: 54 | name: Which node? 55 | command: node -v 56 | - run: 57 | name: Which yarn? 58 | command: yarn -v 59 | - restore_cache: 60 | keys: 61 | - app-yarn-v1-{{ checksum "yarn.lock" }} 62 | - app-yarn-v1- 63 | - run: yarn install 64 | - save_cache: 65 | key: app-yarn-v1-{{ checksum "yarn.lock" }} 66 | paths: 67 | - node_modules 68 | - persist_to_workspace: 69 | root: . 70 | paths: node_modules 71 | 72 | - run: mkdir -p /tmp/circleci-artifacts /tmp/circleci-test-results 73 | 74 | - run: 75 | name: Wait for postgres 76 | command: dockerize -wait tcp://localhost:5432 -timeout 1m 77 | 78 | - run: bundle --path vendor/bundle 79 | - run: mv config/database.yml.ci config/database.yml 80 | - run: ./script/generate-ssl-certificate.sh localhost.ross 81 | - run: bin/rake db:create db:schema:load db:migrate --trace 82 | 83 | - run: 84 | name: Run rspec 85 | command: DEBUG=1 bundle exec rspec 86 | 87 | - store_test_results: 88 | path: /tmp/circleci-test-results 89 | - store_artifacts: 90 | path: /tmp/circleci-artifacts 91 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/* 12 | /tmp/* 13 | !/log/.keep 14 | !/tmp/.keep 15 | 16 | # Ignore uploaded files in development 17 | /storage/* 18 | !/storage/.keep 19 | 20 | /node_modules 21 | /yarn-error.log 22 | 23 | /public/assets 24 | .byebug_history 25 | 26 | # Ignore master key for decrypting credentials and more. 27 | /config/master.key 28 | 29 | /config/database.yml 30 | /config/ssl/* 31 | !/config/ssl/.keep 32 | 33 | /public/packs 34 | /public/packs-test 35 | 36 | /node_modules 37 | yarn-debug.log* 38 | .yarn-integrity 39 | -------------------------------------------------------------------------------- /.postcssrc.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | postcss-import: {} 3 | postcss-cssnext: {} 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby '2.4.2' 5 | 6 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 7 | gem 'rails', '~> 5.2.1' 8 | # Use postgresql as the database for Active Record 9 | gem 'pg', '>= 0.18', '< 2.0' 10 | # Use Puma as the app server 11 | gem 'puma', '~> 3.11' 12 | # Use SCSS for stylesheets 13 | gem 'sass-rails', '~> 5.0' 14 | # Use Uglifier as compressor for JavaScript assets 15 | gem 'uglifier', '>= 1.3.0' 16 | # See https://github.com/rails/execjs#readme for more supported runtimes 17 | # gem 'mini_racer', platforms: :ruby 18 | 19 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 20 | gem 'jbuilder', '~> 2.5' 21 | # Use ActiveModel has_secure_password 22 | # gem 'bcrypt', '~> 3.1.7' 23 | 24 | # Use ActiveStorage variant 25 | # gem 'mini_magick', '~> 4.8' 26 | 27 | # Use Capistrano for deployment 28 | # gem 'capistrano-rails', group: :development 29 | 30 | gem 'webpacker' 31 | 32 | # Reduces boot times through caching; required in config/boot.rb 33 | gem 'bootsnap', '>= 1.1.0', require: false 34 | 35 | group :development, :test do 36 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 37 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 38 | end 39 | 40 | group :development do 41 | # Access an interactive console on exception pages or by calling 'console' anywhere in the code. 42 | gem 'web-console', '>= 3.3.0' 43 | gem 'listen', '>= 3.0.5', '< 3.2' 44 | end 45 | 46 | group :test do 47 | # Adds support for Capybara system testing and selenium driver 48 | gem 'capybara', '>= 2.15' 49 | gem 'selenium-webdriver' 50 | gem 'webdrivers', '~> 3.0' 51 | end 52 | 53 | group :development, :test do 54 | gem 'awesome_print' # very useful for debugging & logging 55 | gem 'binding_of_caller', require: false 56 | gem 'factory_bot_rails' 57 | gem 'pry-byebug' 58 | gem 'rspec-rails' 59 | end 60 | 61 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 62 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 63 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.2.1) 5 | actionpack (= 5.2.1) 6 | nio4r (~> 2.0) 7 | websocket-driver (>= 0.6.1) 8 | actionmailer (5.2.1) 9 | actionpack (= 5.2.1) 10 | actionview (= 5.2.1) 11 | activejob (= 5.2.1) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 2.0) 14 | actionpack (5.2.1) 15 | actionview (= 5.2.1) 16 | activesupport (= 5.2.1) 17 | rack (~> 2.0) 18 | rack-test (>= 0.6.3) 19 | rails-dom-testing (~> 2.0) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.2.1) 22 | activesupport (= 5.2.1) 23 | builder (~> 3.1) 24 | erubi (~> 1.4) 25 | rails-dom-testing (~> 2.0) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 27 | activejob (5.2.1) 28 | activesupport (= 5.2.1) 29 | globalid (>= 0.3.6) 30 | activemodel (5.2.1) 31 | activesupport (= 5.2.1) 32 | activerecord (5.2.1) 33 | activemodel (= 5.2.1) 34 | activesupport (= 5.2.1) 35 | arel (>= 9.0) 36 | activestorage (5.2.1) 37 | actionpack (= 5.2.1) 38 | activerecord (= 5.2.1) 39 | marcel (~> 0.3.1) 40 | activesupport (5.2.1) 41 | concurrent-ruby (~> 1.0, >= 1.0.2) 42 | i18n (>= 0.7, < 2) 43 | minitest (~> 5.1) 44 | tzinfo (~> 1.1) 45 | addressable (2.5.2) 46 | public_suffix (>= 2.0.2, < 4.0) 47 | arel (9.0.0) 48 | awesome_print (1.8.0) 49 | bindex (0.5.0) 50 | binding_of_caller (0.8.0) 51 | debug_inspector (>= 0.0.1) 52 | bootsnap (1.3.1) 53 | msgpack (~> 1.0) 54 | builder (3.2.3) 55 | byebug (10.0.2) 56 | capybara (3.6.0) 57 | addressable 58 | mini_mime (>= 0.1.3) 59 | nokogiri (~> 1.8) 60 | rack (>= 1.6.0) 61 | rack-test (>= 0.6.3) 62 | xpath (~> 3.1) 63 | childprocess (0.9.0) 64 | ffi (~> 1.0, >= 1.0.11) 65 | coderay (1.1.2) 66 | concurrent-ruby (1.0.5) 67 | crass (1.0.4) 68 | debug_inspector (0.0.3) 69 | diff-lcs (1.3) 70 | erubi (1.7.1) 71 | execjs (2.7.0) 72 | factory_bot (4.10.0) 73 | activesupport (>= 3.0.0) 74 | factory_bot_rails (4.10.0) 75 | factory_bot (~> 4.10.0) 76 | railties (>= 3.0.0) 77 | ffi (1.9.25) 78 | globalid (0.4.1) 79 | activesupport (>= 4.2.0) 80 | i18n (1.1.0) 81 | concurrent-ruby (~> 1.0) 82 | jbuilder (2.7.0) 83 | activesupport (>= 4.2.0) 84 | multi_json (>= 1.2) 85 | listen (3.1.5) 86 | rb-fsevent (~> 0.9, >= 0.9.4) 87 | rb-inotify (~> 0.9, >= 0.9.7) 88 | ruby_dep (~> 1.2) 89 | loofah (2.2.2) 90 | crass (~> 1.0.2) 91 | nokogiri (>= 1.5.9) 92 | mail (2.7.0) 93 | mini_mime (>= 0.1.1) 94 | marcel (0.3.2) 95 | mimemagic (~> 0.3.2) 96 | method_source (0.9.0) 97 | mimemagic (0.3.2) 98 | mini_mime (1.0.1) 99 | mini_portile2 (2.3.0) 100 | minitest (5.11.3) 101 | msgpack (1.2.4) 102 | multi_json (1.13.1) 103 | nio4r (2.3.1) 104 | nokogiri (1.8.4) 105 | mini_portile2 (~> 2.3.0) 106 | pg (1.0.0) 107 | pry (0.11.3) 108 | coderay (~> 1.1.0) 109 | method_source (~> 0.9.0) 110 | pry-byebug (3.6.0) 111 | byebug (~> 10.0) 112 | pry (~> 0.10) 113 | public_suffix (3.0.3) 114 | puma (3.12.0) 115 | rack (2.0.5) 116 | rack-proxy (0.6.4) 117 | rack 118 | rack-test (1.1.0) 119 | rack (>= 1.0, < 3) 120 | rails (5.2.1) 121 | actioncable (= 5.2.1) 122 | actionmailer (= 5.2.1) 123 | actionpack (= 5.2.1) 124 | actionview (= 5.2.1) 125 | activejob (= 5.2.1) 126 | activemodel (= 5.2.1) 127 | activerecord (= 5.2.1) 128 | activestorage (= 5.2.1) 129 | activesupport (= 5.2.1) 130 | bundler (>= 1.3.0) 131 | railties (= 5.2.1) 132 | sprockets-rails (>= 2.0.0) 133 | rails-dom-testing (2.0.3) 134 | activesupport (>= 4.2.0) 135 | nokogiri (>= 1.6) 136 | rails-html-sanitizer (1.0.4) 137 | loofah (~> 2.2, >= 2.2.2) 138 | railties (5.2.1) 139 | actionpack (= 5.2.1) 140 | activesupport (= 5.2.1) 141 | method_source 142 | rake (>= 0.8.7) 143 | thor (>= 0.19.0, < 2.0) 144 | rake (12.3.1) 145 | rb-fsevent (0.10.3) 146 | rb-inotify (0.9.10) 147 | ffi (>= 0.5.0, < 2) 148 | rspec-core (3.8.0) 149 | rspec-support (~> 3.8.0) 150 | rspec-expectations (3.8.1) 151 | diff-lcs (>= 1.2.0, < 2.0) 152 | rspec-support (~> 3.8.0) 153 | rspec-mocks (3.8.0) 154 | diff-lcs (>= 1.2.0, < 2.0) 155 | rspec-support (~> 3.8.0) 156 | rspec-rails (3.8.0) 157 | actionpack (>= 3.0) 158 | activesupport (>= 3.0) 159 | railties (>= 3.0) 160 | rspec-core (~> 3.8.0) 161 | rspec-expectations (~> 3.8.0) 162 | rspec-mocks (~> 3.8.0) 163 | rspec-support (~> 3.8.0) 164 | rspec-support (3.8.0) 165 | ruby_dep (1.5.0) 166 | rubyzip (1.2.1) 167 | sass (3.5.7) 168 | sass-listen (~> 4.0.0) 169 | sass-listen (4.0.0) 170 | rb-fsevent (~> 0.9, >= 0.9.4) 171 | rb-inotify (~> 0.9, >= 0.9.7) 172 | sass-rails (5.0.7) 173 | railties (>= 4.0.0, < 6) 174 | sass (~> 3.1) 175 | sprockets (>= 2.8, < 4.0) 176 | sprockets-rails (>= 2.0, < 4.0) 177 | tilt (>= 1.1, < 3) 178 | selenium-webdriver (3.14.0) 179 | childprocess (~> 0.5) 180 | rubyzip (~> 1.2) 181 | sprockets (3.7.2) 182 | concurrent-ruby (~> 1.0) 183 | rack (> 1, < 3) 184 | sprockets-rails (3.2.1) 185 | actionpack (>= 4.0) 186 | activesupport (>= 4.0) 187 | sprockets (>= 3.0.0) 188 | thor (0.20.0) 189 | thread_safe (0.3.6) 190 | tilt (2.0.8) 191 | tzinfo (1.2.5) 192 | thread_safe (~> 0.1) 193 | uglifier (4.1.18) 194 | execjs (>= 0.3.0, < 3) 195 | web-console (3.6.2) 196 | actionview (>= 5.0) 197 | activemodel (>= 5.0) 198 | bindex (>= 0.4.0) 199 | railties (>= 5.0) 200 | webdrivers (3.3.3) 201 | nokogiri (~> 1.6) 202 | rubyzip (~> 1.0) 203 | selenium-webdriver (~> 3.0) 204 | webpacker (3.5.5) 205 | activesupport (>= 4.2) 206 | rack-proxy (>= 0.6.1) 207 | railties (>= 4.2) 208 | websocket-driver (0.7.0) 209 | websocket-extensions (>= 0.1.0) 210 | websocket-extensions (0.1.3) 211 | xpath (3.1.0) 212 | nokogiri (~> 1.8) 213 | 214 | PLATFORMS 215 | ruby 216 | 217 | DEPENDENCIES 218 | awesome_print 219 | binding_of_caller 220 | bootsnap (>= 1.1.0) 221 | byebug 222 | capybara (>= 2.15) 223 | factory_bot_rails 224 | jbuilder (~> 2.5) 225 | listen (>= 3.0.5, < 3.2) 226 | pg (>= 0.18, < 2.0) 227 | pry-byebug 228 | puma (~> 3.11) 229 | rails (~> 5.2.1) 230 | rspec-rails 231 | sass-rails (~> 5.0) 232 | selenium-webdriver 233 | tzinfo-data 234 | uglifier (>= 1.3.0) 235 | web-console (>= 3.3.0) 236 | webdrivers (~> 3.0) 237 | webpacker 238 | 239 | RUBY VERSION 240 | ruby 2.4.2p198 241 | 242 | BUNDLED WITH 243 | 1.16.4 244 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bundle exec puma -b 'ssl://127.0.0.1:$PORT?key=config/ssl/localhost.ross.key&cert=config/ssl/localhost.ross.crt' 2 | webpack: yarn install && bin/webpack-dev-server 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![CircleCI](https://circleci.com/gh/rossta/local-ssl-demo-rails.svg?style=svg)](https://circleci.com/gh/rossta/local-ssl-demo-rails) 2 | # Local SSL Demo for Rails 3 | 4 | This Rails 5 application is a simple demo for getting SSL running for local development and test environments. 5 | 6 | [Blog post](https://rossta.net/blog/local-ssl-for-rails-5.html) 7 | 8 | ![Local SSL Demo](./local-ssl-demo.png) 9 | 10 | ## Requirements 11 | 12 | Below is a list of binaries and gems with the versions used in this demo. It may be possible to make this work with other relatively recent versions of these tools, though your mileage may vary. 13 | 14 | ### Binaries 15 | 16 | ``` 17 | $ openssl version 18 | LibreSSL 2.2.7 19 | 20 | $ ruby -v 21 | ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16] 22 | 23 | $ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version 24 | Google Chrome 68.0.3440.106 25 | 26 | $ /Applications/Firefox.app/Contents/MacOS/firefox --version 27 | Mozilla Firefox 60.0.1 28 | 29 | $ ~/.webdrivers/chromedriver -v 30 | ChromeDriver 2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db) 31 | 32 | $ ~/.webdrivers/geckodriver --version 33 | geckodriver 0.21.0 34 | ``` 35 | ### Gemfile 36 | 37 | ```ruby 38 | gem 'rails', '~> 5.2.1' 39 | gem 'puma', '~> 3.12' 40 | gem 'webpacker', '~> 3.5.5' # optional 41 | 42 | group :test do 43 | gem 'capybara', '~> 3.5.1' 44 | gem 'selenium-webdriver', '~> 3.14.0' 45 | gem 'webdrivers', '~> 3.3.3' 46 | gem 'rspec-rails', '~> 3.8.0' # optional 47 | end 48 | ``` 49 | 50 | ## Register a local top level domain 51 | 52 | For custom "pretty" wildcard domains, you can use a domain name registered to loop back to the local IP `127.0.0.1` like `lvh.me` or you can run `dnsmasq` locally to achieve the same effect for which ever domain you want. 53 | 54 | Install and start dnsmasq 55 | ``` 56 | brew install dnsmasq 57 | mkdir -pv $(brew --prefix)/etc 58 | sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons 59 | brew services start dnsmasq 60 | sudo mkdir -pv /etc/resolver 61 | ``` 62 | Add a resolver for a TLD you'd like to resolve locally. In this example, we'll use the username returned from `whoami`. 63 | ``` 64 | local_tld=$(whoami) 65 | echo "address=/.$local_tld/127.0.0.1" | sudo tee -a $(brew --prefix)/etc/dnsmasq.conf 66 | echo "nameserver 127.0.0.1" | sudo tee /etc/resolver/$local_tld 67 | ``` 68 | 69 | ## Generate a wildcard SSL certificate 70 | 71 | To generate a self-signed SSL certificate that will work for both arbitrary subdomains and the domain appex, we need make use of the Subject Alternative Name X.509 extension via a configuration file. 72 | 73 | ```bash 74 | name=localhost.$(whoami) 75 | openssl req \ 76 | -new \ 77 | -newkey rsa:2048 \ 78 | -sha256 \ 79 | -days 3650 \ 80 | -nodes \ 81 | -x509 \ 82 | -keyout $name.key \ 83 | -out $name.crt \ 84 | -config <(cat <<-EOF 85 | [req] 86 | distinguished_name = req_distinguished_name 87 | x509_extensions = v3_req 88 | prompt = no 89 | [req_distinguished_name] 90 | CN = $name 91 | [v3_req] 92 | keyUsage = keyEncipherment, dataEncipherment 93 | extendedKeyUsage = serverAuth 94 | subjectAltName = @alt_names 95 | [alt_names] 96 | DNS.1 = $name 97 | DNS.2 = *.$name 98 | EOF 99 | ) 100 | ``` 101 | Move the generated files to a location of your choosing, such as the `config` directory of your Rails project: 102 | ``` 103 | $ mv localhost.ross.crt localhost.ross.key config/ssl 104 | ``` 105 | Finally, we can instruct Keychain to trust are newly generated certificate. Some browsers like Chrome will rely on the System settings 106 | ``` 107 | $ sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain config/ssl/localhost.ross.crt 108 | ``` 109 | ### Server configuration 110 | 111 | If you're running Nginx locally to reverse proxy requests for `https://localhost.ross` to your local Rails server, you can configure it to handle SSL requests using your key/crt file pair. 112 | 113 | Without Nginx, you can boot the Rails Puma server so that it will bind to our local domain name over SSL: 114 | 115 | ``` 116 | bin/rails s -b 'ssl://127.0.0.1:3000?key=config/ssl/localhost.ross.key&cert=config/ssl/localhost.ross.crt' 117 | ``` 118 | A similar command can be found in the Procfile for use with `foreman` locally. 119 | 120 | ## Acknowledgements 121 | 122 | The guide for setting up SSL for local development is based off of Jed Schmidt's excellent 123 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/app/assets/images/.keep -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's 5 | // vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require rails-ujs 14 | //= require activestorage 15 | //= require_tree . 16 | -------------------------------------------------------------------------------- /app/assets/javascripts/cable.js: -------------------------------------------------------------------------------- 1 | // Action Cable provides the framework to deal with WebSockets in Rails. 2 | // You can generate new channels where WebSocket features live using the `rails generate channel` command. 3 | // 4 | //= require action_cable 5 | //= require_self 6 | //= require_tree ./channels 7 | 8 | (function() { 9 | this.App || (this.App = {}); 10 | 11 | App.cable = ActionCable.createConsumer(); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/app/assets/javascripts/channels/.keep -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /app/controllers/welcome_controller.rb: -------------------------------------------------------------------------------- 1 | class WelcomeController < ApplicationController 2 | def index 3 | Rails.logger.warn ">>>> Request url: #{request.protocol}#{request.host}" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/javascript/components/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 16 | 17 | 23 | -------------------------------------------------------------------------------- /app/javascript/hello_vue.js: -------------------------------------------------------------------------------- 1 | /* eslint no-console: 0 */ 2 | // Run this example by adding <%= javascript_pack_tag 'hello_vue' %> (and 3 | // <%= stylesheet_pack_tag 'hello_vue' %> if you have styles in your component) 4 | // to the head of your layout file, 5 | // like app/views/layouts/application.html.erb. 6 | // All it does is render
Hello Vue
at the bottom of the page. 7 | 8 | import Vue from 'vue' 9 | import App from 'components/App.vue' 10 | 11 | document.addEventListener('DOMContentLoaded', () => { 12 | const el = document.body.appendChild(document.createElement('hello')) 13 | const app = new Vue({ 14 | el, 15 | render: h => h(App) 16 | }) 17 | 18 | console.log(app) 19 | }) 20 | 21 | 22 | // The above code uses Vue without the compiler, which means you cannot 23 | // use Vue to target elements in your existing html templates. You would 24 | // need to always use single file components. 25 | // To be able to target elements in your existing html/erb templates, 26 | // comment out the above code and uncomment the below 27 | // Add <%= javascript_pack_tag 'hello_vue' %> to your layout 28 | // Then add this markup to your html template: 29 | // 30 | //
31 | // {{message}} 32 | // 33 | //
34 | 35 | 36 | // import Vue from 'vue/dist/vue.esm' 37 | // import App from '../app.vue' 38 | // 39 | // document.addEventListener('DOMContentLoaded', () => { 40 | // const app = new Vue({ 41 | // el: '#hello', 42 | // data: { 43 | // message: "Can you say hello?" 44 | // }, 45 | // components: { App } 46 | // }) 47 | // }) 48 | // 49 | // 50 | // 51 | // If the using turbolinks, install 'vue-turbolinks': 52 | // 53 | // yarn add 'vue-turbolinks' 54 | // 55 | // Then uncomment the code block below: 56 | // 57 | // import TurbolinksAdapter from 'vue-turbolinks' 58 | // import Vue from 'vue/dist/vue.esm' 59 | // import App from '../app.vue' 60 | // 61 | // Vue.use(TurbolinksAdapter) 62 | // 63 | // document.addEventListener('turbolinks:load', () => { 64 | // const app = new Vue({ 65 | // el: '#hello', 66 | // data: { 67 | // message: "Can you say hello?" 68 | // }, 69 | // components: { App } 70 | // }) 71 | // }) 72 | -------------------------------------------------------------------------------- /app/javascript/packs/application.js: -------------------------------------------------------------------------------- 1 | /* eslint no-console:0 */ 2 | // This file is automatically compiled by Webpack, along with any other files 3 | // present in this directory. You're encouraged to place your actual application logic in 4 | // a relevant structure within app/javascript and only use these pack files to reference 5 | // that code so it'll be compiled. 6 | // 7 | // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate 8 | // layout file, like app/views/layouts/application.html.erb 9 | 10 | import "babel-polyfill" 11 | import '../hello_vue' 12 | 13 | console.log('Hello World from Webpacker') 14 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/app/models/concerns/.keep -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Local SSL Demo 5 | <%= csrf_meta_tags %> 6 | <%= csp_meta_tag %> 7 | 8 | <%= stylesheet_link_tag 'application', media: 'all' %> 9 | <%= javascript_pack_tag 'application' %> 10 | 11 | 12 | 13 | <%= yield %> 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/views/welcome/index.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

Welcome!

3 | 4 |

Your protocol: <%= request.protocol %>

5 |

Your domain: <%= request.host %>

6 |
7 | 8 |
9 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../config/application', __dir__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative '../config/boot' 3 | require 'rake' 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /bin/rspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'rspec' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | bundle_binstub = File.expand_path("../bundle", __FILE__) 12 | load(bundle_binstub) if File.file?(bundle_binstub) 13 | 14 | require "pathname" 15 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 16 | Pathname.new(__FILE__).realpath) 17 | 18 | require "rubygems" 19 | require "bundler/setup" 20 | 21 | load Gem.bin_path("rspec-core", "rspec") 22 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a starting point to setup your application. 14 | # Add necessary setup steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies if using Yarn 21 | # system('bin/yarn') 22 | 23 | # puts "\n== Copying sample files ==" 24 | # unless File.exist?('config/database.yml') 25 | # cp 'config/database.yml.sample', 'config/database.yml' 26 | # end 27 | 28 | puts "\n== Preparing database ==" 29 | system! 'bin/rails db:setup' 30 | 31 | puts "\n== Removing old logs and tempfiles ==" 32 | system! 'bin/rails log:clear tmp:clear' 33 | 34 | puts "\n== Restarting application server ==" 35 | system! 'bin/rails restart' 36 | end 37 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'fileutils' 3 | include FileUtils 4 | 5 | # path to your application root. 6 | APP_ROOT = File.expand_path('..', __dir__) 7 | 8 | def system!(*args) 9 | system(*args) || abort("\n== Command #{args} failed ==") 10 | end 11 | 12 | chdir APP_ROOT do 13 | # This script is a way to update your development environment automatically. 14 | # Add necessary update steps to this file. 15 | 16 | puts '== Installing dependencies ==' 17 | system! 'gem install bundler --conservative' 18 | system('bundle check') || system!('bundle install') 19 | 20 | # Install JavaScript dependencies if using Yarn 21 | # system('bin/yarn') 22 | 23 | puts "\n== Updating database ==" 24 | system! 'bin/rails db:migrate' 25 | 26 | puts "\n== Removing old logs and tempfiles ==" 27 | system! 'bin/rails log:clear tmp:clear' 28 | 29 | puts "\n== Restarting application server ==" 30 | system! 'bin/rails restart' 31 | end 32 | -------------------------------------------------------------------------------- /bin/webpack: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" 4 | ENV["NODE_ENV"] ||= "development" 5 | 6 | require "pathname" 7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 8 | Pathname.new(__FILE__).realpath) 9 | 10 | require "rubygems" 11 | require "bundler/setup" 12 | 13 | require "webpacker" 14 | require "webpacker/webpack_runner" 15 | Webpacker::WebpackRunner.run(ARGV) 16 | -------------------------------------------------------------------------------- /bin/webpack-dev-server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" 4 | ENV["NODE_ENV"] ||= "development" 5 | 6 | require "pathname" 7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 8 | Pathname.new(__FILE__).realpath) 9 | 10 | require "rubygems" 11 | require "bundler/setup" 12 | 13 | require "webpacker" 14 | require "webpacker/dev_server_runner" 15 | Webpacker::DevServerRunner.run(ARGV) 16 | -------------------------------------------------------------------------------- /bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_ROOT = File.expand_path('..', __dir__) 3 | Dir.chdir(APP_ROOT) do 4 | begin 5 | exec "yarnpkg", *ARGV 6 | rescue Errno::ENOENT 7 | $stderr.puts "Yarn executable was not detected in the system." 8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" 9 | exit 1 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require 'rails/all' 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module LocalSslDemo 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 5.2 13 | 14 | # Settings in config/environments/* take precedence over those specified here. 15 | # Application configuration can go into files in config/initializers 16 | # -- all .rb files in that directory are automatically loaded after loading 17 | # the framework and any gems in your application. 18 | config.force_ssl = true 19 | 20 | config.generators do |g| 21 | g.test_framework :rspec 22 | g.fixture_replacement :factory_bot, :dir => 'spec/factories' 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | require 'bootsnap/setup' # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: local_ssl_demo_production 11 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | r1aZPo26tb8YRgJFNYLi2zwor+KjHuWT62299TgblL/ZgOad4jFcbnE8hzA2XyJjIizte/NqhyYxsCBR/4KMmgHPS/7JN0cpbiTbTvrVr8kt702SAudMGDWREk47ODgn3GDpNgYqoQ8+09mYBnOoPtROfmHgsQn7HGhu6hrjNgFKq9LVGWIRkUt9+amuog7LdHa76PXsHgek/Y2U40AfXreZmtQ+2sRGbNCD0YGuPc/XUWbYWPLdi+klTCGRGaI6knWw2OmzQRr7kSZO3VUlrphQq+9CgU76KWXnzBln06pg/O2HzNfU2OkniwWZBaOPhfUwySvJ+YtzgWwnrGs3346yKUC0pqY3f/iTFrFt8QBu/9ve4eEjwpAsldwoqi2WbWH5OxkfPulWQXeoXaMXR3ZmKjbsn22dwjcN--MMunh94yFPPeIHnZ--l26bIA4odjnelDthzTbhHQ== -------------------------------------------------------------------------------- /config/database.yml.ci: -------------------------------------------------------------------------------- 1 | --- 2 | test: 3 | host: localhost 4 | username: root 5 | database: circle_test 6 | adapter: postgresql 7 | encoding: unicode 8 | min_messages: WARNING 9 | pool: 10 10 | -------------------------------------------------------------------------------- /config/database.yml.example: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 9.1 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On OS X with Homebrew: 6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7 | # On OS X with MacPorts: 8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 9 | # On Windows: 10 | # gem install pg 11 | # Choose the win32 build. 12 | # Install PostgreSQL and put its /bin directory on your path. 13 | # 14 | # Configure Using Gemfile 15 | # gem 'pg' 16 | # 17 | default: &default 18 | adapter: postgresql 19 | encoding: unicode 20 | # For details on connection pooling, see Rails configuration guide 21 | # http://guides.rubyonrails.org/configuring.html#database-pooling 22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 23 | 24 | development: 25 | <<: *default 26 | database: system_test_demo_development 27 | 28 | # The specified database role being used to connect to postgres. 29 | # To create additional roles in postgres see `$ createuser --help`. 30 | # When left blank, postgres will use the default role. This is 31 | # the same name as the operating system user that initialized the database. 32 | #username: system_test_demo 33 | 34 | # The password associated with the postgres role (username). 35 | #password: 36 | 37 | # Connect on a TCP socket. Omitted by default since the client uses a 38 | # domain socket that doesn't need configuration. Windows does not have 39 | # domain sockets, so uncomment these lines. 40 | #host: localhost 41 | 42 | # The TCP port the server listens on. Defaults to 5432. 43 | # If your server runs on a different port number, change accordingly. 44 | #port: 5432 45 | 46 | # Schema search path. The server defaults to $user,public 47 | #schema_search_path: myapp,sharedapp,public 48 | 49 | # Minimum log levels, in increasing order: 50 | # debug5, debug4, debug3, debug2, debug1, 51 | # log, notice, warning, error, fatal, and panic 52 | # Defaults to warning. 53 | #min_messages: notice 54 | 55 | # Warning: The database defined as "test" will be erased and 56 | # re-generated from your development database when you run "rake". 57 | # Do not set this db to the same as development or production. 58 | test: 59 | <<: *default 60 | database: system_test_demo_test 61 | 62 | # As with config/secrets.yml, you never want to store sensitive information, 63 | # like your database password, in your source code. If your source code is 64 | # ever seen by anyone, they now have access to your database. 65 | # 66 | # Instead, provide the password as a unix environment variable when you boot 67 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 68 | # for a full rundown on how to provide these environment variables in a 69 | # production deployment. 70 | # 71 | # On Heroku and other platform providers, you may have a full connection URL 72 | # available as an environment variable. For example: 73 | # 74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 75 | # 76 | # You can use this database configuration with: 77 | # 78 | # production: 79 | # url: <%= ENV['DATABASE_URL'] %> 80 | # 81 | production: 82 | <<: *default 83 | database: system_test_demo_production 84 | username: system_test_demo 85 | password: <%= ENV['system_test_DEMO_DATABASE_PASSWORD'] %> 86 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Verifies that versions and hashed value of the package contents in the project's package.json 3 | config.webpacker.check_yarn_integrity = true 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # In the development environment your application's code is reloaded on 7 | # every request. This slows down response time but is perfect for development 8 | # since you don't have to restart the web server when you make code changes. 9 | config.cache_classes = false 10 | 11 | # Do not eager load code on boot. 12 | config.eager_load = false 13 | 14 | # Show full error reports. 15 | config.consider_all_requests_local = true 16 | 17 | # Enable/disable caching. By default caching is disabled. 18 | # Run rails dev:cache to toggle caching. 19 | if Rails.root.join('tmp', 'caching-dev.txt').exist? 20 | config.action_controller.perform_caching = true 21 | 22 | config.cache_store = :memory_store 23 | config.public_file_server.headers = { 24 | 'Cache-Control' => "public, max-age=#{2.days.to_i}" 25 | } 26 | else 27 | config.action_controller.perform_caching = false 28 | 29 | config.cache_store = :null_store 30 | end 31 | 32 | # Store uploaded files on the local file system (see config/storage.yml for options) 33 | config.active_storage.service = :local 34 | 35 | # Don't care if the mailer can't send. 36 | config.action_mailer.raise_delivery_errors = false 37 | 38 | config.action_mailer.perform_caching = false 39 | 40 | # Print deprecation notices to the Rails logger. 41 | config.active_support.deprecation = :log 42 | 43 | # Raise an error on page load if there are pending migrations. 44 | config.active_record.migration_error = :page_load 45 | 46 | # Highlight code that triggered database queries in logs. 47 | config.active_record.verbose_query_logs = true 48 | 49 | # Debug mode disables concatenation and preprocessing of assets. 50 | # This option may cause significant delays in view rendering with a large 51 | # number of complex assets. 52 | config.assets.debug = true 53 | 54 | # Suppress logger output for asset requests. 55 | config.assets.quiet = true 56 | 57 | # Raises error for missing translations 58 | # config.action_view.raise_on_missing_translations = true 59 | 60 | # Use an evented file watcher to asynchronously detect changes in source code, 61 | # routes, locales, etc. This feature depends on the listen gem. 62 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 63 | end 64 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Verifies that versions and hashed value of the package contents in the project's package.json 3 | config.webpacker.check_yarn_integrity = false 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # Code is not reloaded between requests. 7 | config.cache_classes = true 8 | 9 | # Eager load code on boot. This eager loads most of Rails and 10 | # your application in memory, allowing both threaded web servers 11 | # and those relying on copy on write to perform better. 12 | # Rake tasks automatically ignore this option for performance. 13 | config.eager_load = true 14 | 15 | # Full error reports are disabled and caching is turned on. 16 | config.consider_all_requests_local = false 17 | config.action_controller.perform_caching = true 18 | 19 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 20 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 21 | # config.require_master_key = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 26 | 27 | # Compress JavaScripts and CSS. 28 | config.assets.js_compressor = :uglifier 29 | # config.assets.css_compressor = :sass 30 | 31 | # Do not fallback to assets pipeline if a precompiled asset is missed. 32 | config.assets.compile = false 33 | 34 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 35 | 36 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 37 | # config.action_controller.asset_host = 'http://assets.example.com' 38 | 39 | # Specifies the header that your server uses for sending files. 40 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 41 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 42 | 43 | # Store uploaded files on the local file system (see config/storage.yml for options) 44 | config.active_storage.service = :local 45 | 46 | # Mount Action Cable outside main process or domain 47 | # config.action_cable.mount_path = nil 48 | # config.action_cable.url = 'wss://example.com/cable' 49 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 50 | 51 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 52 | # config.force_ssl = true 53 | 54 | # Use the lowest log level to ensure availability of diagnostic information 55 | # when problems arise. 56 | config.log_level = :debug 57 | 58 | # Prepend all log lines with the following tags. 59 | config.log_tags = [ :request_id ] 60 | 61 | # Use a different cache store in production. 62 | # config.cache_store = :mem_cache_store 63 | 64 | # Use a real queuing backend for Active Job (and separate queues per environment) 65 | # config.active_job.queue_adapter = :resque 66 | # config.active_job.queue_name_prefix = "local_ssl_demo_#{Rails.env}" 67 | 68 | config.action_mailer.perform_caching = false 69 | 70 | # Ignore bad email addresses and do not raise email delivery errors. 71 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 72 | # config.action_mailer.raise_delivery_errors = false 73 | 74 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 75 | # the I18n.default_locale when a translation cannot be found). 76 | config.i18n.fallbacks = true 77 | 78 | # Send deprecation notices to registered listeners. 79 | config.active_support.deprecation = :notify 80 | 81 | # Use default logging formatter so that PID and timestamp are not suppressed. 82 | config.log_formatter = ::Logger::Formatter.new 83 | 84 | # Use a different logger for distributed setups. 85 | # require 'syslog/logger' 86 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 87 | 88 | if ENV["RAILS_LOG_TO_STDOUT"].present? 89 | logger = ActiveSupport::Logger.new(STDOUT) 90 | logger.formatter = config.log_formatter 91 | config.logger = ActiveSupport::TaggedLogging.new(logger) 92 | end 93 | 94 | # Do not dump schema after migrations. 95 | config.active_record.dump_schema_after_migration = false 96 | end 97 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => "public, max-age=#{1.hour.to_i}" 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | 31 | # Store uploaded files on the local file system in a temporary directory 32 | config.active_storage.service = :test 33 | 34 | config.action_mailer.perform_caching = false 35 | 36 | # Tell Action Mailer not to deliver emails to the real world. 37 | # The :test delivery method accumulates sent emails in the 38 | # ActionMailer::Base.deliveries array. 39 | config.action_mailer.delivery_method = :test 40 | 41 | # Print deprecation notices to the stderr. 42 | config.active_support.deprecation = :stderr 43 | 44 | # Raises error for missing translations 45 | # config.action_view.raise_on_missing_translations = true 46 | end 47 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ActiveSupport::Reloader.to_prepare do 4 | # ApplicationController.renderer.defaults.merge!( 5 | # http_host: 'example.org', 6 | # https: false 7 | # ) 8 | # end 9 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | # Add Yarn node_modules folder to the asset load path. 9 | Rails.application.config.assets.paths << Rails.root.join('node_modules') 10 | 11 | # Precompile additional assets. 12 | # application.js, application.css, and all non-JS/CSS in the app/assets 13 | # folder are already added. 14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 15 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy 4 | # For further information see the following documentation 5 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy 6 | 7 | # Rails.application.config.content_security_policy do |policy| 8 | # policy.default_src :self, :https 9 | # policy.font_src :self, :https, :data 10 | # policy.img_src :self, :https, :data 11 | # policy.object_src :none 12 | # policy.script_src :self, :https 13 | # policy.style_src :self, :https 14 | 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | 19 | # If you are using UJS then enable automatic nonce generation 20 | # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } 21 | 22 | # Report CSP violations to a specified URI 23 | # For further information see the following documentation: 24 | # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only 25 | # Rails.application.config.content_security_policy_report_only = true 26 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # 'true': 'foo' 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at http://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 11 | # 12 | port ENV.fetch("PORT") { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch("RAILS_ENV") { "development" } 17 | 18 | # Specifies the number of `workers` to boot in clustered mode. 19 | # Workers are forked webserver processes. If using threads and workers together 20 | # the concurrency of the application would be max `threads` * `workers`. 21 | # Workers do not work on JRuby or Windows (both of which do not support 22 | # processes). 23 | # 24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 25 | 26 | # Use the `preload_app!` method when specifying a `workers` number. 27 | # This directive tells Puma to first boot the application and load code 28 | # before forking the application. This takes advantage of Copy On Write 29 | # process behavior so workers use less memory. 30 | # 31 | # preload_app! 32 | 33 | # Allow puma to be restarted by `rails restart` command. 34 | plugin :tmp_restart 35 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 3 | root to: "welcome#index" 4 | end 5 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w[ 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ].each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /config/ssl/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/config/ssl/.keep -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket 23 | 24 | # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /config/webpack/development.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || 'development' 2 | 3 | const environment = require('./environment') 4 | 5 | module.exports = environment.toWebpackConfig() 6 | -------------------------------------------------------------------------------- /config/webpack/environment.js: -------------------------------------------------------------------------------- 1 | const { environment } = require('@rails/webpacker') 2 | const vue = require('./loaders/vue') 3 | 4 | environment.loaders.append('vue', { 5 | test: /\.vue$/, 6 | use: [{ 7 | loader: 'vue-loader', 8 | options: { 9 | hotReload: false, 10 | }, 11 | }], 12 | }) 13 | 14 | environment.loaders.append('vue', vue) 15 | module.exports = environment 16 | -------------------------------------------------------------------------------- /config/webpack/loaders/vue.js: -------------------------------------------------------------------------------- 1 | const { dev_server: devServer } = require('@rails/webpacker').config 2 | 3 | const isProduction = process.env.NODE_ENV === 'production' 4 | const inDevServer = process.argv.find(v => v.includes('webpack-dev-server')) 5 | const extractCSS = !(inDevServer && (devServer && devServer.hmr)) || isProduction 6 | 7 | module.exports = { 8 | test: /\.vue(\.erb)?$/, 9 | use: [{ 10 | loader: 'vue-loader', 11 | options: { extractCSS } 12 | }] 13 | } 14 | -------------------------------------------------------------------------------- /config/webpack/production.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || 'production' 2 | 3 | const environment = require('./environment') 4 | 5 | module.exports = environment.toWebpackConfig() 6 | -------------------------------------------------------------------------------- /config/webpack/test.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || 'development' 2 | 3 | const environment = require('./environment') 4 | 5 | module.exports = environment.toWebpackConfig() 6 | -------------------------------------------------------------------------------- /config/webpacker.yml: -------------------------------------------------------------------------------- 1 | # Note: You must restart bin/webpack-dev-server for changes to take effect 2 | 3 | default: &default 4 | source_path: app/javascript 5 | source_entry_path: packs 6 | public_output_path: packs 7 | cache_path: tmp/cache/webpacker 8 | 9 | # Additional paths webpack should lookup modules 10 | # ['app/assets', 'engine/foo/app/assets'] 11 | resolved_paths: [] 12 | 13 | # Reload manifest.json on all requests so we reload latest compiled packs 14 | cache_manifest: false 15 | 16 | extensions: 17 | - .js 18 | - .sass 19 | - .scss 20 | - .css 21 | - .module.sass 22 | - .module.scss 23 | - .module.css 24 | - .png 25 | - .svg 26 | - .gif 27 | - .jpeg 28 | - .jpg 29 | 30 | development: 31 | <<: *default 32 | compile: true 33 | 34 | # Reference: https://webpack.js.org/configuration/dev-server/ 35 | dev_server: 36 | https: true 37 | host: localhost 38 | port: 3035 39 | public: localhost:3035 40 | hmr: false 41 | # Inline should be set to true if using HMR 42 | inline: true 43 | overlay: true 44 | compress: true 45 | disable_host_check: true 46 | use_local_ip: false 47 | quiet: false 48 | headers: 49 | 'Access-Control-Allow-Origin': '*' 50 | watch_options: 51 | ignored: /node_modules/ 52 | 53 | 54 | test: 55 | <<: *default 56 | compile: true 57 | 58 | # Compile test packs to a separate directory 59 | public_output_path: packs-test 60 | 61 | production: 62 | <<: *default 63 | 64 | # Production depends on precompilation of packs prior to booting for performance. 65 | compile: false 66 | 67 | # Cache manifest.json for performance 68 | cache_manifest: true 69 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 0) do 14 | 15 | # These are extensions that must be enabled in order to support this database 16 | enable_extension "plpgsql" 17 | 18 | end 19 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) 7 | # Character.create(name: 'Luke', movie: movies.first) 8 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/lib/assets/.keep -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/lib/tasks/.keep -------------------------------------------------------------------------------- /local-ssl-demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/local-ssl-demo.png -------------------------------------------------------------------------------- /log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/log/.keep -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "javascript_demo", 3 | "private": true, 4 | "dependencies": { 5 | "@rails/webpacker": "3.5", 6 | "babel-plugin-module-resolver": "^3.1.1", 7 | "vue": "^2.5.17", 8 | "vue-loader": "14.2.2", 9 | "vue-template-compiler": "^2.5.17" 10 | }, 11 | "devDependencies": { 12 | "webpack-dev-server": "2.11.2" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/public/apple-touch-icon.png -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/public/favicon.ico -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /script/generate-ssl-certificate.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ ! -n "$1" ]]; then 4 | echo "Argument 1 should be the domain name" 1>&2 5 | exit 1 6 | fi 7 | 8 | name=$1 9 | mkdir -p config/ssl 10 | 11 | openssl req \ 12 | -new \ 13 | -newkey rsa:2048 \ 14 | -sha256 \ 15 | -days 3650 \ 16 | -nodes \ 17 | -x509 \ 18 | -keyout config/ssl/$name.key \ 19 | -out config/ssl/$name.crt \ 20 | -config <(cat <<-EOF 21 | [req] 22 | distinguished_name = req_distinguished_name 23 | x509_extensions = v3_req 24 | prompt = no 25 | [req_distinguished_name] 26 | CN = $name 27 | [v3_req] 28 | keyUsage = keyEncipherment, dataEncipherment 29 | extendedKeyUsage = serverAuth 30 | subjectAltName = @alt_names 31 | [alt_names] 32 | DNS.1 = $name 33 | DNS.2 = *.$name 34 | EOF 35 | ) 36 | echo "A wildcard self-signed SSL key/certificate pair has been generated for $name" 37 | -------------------------------------------------------------------------------- /spec/application_system_test_case.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ApplicationSystemTestCase < ActionDispatch::SystemTestCase 4 | driven_by :selenium, using: :chrome, screen_size: [1400, 1400] 5 | end 6 | -------------------------------------------------------------------------------- /spec/controllers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/spec/controllers/.keep -------------------------------------------------------------------------------- /spec/fixtures/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/spec/fixtures/.keep -------------------------------------------------------------------------------- /spec/fixtures/files/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/spec/fixtures/files/.keep -------------------------------------------------------------------------------- /spec/helpers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/spec/helpers/.keep -------------------------------------------------------------------------------- /spec/integration/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/spec/integration/.keep -------------------------------------------------------------------------------- /spec/mailers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/spec/mailers/.keep -------------------------------------------------------------------------------- /spec/models/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/spec/models/.keep -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | require 'spec_helper' 3 | ENV['RAILS_ENV'] ||= 'test' 4 | require File.expand_path('../../config/environment', __FILE__) 5 | # Prevent database truncation if the environment is production 6 | abort("The Rails environment is running in production mode!") if Rails.env.production? 7 | require 'rspec/rails' 8 | # Add additional requires below this line. Rails is not loaded until this point! 9 | 10 | # Requires supporting ruby files with custom matchers and macros, etc, in 11 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 12 | # run as spec files by default. This means that files in spec/support that end 13 | # in _spec.rb will both be required and run as specs, causing the specs to be 14 | # run twice. It is recommended that you do not name files matching this glob to 15 | # end with _spec.rb. You can configure this pattern with the --pattern 16 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 17 | # 18 | # The following line is provided for convenience purposes. It has the downside 19 | # of increasing the boot-up time by auto-requiring all files in the support 20 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 21 | # require only the support files necessary. 22 | # 23 | # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f } 24 | 25 | # Checks for pending migrations and applies them before tests are run. 26 | # If you are not using ActiveRecord, you can remove these lines. 27 | begin 28 | ActiveRecord::Migration.maintain_test_schema! 29 | rescue ActiveRecord::PendingMigrationError => e 30 | puts e.to_s.strip 31 | exit 1 32 | end 33 | RSpec.configure do |config| 34 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 35 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 36 | 37 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 38 | # examples within a transaction, remove the following line or assign false 39 | # instead of true. 40 | config.use_transactional_fixtures = true 41 | 42 | # RSpec Rails can automatically mix in different behaviours to your tests 43 | # based on their file location, for example enabling you to call `get` and 44 | # `post` in specs under `spec/controllers`. 45 | # 46 | # You can disable this behaviour by removing the line below, and instead 47 | # explicitly tag your specs with their type, e.g.: 48 | # 49 | # RSpec.describe UsersController, :type => :controller do 50 | # # ... 51 | # end 52 | # 53 | # The different available types are documented in the features, such as in 54 | # https://relishapp.com/rspec/rspec-rails/docs 55 | config.infer_spec_type_from_file_location! 56 | 57 | # Filter lines from Rails gems in backtraces. 58 | config.filter_rails_from_backtrace! 59 | # arbitrary gems may also be filtered via: 60 | # config.filter_gems_from_backtrace("gem name") 61 | end 62 | 63 | Capybara.register_driver(:headless_chrome) do |app| 64 | options = Selenium::WebDriver::Chrome::Options.new({ 65 | args: %w[--headless --disable-gpu --no-sandbox --disable-web-security], 66 | url: ENV['SELENIUM_DRIVER_URL'] 67 | }.reject { |k, v| v.blank? }) 68 | capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( 69 | acceptInsecureCerts: true, 70 | ) 71 | Capybara::Selenium::Driver.new( 72 | app, 73 | browser: :chrome, 74 | options: options, 75 | desired_capabilities: capabilities 76 | ) 77 | end 78 | 79 | Capybara.register_driver(:headless_firefox) do |app| 80 | options = Selenium::WebDriver::Firefox::Options.new(args: %w[--headless]) 81 | 82 | capabilities = Selenium::WebDriver::Remote::Capabilities.firefox( 83 | acceptInsecureCerts: true, 84 | ) 85 | Capybara::Selenium::Driver.new( 86 | app, 87 | browser: :firefox, 88 | options: options, 89 | desired_capabilities: capabilities 90 | ) 91 | end 92 | 93 | key_file_path = Rails.root.join("config", "ssl", "localhost.ross.key") 94 | cert_file_path = Rails.root.join("config", "ssl", "localhost.ross.crt") 95 | 96 | Capybara.server = :puma, { 97 | Host: "ssl://#{Capybara.server_host}?key=#{key_file_path}&cert=#{cert_file_path}", 98 | Silent: ENV['DEBUG'] != 'true', 99 | } 100 | 101 | RSpec.configure do |config| 102 | config.before(:each, type: :system) do 103 | driven_by :rack_test 104 | end 105 | 106 | config.before(:each, type: :system, js: true) do 107 | driven_by :headless_chrome 108 | end 109 | end 110 | 111 | module SystemTestHelpers 112 | def using_app_host(host) 113 | original_host = Capybara.app_host 114 | Capybara.app_host = host 115 | 116 | yield 117 | ensure 118 | Capybara.app_host = original_host 119 | end 120 | end 121 | 122 | RSpec.configure do |config| 123 | config.include SystemTestHelpers, type: :system 124 | end 125 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 16 | RSpec.configure do |config| 17 | # rspec-expectations config goes here. You can use an alternate 18 | # assertion/expectation library such as wrong or the stdlib/minitest 19 | # assertions if you prefer. 20 | config.expect_with :rspec do |expectations| 21 | # This option will default to `true` in RSpec 4. It makes the `description` 22 | # and `failure_message` of custom matchers include text for helper methods 23 | # defined using `chain`, e.g.: 24 | # be_bigger_than(2).and_smaller_than(4).description 25 | # # => "be bigger than 2 and smaller than 4" 26 | # ...rather than: 27 | # # => "be bigger than 2" 28 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 29 | end 30 | 31 | # rspec-mocks config goes here. You can use an alternate test double 32 | # library (such as bogus or mocha) by changing the `mock_with` option here. 33 | config.mock_with :rspec do |mocks| 34 | # Prevents you from mocking or stubbing a method that does not exist on 35 | # a real object. This is generally recommended, and will default to 36 | # `true` in RSpec 4. 37 | mocks.verify_partial_doubles = true 38 | end 39 | 40 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 41 | # have no way to turn it off -- the option exists only for backwards 42 | # compatibility in RSpec 3). It causes shared context metadata to be 43 | # inherited by the metadata hash of host groups and examples, rather than 44 | # triggering implicit auto-inclusion in groups with matching metadata. 45 | config.shared_context_metadata_behavior = :apply_to_host_groups 46 | 47 | # The settings below are suggested to provide a good initial experience 48 | # with RSpec, but feel free to customize to your heart's content. 49 | =begin 50 | # This allows you to limit a spec run to individual examples or groups 51 | # you care about by tagging them with `:focus` metadata. When nothing 52 | # is tagged with `:focus`, all examples get run. RSpec also provides 53 | # aliases for `it`, `describe`, and `context` that include `:focus` 54 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 55 | config.filter_run_when_matching :focus 56 | 57 | # Allows RSpec to persist some state between runs in order to support 58 | # the `--only-failures` and `--next-failure` CLI options. We recommend 59 | # you configure your source control system to ignore this file. 60 | config.example_status_persistence_file_path = "spec/examples.txt" 61 | 62 | # Limits the available syntax to the non-monkey patched syntax that is 63 | # recommended. For more details, see: 64 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 65 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 66 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 67 | config.disable_monkey_patching! 68 | 69 | # Many RSpec users commonly either run the entire suite or an individual 70 | # file, and it's useful to allow more verbose output when running an 71 | # individual spec file. 72 | if config.files_to_run.one? 73 | # Use the documentation formatter for detailed output, 74 | # unless a formatter has already been configured 75 | # (e.g. via a command-line flag). 76 | config.default_formatter = "doc" 77 | end 78 | 79 | # Print the 10 slowest examples and example groups at the 80 | # end of the spec run, to help surface which specs are running 81 | # particularly slow. 82 | config.profile_examples = 10 83 | 84 | # Run specs in random order to surface order dependencies. If you find an 85 | # order dependency and want to debug it, you can fix the order by providing 86 | # the seed, which is printed after each run. 87 | # --seed 1234 88 | config.order = :random 89 | 90 | # Seed global randomization in this process using the `--seed` CLI option. 91 | # Setting this allows you to use `--seed` to deterministically reproduce 92 | # test failures related to randomization by passing the same `--seed` value 93 | # as the one that triggered the failure. 94 | Kernel.srand config.seed 95 | =end 96 | end 97 | -------------------------------------------------------------------------------- /spec/system/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/spec/system/.keep -------------------------------------------------------------------------------- /spec/system/welcomes_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | RSpec.feature "Welcome", :js, type: :system do 4 | scenario "Visit homepage" do 5 | using_app_host('https://subdomain.localhost.ross') do 6 | visit "/" 7 | 8 | expect(page).to have_content('Welcome') 9 | expect(page).to have_content('Hello from Webpack') 10 | 11 | expect(page).to have_content('Your domain: subdomain.localhost.ross') 12 | expect(page).to have_content('Your protocol: https://') 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | require_relative '../config/environment' 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 7 | fixtures :all 8 | 9 | # Add more helper methods to be used by all tests here... 10 | end 11 | -------------------------------------------------------------------------------- /storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/storage/.keep -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rossta/local-ssl-demo-rails/7e52ff935259c483e60fe4f31eb22d1cf0161559/vendor/.keep --------------------------------------------------------------------------------