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 +4 -4
- data/app/controllers/isaca/rails/platform/administrators_controller.rb +3 -0
- data/app/controllers/isaca/rails/sessions_controller.rb +1 -1
- data/lib/isaca/rails/authentication.rb +21 -19
- data/lib/isaca/rails/authorization.rb +10 -4
- data/lib/isaca/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 700f73c4157cab70ecffb3b4254b656d0a287edbdfa38954a7d5745fb12b6825
|
4
|
+
data.tar.gz: 3670014ec5c3bffb8fa6ebd48d6d2addaf4c1014e2199938260e3d112264a956
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
else
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
45
|
-
|
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.
|
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)
|
data/lib/isaca/rails/version.rb
CHANGED
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.
|
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-
|
12
|
+
date: 2021-09-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|