egov_utils 0.1.15 → 0.1.16
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/app/assets/javascripts/egov_utils/eGovUtilities.coffee.erb +8 -4
- data/app/controllers/egov_utils/groups_controller.rb +1 -1
- data/app/controllers/egov_utils/people_controller.rb +23 -0
- data/app/models/egov_utils/address.rb +1 -1
- data/app/models/egov_utils/group.rb +4 -0
- data/app/models/egov_utils/person.rb +4 -0
- data/app/models/egov_utils/user.rb +8 -1
- data/app/schemas/egov_utils/person_schema.rb +1 -1
- data/app/schemas/egov_utils/user_schema.rb +1 -1
- data/config/locales/cs.yml +2 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20171109172909_add_external_uid_to_groups.rb +5 -0
- data/lib/egov_utils/auth_source.rb +18 -22
- data/lib/egov_utils/version.rb +1 -1
- metadata +4 -3
- data/app/attributes/egov_utils/fullname.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5e0d2eacc1f1255140048fa865dfe34378472030cbbd7c51bd39efd2f49c152
|
4
|
+
data.tar.gz: 62675a67d00e5dc9b3ffcdf19a833166979091b00d454ca64cbbcdd2b575b63d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 182175b3dbe8628155477389a50ed4dc10c5cb4b785115551ff34e9609dd0c14a34989aaea07f01c382137a1533a00e9a1961809c5e8c342fada11238013718d
|
7
|
+
data.tar.gz: f94cd08099878bcd8c0218f2103aa961f2152a8cd88b54cf5b8236a540d1cd1a5c67021cf6a4d0f3fb42c19f98bc5b38ee4eb91ccf506f72b74f0e8fd338d3be
|
@@ -18,9 +18,10 @@ window.eGovUtilities =
|
|
18
18
|
}
|
19
19
|
|
20
20
|
|
21
|
-
initPage: ()->
|
22
|
-
|
23
|
-
eGovUtilities.
|
21
|
+
initPage: ($container)->
|
22
|
+
$container ||= $(document)
|
23
|
+
eGovUtilities.initDatepickers($container)
|
24
|
+
eGovUtilities.initSelect2($container)
|
24
25
|
|
25
26
|
initDatepickers: ($container)->
|
26
27
|
$container ||= $(document)
|
@@ -64,7 +65,7 @@ window.eGovUtilities =
|
|
64
65
|
setModalContent: ($modal, body, title) ->
|
65
66
|
$modal.find('.modal-title').text(title)
|
66
67
|
$modal.find('.modal-body').html(body)
|
67
|
-
eGovUtilities.
|
68
|
+
eGovUtilities.initPage($modal)
|
68
69
|
|
69
70
|
showModal: (body, options) ->
|
70
71
|
options = options || {}
|
@@ -75,6 +76,9 @@ window.eGovUtilities =
|
|
75
76
|
delete options['title']
|
76
77
|
eGovUtilities.setModalContent($modal, body, title)
|
77
78
|
$modal.modal(options)
|
79
|
+
window.setTimeout(()->
|
80
|
+
eGovUtilities.initPage($modal)
|
81
|
+
, 750)
|
78
82
|
$modal
|
79
83
|
|
80
84
|
$(eGovUtilities.setup)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module EgovUtils
|
2
|
+
class PeopleController < ApplicationController
|
3
|
+
|
4
|
+
load_and_authorize_resource
|
5
|
+
|
6
|
+
def index
|
7
|
+
@people_schema = PersonSchema.new
|
8
|
+
@people_schema.from_params(params)
|
9
|
+
respond_to do |format|
|
10
|
+
if params['_type'] == 'query'
|
11
|
+
format.json{ render json: {
|
12
|
+
results: @people_schema.entities.collect do |p|
|
13
|
+
{id: p.id, text: p.to_s, residence: p.residence.to_s}
|
14
|
+
end
|
15
|
+
}}
|
16
|
+
else
|
17
|
+
format.json{ render json: @people_schema }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -3,7 +3,7 @@ module EgovUtils
|
|
3
3
|
|
4
4
|
# before_safe :identify_address , if: :changed?
|
5
5
|
|
6
|
-
validates :street, :city, length:
|
6
|
+
validates :street, :city, length: 2..255
|
7
7
|
validates :postcode, numericality: { only_integer: true }
|
8
8
|
validates :district, inclusion: { in: :district_names }
|
9
9
|
validates :region, inclusion: { in: :region_names }
|
@@ -106,7 +106,14 @@ module EgovUtils
|
|
106
106
|
|
107
107
|
def ldap_groups
|
108
108
|
if provider.present?
|
109
|
-
|
109
|
+
group_ids = Rails.cache.read("#{cache_key}/ldap_group_ids", expires_in: 30.minutes)
|
110
|
+
if group_ids
|
111
|
+
groups = EgovUtils::Group.where(id: group_ids).to_a
|
112
|
+
else
|
113
|
+
groups = EgovUtils::Group.where(provider: provider).to_a.select{|g| auth_source.member?(ldap_dn, g.external_uid) }
|
114
|
+
Rails.cache.write("#{cache_key}/ldap_group_ids", groups.collect(&:id), expires_in: 30.minutes)
|
115
|
+
end
|
116
|
+
groups
|
110
117
|
end
|
111
118
|
end
|
112
119
|
|
@@ -7,7 +7,7 @@ module EgovUtils
|
|
7
7
|
|
8
8
|
def initialize_available_attributes
|
9
9
|
@available_attributes ||= []
|
10
|
-
@available_attributes <<
|
10
|
+
@available_attributes << AzaharaSchema::DerivedAttribute.new(model, 'fullname', :concat, 'firstname', 'lastname', schema: self)
|
11
11
|
super
|
12
12
|
end
|
13
13
|
|
@@ -7,7 +7,7 @@ module EgovUtils
|
|
7
7
|
|
8
8
|
def initialize_available_attributes
|
9
9
|
@available_attributes ||= []
|
10
|
-
@available_attributes <<
|
10
|
+
@available_attributes << AzaharaSchema::DerivedAttribute.new(model, 'fullname', :concat, 'firstname', 'lastname', schema: self)
|
11
11
|
super
|
12
12
|
@available_attributes << AllRoleNames.new(model, 'all_role_names', 'string')
|
13
13
|
end
|
data/config/locales/cs.yml
CHANGED
data/config/routes.rb
CHANGED
@@ -165,33 +165,19 @@ module EgovUtils
|
|
165
165
|
raise AuthSourceException.new(e.message)
|
166
166
|
end
|
167
167
|
|
168
|
-
def member?(user_dn,
|
168
|
+
def member?(user_dn, group_dn)
|
169
169
|
ldap_con = initialize_ldap_con(options['bind_dn'], options['password'])
|
170
|
-
group_dn
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
group_dn = get_attr(entry, 'dn')
|
176
|
-
end
|
177
|
-
if group_dn
|
178
|
-
ldap_con.search(base: user_dn,
|
179
|
-
filter: base_user_filter & Net::LDAP::Filter.ex('memberOf:1.2.840.113556.1.4.1941', group_dn),
|
180
|
-
attributes: ['dn']) do |entry|
|
181
|
-
return true
|
182
|
-
end
|
170
|
+
Rails.logger.debug("Membership in group (#{group_dn}) for (#{user_dn})")
|
171
|
+
ldap_con.search(base: user_dn,
|
172
|
+
filter: base_user_filter & Net::LDAP::Filter.ex('memberOf:1.2.840.113556.1.4.1941', group_dn),
|
173
|
+
attributes: ['dn']) do |entry|
|
174
|
+
return true
|
183
175
|
end
|
184
176
|
return false
|
185
177
|
end
|
186
178
|
|
187
|
-
def group_members(
|
179
|
+
def group_members(group_dn)
|
188
180
|
ldap_con = initialize_ldap_con(options['bind_dn'], options['password'])
|
189
|
-
group_dn = nil
|
190
|
-
ldap_con.search(base: options['base'],
|
191
|
-
filter: base_group_filter & Net::LDAP::Filter.eq('objectSID', group_sid),
|
192
|
-
attributes: ['dn']) do |entry|
|
193
|
-
group_dn = get_attr(entry, 'dn')
|
194
|
-
end
|
195
181
|
results = []
|
196
182
|
if group_dn
|
197
183
|
ldap_con.search(base: options['base'],
|
@@ -254,7 +240,8 @@ module EgovUtils
|
|
254
240
|
:dn => entry.dn,
|
255
241
|
:name => get_attr(entry, 'cn'),
|
256
242
|
:provider => provider,
|
257
|
-
:ldap_uid => get_sid_string( get_attr(entry, 'objectSID') )
|
243
|
+
:ldap_uid => get_sid_string( get_attr(entry, 'objectSID') ),
|
244
|
+
:external_uid => entry.dn
|
258
245
|
}
|
259
246
|
end
|
260
247
|
|
@@ -297,6 +284,15 @@ module EgovUtils
|
|
297
284
|
attrs
|
298
285
|
end
|
299
286
|
|
287
|
+
def get_group_dn(**options)
|
288
|
+
ldap_con = initialize_ldap_con(options['bind_dn'], options['password'])
|
289
|
+
ldap_con.search(base: options['base'],
|
290
|
+
filter: base_group_filter & ( options[:sid] ? Net::LDAP::Filter.eq('objectSID', options[:sid]) : group_search_filters(options[:name]) ),
|
291
|
+
attributes: ['dn']) do |entry|
|
292
|
+
return get_attr(entry, 'dn')
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
300
296
|
def search_user_dn(login, password=nil)
|
301
297
|
ldap_con = nil
|
302
298
|
if options['bind_dn'].include?("$login")
|
data/lib/egov_utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egov_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ondřej Ezr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -287,11 +287,11 @@ files:
|
|
287
287
|
- app/attributes/egov_utils/all_role_names.rb
|
288
288
|
- app/attributes/egov_utils/district.rb
|
289
289
|
- app/attributes/egov_utils/full_address.rb
|
290
|
-
- app/attributes/egov_utils/fullname.rb
|
291
290
|
- app/attributes/egov_utils/region.rb
|
292
291
|
- app/controllers/egov_utils/addresses_controller.rb
|
293
292
|
- app/controllers/egov_utils/application_controller.rb
|
294
293
|
- app/controllers/egov_utils/groups_controller.rb
|
294
|
+
- app/controllers/egov_utils/people_controller.rb
|
295
295
|
- app/controllers/egov_utils/roles_controller.rb
|
296
296
|
- app/controllers/egov_utils/sessions_controller.rb
|
297
297
|
- app/controllers/egov_utils/users_controller.rb
|
@@ -344,6 +344,7 @@ files:
|
|
344
344
|
- db/migrate/20170809150646_create_egov_utils_people.rb
|
345
345
|
- db/migrate/20170824111701_create_egov_utils_groups.rb
|
346
346
|
- db/migrate/20171103141234_add_birth_place_and_residence_to_people.rb
|
347
|
+
- db/migrate/20171109172909_add_external_uid_to_groups.rb
|
347
348
|
- lib/bootstrap_form/datetimepicker.rb
|
348
349
|
- lib/bootstrap_form/fileuid.rb
|
349
350
|
- lib/bootstrap_form/helpers/bootstrap4.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module EgovUtils
|
2
|
-
class Fullname < AzaharaSchema::Attribute
|
3
|
-
|
4
|
-
def arel_field
|
5
|
-
Arel::Nodes::NamedFunction.new 'CONCAT', [EgovUtils::Person.arel_table[:lastname], Arel::Nodes::SqlLiteral.new('\' \'') , EgovUtils::Person.arel_table[:firstname]]
|
6
|
-
end
|
7
|
-
|
8
|
-
def build_json_options!(options)
|
9
|
-
options[:methods] ||= []
|
10
|
-
options[:methods] << 'fullname'
|
11
|
-
options
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|