rnsap 0.4.12 → 0.4.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/auth.rb +132 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1d839817ae1d8f4264066df07ca40d636746be3eadb962a36c9b5aa98ff86e9
|
4
|
+
data.tar.gz: 8ba9e2b2374a100950ba1d4f11f0684b6c63e09e30b0abbeadb7b4bf32da0795
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 397f61575fdca3c5dcbf9b521bd5e1e6337e21600033463eb7a706bfcf6a26640ce9a9b2c2f7f4d6eac395b6711fef7cddcbb9735440c4826f13fc2a0380d581
|
7
|
+
data.tar.gz: 976094292a14865df24a8c193a93c4db4d39dc3727a453b3dca2dc3db409852c4d3f4793f17a3ed208269dd90819e3d785ca57ad5ff63e8a82236b4fe49a4f1c
|
data/lib/auth.rb
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# Class to handle authorization related SAP information
|
2
|
+
# @author Rogerio Nascimento (26/03/2021)
|
3
|
+
class Auth
|
4
|
+
|
5
|
+
# Return a list of users with authorization
|
6
|
+
# for an object
|
7
|
+
# @param json containing authorization object and optionaly
|
8
|
+
# the tuples with field and value to be checked
|
9
|
+
# @return an array of strings with the list of users
|
10
|
+
def self.for_object(*options)
|
11
|
+
users = []
|
12
|
+
conn, obj, field1, value1, field2, value2 = validate_options(options)
|
13
|
+
return users unless conn && obj
|
14
|
+
|
15
|
+
## Busca o AUTH na tabela UST12
|
16
|
+
ust12_list = Auth.auth_list(conn, obj, field1, value1, field2, value2)
|
17
|
+
return users unless ust12_list
|
18
|
+
|
19
|
+
## Busca o PROFN na tabela UST10S
|
20
|
+
ust10s_list = Auth.profile_list(conn, obj, ust12_list)
|
21
|
+
|
22
|
+
## Busca os Usuários na tabela UST04
|
23
|
+
Auth.user_list(conn, obj, ust10s_list)
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# Select Authorization roles for the Profile
|
28
|
+
# @param list List of profiles to be searched
|
29
|
+
# @return Array<string> with list of authorizations
|
30
|
+
def self.profiles_for_composite(conn, list = [])
|
31
|
+
return [] if list.empty?
|
32
|
+
|
33
|
+
fname = conn.conn.get_function('SIAG_PROF_GET_AUTH')
|
34
|
+
fcall = fname.get_function_call
|
35
|
+
|
36
|
+
fcall[:IV_PROFILE_TYPE] = 'C'
|
37
|
+
list.each do |prof|
|
38
|
+
row = fcall[:IT_PROFILE_RANGE].new_row
|
39
|
+
row[:SIGN] = 'I'
|
40
|
+
row[:OPTION] = 'EQ'
|
41
|
+
row[:LOW] = prof
|
42
|
+
end
|
43
|
+
|
44
|
+
fcall.invoke
|
45
|
+
|
46
|
+
ret = []
|
47
|
+
fcall[:ET_COMPOSITE_PROFILE].each do |row|
|
48
|
+
ret.push(row[:SINGLE_PROFILE])
|
49
|
+
end
|
50
|
+
|
51
|
+
ret
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def self.validate_options(options)
|
58
|
+
return [] if options.empty?
|
59
|
+
params = options.first
|
60
|
+
|
61
|
+
conn = params[:conn]
|
62
|
+
obj = params[:obj]
|
63
|
+
|
64
|
+
return [] unless conn && obj
|
65
|
+
return [] unless conn.class.name == 'RnSap::Sap'
|
66
|
+
|
67
|
+
field1 = params[:field1]
|
68
|
+
value1 = params[:value1]
|
69
|
+
field2 = params[:field2]
|
70
|
+
value2 = params[:value2]
|
71
|
+
|
72
|
+
[conn, obj, field1, value1, field2, value2]
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.auth_list( conn, obj, field1, value1, field2, value2)
|
76
|
+
|
77
|
+
fields = ['AUTH']
|
78
|
+
filter = ["OBJCT = '#{obj}' "]
|
79
|
+
if field1 && value1
|
80
|
+
filter.push(" AND ( FIELD = '#{field1}' AND ( VON = '*' OR VON = '#{value1}' ) ")
|
81
|
+
if field2 && value2
|
82
|
+
filter.push(" OR FIELD = '#{field2}' AND ( VON = '*' OR VON = '#{value2}' ) )")
|
83
|
+
else
|
84
|
+
filter.push( ')')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
conn.read_table('UST12', fields, filter)
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.profile_list( conn, obj, ust12_list)
|
92
|
+
sap_all = 'SAP_ALL'
|
93
|
+
profiles = Auth.profiles_for_composite(conn, [sap_all])
|
94
|
+
profiles.push(sap_all)
|
95
|
+
|
96
|
+
fields = ['PROFN']
|
97
|
+
filter = ["OBJCT = '#{obj}' AND AUTH IN ("]
|
98
|
+
profiles.each do |prof|
|
99
|
+
filter.push( "'#{prof}' , ")
|
100
|
+
end
|
101
|
+
ust12_list.each do |ust|
|
102
|
+
filter.push( "'#{ust.auth}' , ")
|
103
|
+
end
|
104
|
+
filter = filter.uniq
|
105
|
+
puts filter
|
106
|
+
|
107
|
+
new_last = "#{filter.last[0..(filter.last.length - 4)]} )"
|
108
|
+
filter = filter[0..-1].push(new_last)
|
109
|
+
|
110
|
+
conn.read_table('UST10S', fields, filter)
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.user_list(conn, obj, ust10s_list)
|
114
|
+
users = []
|
115
|
+
fields = ['BNAME']
|
116
|
+
filter = ['PROFILE IN (']
|
117
|
+
filter.push("'SAP_ALL' , ")
|
118
|
+
ust10s_list.each do |ust|
|
119
|
+
filter.push("'#{ust.profn}' , ")
|
120
|
+
end
|
121
|
+
new_last = "#{filter.last[0..(filter.last.length - 4)]} )"
|
122
|
+
filter = filter[0..-1].push(new_last)
|
123
|
+
|
124
|
+
ust04_list = conn.read_table('UST04', fields, filter)
|
125
|
+
|
126
|
+
ust04_list.each do |ust|
|
127
|
+
users.push( ust.bname )
|
128
|
+
end
|
129
|
+
|
130
|
+
users.uniq.sort
|
131
|
+
end
|
132
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rnsap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rogerio Nascimento
|
@@ -45,6 +45,7 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- lib/auth.rb
|
48
49
|
- lib/helper/rfc_helper.rb
|
49
50
|
- lib/helper/util_helper.rb
|
50
51
|
- lib/po_detail/all.rb
|