Compare commits
7 Commits
get_specs_
...
master
Author | SHA1 | Date |
---|---|---|
|
50b4d8eda4 | 3 years ago |
|
e136495836 | 3 years ago |
|
7d670b1a2b | 3 years ago |
|
e70944bad7 | 3 years ago |
|
5fa6ba40d9 | 3 years ago |
|
fdece3ef18 | 3 years ago |
|
de5facfee3 | 3 years ago |
23 changed files with 140 additions and 141 deletions
@ -1,21 +0,0 @@ |
|||||||
engines: |
|
||||||
brakeman: |
|
||||||
enabled: true |
|
||||||
duplication: |
|
||||||
enabled: true |
|
||||||
config: |
|
||||||
languages: |
|
||||||
- ruby |
|
||||||
# mass_threshold: 30 |
|
||||||
exclude_paths: |
|
||||||
- 'spec/**/*' |
|
||||||
fixme: |
|
||||||
enabled: true |
|
||||||
rubocop: |
|
||||||
enabled: true |
|
||||||
|
|
||||||
ratings: |
|
||||||
paths: |
|
||||||
- app/** |
|
||||||
- lib/** |
|
||||||
- '**.rb' |
|
@ -0,0 +1,42 @@ |
|||||||
|
name: 'CI/CD Pipeline' |
||||||
|
|
||||||
|
on: |
||||||
|
push: |
||||||
|
branches: |
||||||
|
- master |
||||||
|
pull_request: |
||||||
|
workflow_dispatch: |
||||||
|
|
||||||
|
defaults: |
||||||
|
run: |
||||||
|
shell: bash |
||||||
|
|
||||||
|
jobs: |
||||||
|
|
||||||
|
test: |
||||||
|
name: Test |
||||||
|
runs-on: ubuntu-latest |
||||||
|
|
||||||
|
env: |
||||||
|
RAILS_ENV: test |
||||||
|
GEMFILE_RUBY_VERSION: 3.0.3 |
||||||
|
|
||||||
|
# Rails verifies the time zone in DB is the same as the time zone of the Rails app |
||||||
|
TZ: "Europe/London" |
||||||
|
|
||||||
|
|
||||||
|
steps: |
||||||
|
- name: Checkout |
||||||
|
uses: actions/checkout@v2 |
||||||
|
|
||||||
|
- name: Set up Ruby |
||||||
|
uses: ruby/setup-ruby@v1 |
||||||
|
with: |
||||||
|
ruby-version: 3.0.3 |
||||||
|
# runs 'bundle install' and caches installed gems automatically |
||||||
|
bundler-cache: true |
||||||
|
|
||||||
|
- name: Run tests |
||||||
|
run: | |
||||||
|
bundle exec rake spec |
||||||
|
|
@ -1,28 +0,0 @@ |
|||||||
language: ruby |
|
||||||
|
|
||||||
env: |
|
||||||
- "RAILS_VERSION=4.2" |
|
||||||
- "RAILS_VERSION=5.2" |
|
||||||
- "RAILS_VERSION=master" |
|
||||||
|
|
||||||
rvm: |
|
||||||
- 2.3.8 |
|
||||||
- 2.4.5 |
|
||||||
- 2.5.3 |
|
||||||
|
|
||||||
matrix: |
|
||||||
fast_finish: true |
|
||||||
allow_failures: |
|
||||||
- env: "RAILS_VERSION=master" |
|
||||||
include: |
|
||||||
- rvm: 2.2 |
|
||||||
env: RAILS_VERSION=4.2 |
|
||||||
|
|
||||||
before_install: |
|
||||||
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true |
|
||||||
- gem install bundler -v '< 2' |
|
||||||
|
|
||||||
before_script: |
|
||||||
- bundle exec rake app:db:setup |
|
||||||
|
|
||||||
script: bundle exec rake spec |
|
@ -1,17 +1,17 @@ |
|||||||
Warden::Manager.after_authentication do |user, auth, options| |
Warden::Manager.after_authentication do |user, auth, options| |
||||||
if auth.env["action_dispatch.cookies"] |
if auth.env["action_dispatch.cookies"] |
||||||
expected_cookie_value = "#{user.class}-#{user.public_send(Devise.second_factor_resource_id)}" |
expected_cookie_value = "#{user.class}-#{user.public_send(Devise.second_factor_resource_id)}" |
||||||
actual_cookie_value = auth.env["action_dispatch.cookies"].signed[TwoFactorAuthentication::REMEMBER_TFA_COOKIE_NAME] |
actual_cookie_value = auth.env["action_dispatch.cookies"].signed[DeviseTwoFactorAuthentication::REMEMBER_TFA_COOKIE_NAME] |
||||||
bypass_by_cookie = actual_cookie_value == expected_cookie_value |
bypass_by_cookie = actual_cookie_value == expected_cookie_value |
||||||
end |
end |
||||||
|
|
||||||
if user.respond_to?(:need_two_factor_authentication?) && !bypass_by_cookie |
if user.respond_to?(:need_two_factor_authentication?) && !bypass_by_cookie |
||||||
if auth.session(options[:scope])[TwoFactorAuthentication::NEED_AUTHENTICATION] = user.need_two_factor_authentication?(auth.request) |
if auth.session(options[:scope])[DeviseTwoFactorAuthentication::NEED_AUTHENTICATION] = user.need_two_factor_authentication?(auth.request) |
||||||
user.send_new_otp if user.send_new_otp_after_login? |
user.send_new_otp if user.send_new_otp_after_login? |
||||||
end |
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
|
||||||
Warden::Manager.before_logout do |user, auth, _options| |
Warden::Manager.before_logout do |user, auth, _options| |
||||||
auth.cookies.delete TwoFactorAuthentication::REMEMBER_TFA_COOKIE_NAME if Devise.delete_cookie_on_logout |
auth.cookies.delete DeviseTwoFactorAuthentication::REMEMBER_TFA_COOKIE_NAME if Devise.delete_cookie_on_logout |
||||||
end |
end |
@ -0,0 +1,14 @@ |
|||||||
|
require "active_record" |
||||||
|
|
||||||
|
module Devise2Fa |
||||||
|
module Orm |
||||||
|
module ActiveRecord |
||||||
|
module Schema |
||||||
|
# include Devise2Fa::Schema |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
ActiveRecord::ConnectionAdapters::Table.send :include, Devise2Fa::Orm::ActiveRecord::Schema |
||||||
|
ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Devise2Fa::Orm::ActiveRecord::Schema |
@ -0,0 +1,7 @@ |
|||||||
|
module DeviseTwoFactorAuthentication |
||||||
|
class Engine < ::Rails::Engine |
||||||
|
ActiveSupport.on_load(:action_controller) do |
||||||
|
include DeviseTwoFactorAuthentication::Controllers::Helpers |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -1,4 +1,4 @@ |
|||||||
module TwoFactorAuthentication |
module DeviseTwoFactorAuthentication |
||||||
module Schema |
module Schema |
||||||
def second_factor_attempts_count |
def second_factor_attempts_count |
||||||
apply_devise_schema :second_factor_attempts_count, Integer, :default => 0 |
apply_devise_schema :second_factor_attempts_count, Integer, :default => 0 |
@ -0,0 +1,3 @@ |
|||||||
|
module DeviseTwoFactorAuthentication |
||||||
|
VERSION = "3.0.0".freeze |
||||||
|
end |
@ -1,14 +0,0 @@ |
|||||||
require "active_record" |
|
||||||
|
|
||||||
module TwoFactorAuthentication |
|
||||||
module Orm |
|
||||||
module ActiveRecord |
|
||||||
module Schema |
|
||||||
include TwoFactorAuthentication::Schema |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
||||||
|
|
||||||
ActiveRecord::ConnectionAdapters::Table.send :include, TwoFactorAuthentication::Orm::ActiveRecord::Schema |
|
||||||
ActiveRecord::ConnectionAdapters::TableDefinition.send :include, TwoFactorAuthentication::Orm::ActiveRecord::Schema |
|
@ -1,7 +0,0 @@ |
|||||||
module TwoFactorAuthentication |
|
||||||
class Engine < ::Rails::Engine |
|
||||||
ActiveSupport.on_load(:action_controller) do |
|
||||||
include TwoFactorAuthentication::Controllers::Helpers |
|
||||||
end |
|
||||||
end |
|
||||||
end |
|
@ -1,3 +0,0 @@ |
|||||||
module TwoFactorAuthentication |
|
||||||
VERSION = "2.2.0".freeze |
|
||||||
end |
|
Loading…
Reference in new issue