Skip to content

Commit

Permalink
Merge pull request #129 from gate-sso/migrating_to_rails_5
Browse files Browse the repository at this point in the history
Migrating to rails 5
  • Loading branch information
sidpub authored Oct 15, 2018
2 parents 06779d3 + cdebe75 commit 330adc0
Show file tree
Hide file tree
Showing 54 changed files with 394 additions and 258 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ gem 'omniauth-google-oauth2'
gem 'paper_trail'
gem 'paranoia'
gem 'puma'
gem 'rails', '4.2.10'
gem 'rails', '5.0.2'
gem 'redis'
gem 'rotp'
gem 'ruby-saml', '1.8.0'
Expand All @@ -41,6 +41,7 @@ group :development, :test do
gem 'faker'
gem 'mock_redis'
gem 'pry'
gem 'rails-controller-testing'
gem 'rspec-rails'
gem 'rubocop'
gem 'rubocop-rspec'
Expand Down
158 changes: 84 additions & 74 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,58 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.10)
actionpack (= 4.2.10)
actionview (= 4.2.10)
activejob (= 4.2.10)
actioncable (5.0.2)
actionpack (= 5.0.2)
nio4r (>= 1.2, < 3.0)
websocket-driver (~> 0.6.1)
actionmailer (5.0.2)
actionpack (= 5.0.2)
actionview (= 5.0.2)
activejob (= 5.0.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.10)
actionview (= 4.2.10)
activesupport (= 4.2.10)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
actionpack (5.0.2)
actionview (= 5.0.2)
activesupport (= 5.0.2)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.10)
activesupport (= 4.2.10)
actionview (5.0.2)
activesupport (= 5.0.2)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (4.2.10)
activesupport (= 4.2.10)
globalid (>= 0.3.0)
activemodel (4.2.10)
activesupport (= 4.2.10)
builder (~> 3.1)
activerecord (4.2.10)
activemodel (= 4.2.10)
activesupport (= 4.2.10)
arel (~> 6.0)
activesupport (4.2.10)
activejob (5.0.2)
activesupport (= 5.0.2)
globalid (>= 0.3.6)
activemodel (5.0.2)
activesupport (= 5.0.2)
activerecord (5.0.2)
activemodel (= 5.0.2)
activesupport (= 5.0.2)
arel (~> 7.0)
activesupport (5.0.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ansi (1.5.0)
arel (6.0.4)
arel (7.1.4)
ast (2.4.0)
autoprefixer-rails (9.1.3)
autoprefixer-rails (9.1.4)
execjs
bcrypt (3.1.12)
bindex (0.5.0)
bootstrap (4.0.0)
autoprefixer-rails (>= 6.0.3)
popper_js (>= 1.12.9, < 2)
sass (>= 3.5.2)
builder (3.2.3)
capybara (3.6.0)
capybara (3.9.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
Expand Down Expand Up @@ -90,7 +94,6 @@ GEM
safe_yaml (~> 1.0.0)
crass (1.0.4)
database_cleaner (1.7.0)
debug_inspector (0.0.3)
devise (4.5.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
Expand All @@ -101,10 +104,10 @@ GEM
docile (1.3.1)
erubis (2.7.0)
execjs (2.7.0)
factory_bot (4.11.0)
factory_bot (4.11.1)
activesupport (>= 3.0.0)
factory_bot_rails (4.11.0)
factory_bot (~> 4.11.0)
factory_bot_rails (4.11.1)
factory_bot (~> 4.11.1)
railties (>= 3.0.0)
faker (1.9.1)
i18n (>= 0.7)
Expand Down Expand Up @@ -145,14 +148,15 @@ GEM
mini_portile2 (2.3.0)
minitest (5.11.3)
mock_redis (0.19.0)
money (6.12.0)
i18n (>= 0.6.4, < 1.1)
money (6.13.0)
i18n (>= 0.6.4, <= 2)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
mysql2 (0.4.10)
newrelic_rpm (5.3.0.346)
nokogiri (1.8.4)
newrelic_rpm (5.4.0.347)
nio4r (2.3.1)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
oauth2 (1.4.0)
faraday (>= 0.8, < 0.13)
Expand All @@ -171,11 +175,9 @@ GEM
oauth2 (~> 1.1)
omniauth (~> 1.2)
orm_adapter (0.5.0)
paper_trail (9.2.0)
paper_trail (10.0.1)
activerecord (>= 4.2, < 5.3)
paper_trail-association_tracking (< 2)
request_store (~> 1.1)
paper_trail-association_tracking (1.0.0)
parallel (1.12.1)
paranoia (2.4.1)
activerecord (>= 4.0, < 5.3)
Expand All @@ -188,31 +190,34 @@ GEM
method_source (~> 0.9.0)
public_suffix (3.0.3)
puma (3.12.0)
rack (1.6.10)
rack (2.0.5)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.10)
actionmailer (= 4.2.10)
actionpack (= 4.2.10)
actionview (= 4.2.10)
activejob (= 4.2.10)
activemodel (= 4.2.10)
activerecord (= 4.2.10)
activesupport (= 4.2.10)
rails (5.0.2)
actioncable (= 5.0.2)
actionmailer (= 5.0.2)
actionpack (= 5.0.2)
actionview (= 5.0.2)
activejob (= 5.0.2)
activemodel (= 5.0.2)
activerecord (= 5.0.2)
activesupport (= 5.0.2)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.10)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.9)
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
railties (= 5.0.2)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
actionview (~> 5.x, >= 5.0.1)
activesupport (~> 5.x)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (4.2.10)
actionpack (= 4.2.10)
activesupport (= 4.2.10)
railties (5.0.2)
actionpack (= 5.0.2)
activesupport (= 5.0.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
Expand Down Expand Up @@ -245,21 +250,21 @@ GEM
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.58.2)
rubocop (0.59.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-rspec (1.28.0)
rubocop-rspec (1.30.0)
rubocop (>= 0.58.0)
ruby-progressbar (1.10.0)
ruby-saml (1.8.0)
nokogiri (>= 1.5.10)
safe_yaml (1.0.4)
sass (3.5.7)
sass (3.6.0)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand All @@ -284,13 +289,13 @@ GEM
simplecov
simplecov-html (0.10.2)
sixarm_ruby_unaccent (1.2.0)
slim (3.0.9)
slim (4.0.1)
temple (>= 0.7.6, < 0.9)
tilt (>= 1.3.3, < 2.1)
slim-rails (3.1.3)
tilt (>= 2.0.6, < 2.1)
slim-rails (3.2.0)
actionpack (>= 3.1)
railties (>= 3.1)
slim (~> 3.0)
slim (>= 3.0, < 5.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -312,22 +317,26 @@ GEM
turbolinks-source (5.2.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (4.1.18)
uglifier (4.1.19)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.4.0)
unicode_utils (1.4.0)
uuid (2.3.9)
macaddr (~> 1.0)
warden (1.2.7)
rack (>= 1.0)
web-console (3.3.0)
activemodel (>= 4.2)
debug_inspector
railties (>= 4.2)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webmock (3.4.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
whenever (0.10.0)
chronic (>= 0.6.3)
xpath (3.1.0)
Expand Down Expand Up @@ -359,7 +368,8 @@ DEPENDENCIES
paranoia
pry
puma
rails (= 4.2.10)
rails (= 5.0.2)
rails-controller-testing
redis
rotp
rspec-rails
Expand All @@ -381,4 +391,4 @@ DEPENDENCIES
whenever

BUNDLED WITH
1.16.4
1.16.6
2 changes: 1 addition & 1 deletion app/controllers/api_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ApiController < ActionController::Base
protect_from_forgery with: :null_session
before_filter :authenticate_user_from_token!
before_action :authenticate_user_from_token!

def authenticate_user_from_token!
unless AccessToken.valid_token(get_token)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api_resources_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ApiResourcesController < ApplicationController
before_action :set_api_resource, only: [:show, :edit, :update, :destroy, :regenerate_access_key]
before_filter :authenticate_user!, :except => [:authenticate]
before_action :authenticate_user!, :except => [:authenticate]

# GET /api_resources
# GET /api_resources.json
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/host_machines_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class HostMachinesController < ApplicationController
before_action :set_paper_trail_whodunnit
before_action :set_host_machine, only: [:add_group, :show, :edit, :update, :destroy, :delete_group]
prepend_before_filter :setup_user if Rails.env.development?
before_filter :authenticate_user!
before_action :authenticate_user!
def index
@title = "Host"
@host_machines = HostMachine.all
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/nss_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class NssController < ApplicationController
skip_before_filter :verify_authenticity_token, only: [ :add_host, :add_user_to_group ]
before_filter :authenticate_access_token!, only: %i[add_host]
skip_before_action :verify_authenticity_token, only: [ :add_host, :add_user_to_group ]
before_action :authenticate_access_token!, only: %i[add_host]

def host
token = AccessToken.valid_token params[:token]
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/profile_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class ProfileController < ApplicationController
require 'vpn/mobileconfig'

before_action :set_paper_trail_whodunnit
skip_before_filter :verify_authenticity_token, :if => Proc.new { |c| c.request.format == 'application/json' }
before_filter :authenticate_user!, :except => [:user_id, :verify, :authenticate, :authenticate_cas, :authenticate_ms_chap, :authenticate_pam, :public_key] unless Rails.env.development?
skip_before_action :verify_authenticity_token, :if => Proc.new { |c| c.request.format == 'application/json' }
before_action :authenticate_user!, :except => [:user_id, :verify, :authenticate, :authenticate_cas, :authenticate_ms_chap, :authenticate_pam, :public_key] unless Rails.env.development?
prepend_before_filter :setup_user if Rails.env.development?

def regen_auth
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class UsersController < ApplicationController
before_action :set_paper_trail_whodunnit

before_filter :authenticate_user!, :except => [:user_id, :verify, :authenticate, :authenticate_cas, :authenticate_ms_chap, :authenticate_pam, :public_key]
before_action :authenticate_user!, :except => [:user_id, :verify, :authenticate, :authenticate_cas, :authenticate_ms_chap, :authenticate_pam, :public_key]

def index
@user_search = params[:user_search]
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/vpns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class VpnsController < ApplicationController
:add_supplemental_match_domain, :remove_supplemental_match_domain, \
:migrate_to_new_group, :assign_group]

before_filter :authenticate_user!
before_action :authenticate_user!

require 'securerandom'

Expand All @@ -19,10 +19,10 @@ def update
if current_user.admin?
@vpn = Vpn.find(params[:id])
if @vpn.update(vpn_params)
redirect_to vpn_path(@vpn), notice: 'Vpn was successfully updated.'
redirect_to vpn_path(@vpn), notice: 'Vpn was successfully updated.'
end
else
redirect_to vpn_path(@vpn), notice: 'You can not update, not sufficient privileges.'
redirect_to vpn_path(@vpn), notice: 'You can not update, not sufficient privileges.'
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/access_token.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AccessToken < ActiveRecord::Base
class AccessToken < ApplicationRecord
attr_accessor :token

has_paper_trail
Expand Down
2 changes: 1 addition & 1 deletion app/models/api_resource.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ApiResource < ActiveRecord::Base
class ApiResource < ApplicationRecord
attr_accessor :access_key

validates :name, format: { with: /\A[a-zA-Z0-9_-]+\Z/ }, uniqueness: true, presence: true
Expand Down
3 changes: 3 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
Loading

0 comments on commit 330adc0

Please sign in to comment.