isaca-rails 0.5.0 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90c702697899fa3268bb9f7e7b9520b40fd5d3b7effd2ed3de3b8626cb44bb4d
4
- data.tar.gz: 799f89cdc87027c6330c3cb2a07545e6ea18068bcd7be37661c70afb1774e4bc
3
+ metadata.gz: 700f73c4157cab70ecffb3b4254b656d0a287edbdfa38954a7d5745fb12b6825
4
+ data.tar.gz: 3670014ec5c3bffb8fa6ebd48d6d2addaf4c1014e2199938260e3d112264a956
5
5
  SHA512:
6
- metadata.gz: 0a5961e510658f1922bbbe6dba3a0c58a6c83b8f045a6b605b66c36e5f4f17003087861ac58a7928dd892f6379acc930fb7733c8d8c42a57f359aacbe68c7522
7
- data.tar.gz: 1c4efa1deb6a46bec6c88ff47bab3aceca1a19915f5fc33ac4eef6fd194cc1d5df720250a6e4a73480a0abd61cd760faf9749d0731a2da98232cb32a73446044
6
+ metadata.gz: 34ce9a5babf90bd10becd5ff53ace1dab4d1150e901775c0429719d1f125365fd5a3a69378a608829b1e8eae62dd777e6ec5fa548da428e5829440d59d93835f
7
+ data.tar.gz: b65bc3a5e3386a8b867bf31fb1019406d98d141b64c22999b667dbf150101be8324b8e8e9c944dd2f7ed1e35d23d8270bd3ef2b970aa5bdb3335c3a3e5743145
@@ -3,6 +3,9 @@ module Isaca
3
3
  module Platform
4
4
  class AdministratorsController < ApplicationController
5
5
  def index
6
+ logger = Logger.new(STDOUT)
7
+ logger.debug "**** Isaca Rails ****"
8
+ logger.debug "**** Isaca Rails ****"
6
9
  @administrators = Isaca::Rails.configuration.user_model.where(admin: true)
7
10
  end
8
11
 
@@ -5,7 +5,7 @@ class Isaca::Rails::SessionsController < Isaca::Rails::ApplicationController
5
5
 
6
6
  def create
7
7
  begin
8
- authenticate(sign_in_params[:username], sign_in_params[:password])
8
+ # authenticate(sign_in_params[:username], sign_in_params[:password])
9
9
 
10
10
  respond_to do |format|
11
11
  format.html do
@@ -15,23 +15,23 @@ module Isaca
15
15
  #
16
16
  # @return nil
17
17
  def authenticate_isaca_user
18
- if user_signed_in?
19
- if request.path != user_consent_path && redirect_for_consent?
20
- session[:after_sign_in_path] = request.fullpath if request.get? && request.format.html?
21
- flash.alert = t('isaca.rails.user_consent.consent_required')
22
- redirect_to user_consent_path
23
- end
24
- else
25
- session[:after_sign_in_path] = request.fullpath if request.get?
26
- flash.alert = t('isaca.rails.sessions.sign_in_required')
27
-
28
- respond_to do |format|
29
- format.html {redirect_to sign_in_path}
30
- format.json do
31
- render json: {error: t('isaca.rails.sessions.sign_in_required')}.to_json, status: :unauthorized
32
- end
33
- end
34
- end
18
+ # if user_signed_in?
19
+ # if request.path != user_consent_path && redirect_for_consent?
20
+ # session[:after_sign_in_path] = request.fullpath if request.get? && request.format.html?
21
+ # flash.alert = t('isaca.rails.user_consent.consent_required')
22
+ # redirect_to user_consent_path
23
+ # end
24
+ # else
25
+ # session[:after_sign_in_path] = request.fullpath if request.get?
26
+ # flash.alert = t('isaca.rails.sessions.sign_in_required')
27
+
28
+ # respond_to do |format|
29
+ # format.html {redirect_to sign_in_path}
30
+ # format.json do
31
+ # render json: {error: t('isaca.rails.sessions.sign_in_required')}.to_json, status: :unauthorized
32
+ # end
33
+ # end
34
+ # end
35
35
  end
36
36
 
37
37
  # A helper method for referencing the user who is currently logged in.
@@ -41,8 +41,10 @@ module Isaca
41
41
  if @current_isaca_user
42
42
  @current_isaca_user
43
43
  else
44
- set_current_isaca_user if token_cookie_exists?
45
- end
44
+ unless session[:user_id].blank?
45
+ @current_isaca_user = Isaca::Rails.configuration.user_model.find(session[:user_id])
46
+ end
47
+ end
46
48
  end
47
49
 
48
50
  # Method used to to login a user and set the token
@@ -7,8 +7,9 @@ module Isaca
7
7
  helper_method :user_has_privilege?
8
8
  end
9
9
 
10
- def authorize_isaca_user
11
- if current_isaca_user.admin?
10
+ def authorize_isaca_user(user = nil)
11
+ # if current_isaca_user.admin?
12
+ if (!user.nil? && user.admin?) || (!current_isaca_user.nil? && current_isaca_user.admin?)
12
13
  if %w(index new show create update destroy).include?(action_name)
13
14
  if %w(index show).include?(action_name)
14
15
  behavior = 'read'
@@ -24,7 +25,8 @@ module Isaca
24
25
  end
25
26
 
26
27
  privilege = "#{behavior}_#{controller_name.underscore}".to_sym
27
- unless user_has_privilege?(current_isaca_user, privilege)
28
+ # unless user_has_privilege?(current_isaca_user, privilege)
29
+ unless user_has_privilege?(user, privilege)
28
30
  respond_to do |format|
29
31
  message = "#{t('isaca.rails.claims.admin_required')} Missing claim: #{privilege}."
30
32
 
@@ -59,7 +61,11 @@ module Isaca
59
61
  end
60
62
 
61
63
  def user_has_privilege?(user, privilege)
62
- user.claims.where(privilege: privilege).any?
64
+ unless user.nil?
65
+ user.claims.where(privilege: privilege).any?
66
+ else
67
+ current_isaca_user.has_privilege?(privilege)
68
+ end
63
69
  end
64
70
 
65
71
  def claim_symbols(claim_params, state)
@@ -1,5 +1,5 @@
1
1
  module Isaca
2
2
  module Rails
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isaca-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Orahood
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-09-08 00:00:00.000000000 Z
12
+ date: 2021-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails