This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.
Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).
| $ ruby -v t.rb | |
| ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17] | |
| Lookup | |
| Warming up -------------------------------------- | |
| Symbol Hash, Symbol Key | |
| 259.197k i/100ms | |
| String Hash, String Key | |
| 231.953k i/100ms | |
| Symbol Hash, String Key | |
| 203.959k i/100ms |
This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.
Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).
| <VirtualHost *:8443> | |
| ServerAdmin webmaster@localhost | |
| DocumentRoot /var/www/html | |
| ErrorLog ${APACHE_LOG_DIR}/error.log | |
| CustomLog ${APACHE_LOG_DIR}/access.log combined | |
| </VirtualHost> |
In the apps config/puma.rb file:
Change to match your CPU core count
# Check using this on the server => grep -c processor /proc/cpuinfo
workers 4
# Min and Max threads per worker
threads 1, 6
app_dir = File.expand_path('../..', FILE)
This is just some code I recently used in my development application in order to add token-based authentication for my api-only rails app. The api-client was to be consumed by a mobile application, so I needed an authentication solution that would keep the user logged in indefinetly and the only way to do this was either using refresh tokens or sliding sessions.
I also needed a way to both blacklist and whitelist tokens based on a unique identifier (jti)
Before trying it out DIY, I considered using:
| require 'base64' | |
| require 'json' | |
| require 'openssl' | |
| require 'time' | |
| def secure_compare(a, b) | |
| return false unless a.bytesize == b.bytesize | |
| l = a.unpack "C#{a.bytesize}" |