This file describes de required Style Guide used by Basicamente to keep the Best Practices on develop new features or improve/change existents one.
Always follow the folder structure below:
src/
#!/usr/bin/env jruby | |
%W{rails/command/server rack webrick webrick/https}.each { |lib| require lib } | |
ENV['HTTPS'] = 'on' | |
module Rails | |
class Server < ::Rack::Server | |
def default_options | |
super.merge({ |
The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.
First the simplest/core layers, then optional layers depending on which features/functionality you want.
Specs |
|
---|---|
AUTHOR | Ira Herman |
LANGUAGE/STACK | Ruby on Rails Version 4, 5, or 6 |
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:
module Rack | |
class ApiContentType | |
def initialize(app, methods = [:post, :patch], path = /^\/api\/v2+/, content_type = 'application/json') | |
@app = app | |
@methods = (methods.is_a?(Array) ? methods : [methods]).map{ |item| item.to_s.upcase } | |
@path = path | |
@content_type = content_type | |
end | |
def call(env) |
Capybara.register_driver :chrome_custom do |app| | |
caps = Selenium::WebDriver::Remote::Capabilities.chrome( | |
"chromeOptions" => { | |
"args" => ["--headless", "--disable-site-isolation-trials", "--disable-gpu"], | |
"excludeSwitches" => ["enable-logging"], | |
}, | |
) | |
Capybara::Selenium::Driver.new(app, :browser => :chrome, :desired_capabilities => caps) | |
end |
#!/bin/env/ruby | |
# gem "aws-sdk", "~> 2" | |
require "rubygems" | |
require "zlib" | |
require "rubygems/package" | |
require "securerandom" | |
gem "aws-sdk" | |
require "aws-sdk" |