wobauth 5.0.0 → 5.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +8 -2
- data/app/assets/javascripts/wobauth/authorities.js.coffee +8 -8
- data/app/helpers/wobauth/application_helper.rb +1 -33
- data/app/models/wobauth/group.rb +1 -2
- data/app/models/wobauth/role.rb +1 -1
- data/app/services/wobauth/search_ad_user_service.rb +27 -9
- data/app/views/wobauth/ad_users/index.html.erb +60 -54
- data/app/views/wobauth/authorities/_form.html.erb +6 -2
- data/app/views/wobauth/authorities/index.html.erb +38 -33
- data/app/views/wobauth/authorities/show.html.erb +8 -8
- data/app/views/wobauth/groups/index.html.erb +28 -22
- data/app/views/wobauth/memberships/index.html.erb +29 -24
- data/app/views/wobauth/memberships/show.html.erb +4 -4
- data/app/views/wobauth/roles/_role_authorities.html.erb +26 -20
- data/app/views/wobauth/roles/index.html.erb +24 -18
- data/app/views/wobauth/users/index.html.erb +47 -42
- data/config/ldap.yml.example +32 -0
- data/lib/wobauth.rb +9 -4
- data/lib/wobauth/concerns/models/user_concerns.rb +1 -1
- data/lib/wobauth/version.rb +2 -2
- data/spec/factories.rb +20 -4
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed605664e9d17cbb6c0aaed21b9450e4ae07f70d3d57ee9605c2c8ca6620750c
|
4
|
+
data.tar.gz: 597faad405beff61e938fd27cbaf904b198c2d74b235225ba7c4172dd053f847
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adedeb007fe3dd77e7c51412e3cf2f937392a94265a9f1682950a472050dfebc73636e7d86f153f08479057b17b6cf93489dcfd76f5018203981d5256f717990
|
7
|
+
data.tar.gz: abb5c0828eec7e3623e63b72d51cdc4b5b36445147fcf8352e1acedba0b9920646be220f9ab1aceed9c06a2fad6f4f7e9547471db3531e59ed784effd5af9f21
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -34,11 +34,17 @@ wobauth 5.x works with rails 6.x and is designed for autoloading via zeitwerk.
|
|
34
34
|
Requirements
|
35
35
|
------------
|
36
36
|
|
37
|
+
### Rails >= 6.0; autoload = :zeitwerk; webpacker; stimulusjs
|
38
|
+
|
39
|
+
| branch | rails | ruby | bootstrap | icons | wobapphelpers |
|
40
|
+
|------------|-------|--------|-----------|-----------------|---------------|
|
41
|
+
| master(6.x)| >=6.0 | >= 2.6 | v4 | fontawesome 5.x | master (4.x) |
|
42
|
+
|
37
43
|
### Rails >= 6.0, autoload = :zeitwerk
|
38
44
|
|
39
45
|
| branch | rails | ruby | bootstrap | icons | wobapphelpers |
|
40
46
|
|------------|-------|--------|-----------|-----------------|---------------|
|
41
|
-
|
|
47
|
+
| 5-stable | >=6.0 | >= 2.6 | v4 | fontawesome 5.x | master (4.x) |
|
42
48
|
|
43
49
|
### Rails <= 5.2, autoload = :classic
|
44
50
|
|
@@ -181,7 +187,7 @@ included in this rails engine.
|
|
181
187
|
Licence
|
182
188
|
-------
|
183
189
|
|
184
|
-
wobauth Copyright (C) 2014-
|
190
|
+
wobauth Copyright (C) 2014-2021 Wolfgang Barth
|
185
191
|
|
186
192
|
MIT license, see [LICENSE](LICENSE)
|
187
193
|
|
@@ -4,14 +4,14 @@
|
|
4
4
|
|
5
5
|
# - start with given values
|
6
6
|
auth_types = $('#authority_authorizable_type').find("option:selected").val()
|
7
|
-
$('#authority_authorizable_id optgroup').find('option').addBack().
|
8
|
-
$("#authority_authorizable_id optgroup[label=\"#{auth_types}\"]").find('option').addBack().
|
7
|
+
$('#authority_authorizable_id optgroup').find('option').addBack().attr("disabled", true)
|
8
|
+
$("#authority_authorizable_id optgroup[label=\"#{auth_types}\"]").find('option').addBack().attr("disabled", false)
|
9
9
|
|
10
10
|
# - redisplay on change
|
11
11
|
$(document).on('click', '#authority_authorizable_type', ->
|
12
12
|
type = $(this).find("option:selected").val()
|
13
|
-
$('#authority_authorizable_id optgroup').find('option').addBack().
|
14
|
-
$("#authority_authorizable_id optgroup[label=\"#{type}\"]").find('option').addBack().
|
13
|
+
$('#authority_authorizable_id optgroup').find('option').addBack().attr("disabled", true)
|
14
|
+
$("#authority_authorizable_id optgroup[label=\"#{type}\"]").find('option').addBack().attr("disabled", false)
|
15
15
|
)
|
16
16
|
|
17
17
|
#
|
@@ -20,12 +20,12 @@ $(document).on('click', '#authority_authorizable_type', ->
|
|
20
20
|
|
21
21
|
# - start with given values
|
22
22
|
authfor_type = $('#authority_authorized_for_type').find("option:selected").val()
|
23
|
-
$('#authority_authorized_for_id optgroup').find('option').addBack().
|
24
|
-
$("#authority_authorized_for_id optgroup[label=\"#{authfor_type}\"]").find('option').addBack().
|
23
|
+
$('#authority_authorized_for_id optgroup').find('option').addBack().attr("disabled", true)
|
24
|
+
$("#authority_authorized_for_id optgroup[label=\"#{authfor_type}\"]").find('option').addBack().attr("disabled", false)
|
25
25
|
|
26
26
|
# - redisplay on change
|
27
27
|
$(document).on('click', '#authority_authorized_for_type', ->
|
28
28
|
type = $(this).find("option:selected").val()
|
29
|
-
$('#authority_authorized_for_id optgroup').find('option').addBack().
|
30
|
-
$("#authority_authorized_for_id optgroup[label=\"#{type}\"]").find('option').addBack().
|
29
|
+
$('#authority_authorized_for_id optgroup').find('option').addBack().attr("disabled", true)
|
30
|
+
$("#authority_authorized_for_id optgroup[label=\"#{type}\"]").find('option').addBack().attr("disabled", false)
|
31
31
|
)
|
@@ -1,19 +1,7 @@
|
|
1
1
|
module Wobauth
|
2
2
|
module ApplicationHelper
|
3
3
|
include Wobapphelpers::Helpers::All
|
4
|
-
|
5
|
-
def polymorphic_selector(form, poly, types, group_method = :all)
|
6
|
-
msg = ""
|
7
|
-
# -- object available?
|
8
|
-
if form.object.send(poly).present?
|
9
|
-
msg += poly_type_display(form, poly)
|
10
|
-
msg += poly_id_select(form, poly, form.object.send("#{poly}_type"), :all)
|
11
|
-
else
|
12
|
-
msg += poly_type_select(form, poly, types)
|
13
|
-
msg += poly_id_select(form, poly, types, group_method)
|
14
|
-
end
|
15
|
-
msg.html_safe
|
16
|
-
end
|
4
|
+
include Wobapphelpers::Helpers::PolymorphicHelper
|
17
5
|
|
18
6
|
def navigation_admin_links
|
19
7
|
render partial: 'wobauth/shared/admin'
|
@@ -29,25 +17,5 @@ module Wobauth
|
|
29
17
|
end
|
30
18
|
end
|
31
19
|
|
32
|
-
private
|
33
|
-
|
34
|
-
def poly_type_select(f, poly, types)
|
35
|
-
f.input "#{poly}_type".to_sym, collection: types,
|
36
|
-
label_method: lambda {|x| t('activerecord.models.' + x.underscore)}
|
37
|
-
end
|
38
|
-
|
39
|
-
def poly_type_display(f, poly)
|
40
|
-
f.input("#{poly}_type".to_sym, collection: Array(f.object.send("#{poly}_type")),
|
41
|
-
label_method: lambda {|x| t('activerecord.models.' + x.underscore)},
|
42
|
-
disabled: true) +
|
43
|
-
f.hidden_field("#{poly}_type".to_sym, value: f.object.send("#{poly}_type"))
|
44
|
-
end
|
45
|
-
|
46
|
-
def poly_id_select(f, poly, types, group_method)
|
47
|
-
collections = Array(types).map {|t| t.constantize}
|
48
|
-
f.input "#{poly}_id".to_sym, collection: collections,
|
49
|
-
as: :grouped_select, group_method: group_method
|
50
|
-
end
|
51
|
-
|
52
20
|
end
|
53
21
|
end
|
data/app/models/wobauth/group.rb
CHANGED
data/app/models/wobauth/role.rb
CHANGED
@@ -17,17 +17,27 @@ module Wobauth
|
|
17
17
|
return Result.new(success: false, error_messages: ["no query given"], ad_users: [])
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
errors = []
|
21
|
+
ad_users = []
|
22
|
+
ldap_options.each do |ldapopts|
|
23
|
+
ldap = Wobaduser::LDAP.new(ldap_options: ldapopts)
|
24
|
+
if ldap.errors.any?
|
25
|
+
errors += ldap.errors
|
26
|
+
next
|
27
|
+
end
|
28
|
+
search = Wobaduser::User.search(ldap: ldap, filter: user_filter(query))
|
29
|
+
if search.success?
|
30
|
+
ad_users += search.entries
|
31
|
+
else
|
32
|
+
errors += search.errors
|
33
|
+
end
|
23
34
|
end
|
24
35
|
|
25
|
-
|
26
|
-
|
27
|
-
result = Result.new(success: true, error_messages: [], ad_users: search.entries)
|
36
|
+
if errors.any?
|
37
|
+
return Result.new(success: false, error_messages: errors, ad_users: ad_users)
|
28
38
|
else
|
29
|
-
|
30
|
-
|
39
|
+
result = Result.new(success: true, error_messages: errors, ad_users: ad_users)
|
40
|
+
end
|
31
41
|
end
|
32
42
|
|
33
43
|
private
|
@@ -50,5 +60,13 @@ module Wobauth
|
|
50
60
|
filter += ")"
|
51
61
|
filter = Net::LDAP::Filter.construct(filter)
|
52
62
|
end
|
63
|
+
|
64
|
+
def ldap_options
|
65
|
+
if @ldap_options.kind_of? Hash
|
66
|
+
[@ldap_options]
|
67
|
+
else
|
68
|
+
@ldap_options
|
69
|
+
end
|
70
|
+
end
|
53
71
|
end
|
54
|
-
end
|
72
|
+
end
|
@@ -11,59 +11,65 @@
|
|
11
11
|
</div>
|
12
12
|
<br>
|
13
13
|
|
14
|
-
<
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
<
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
<
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
14
|
+
<div data-controller="datatables">
|
15
|
+
<%= content_tag :table, id: :adusers, role: :woauth_datatable,
|
16
|
+
class: "table table-bordered table-striped",
|
17
|
+
data: {
|
18
|
+
target: 'datatables.datatable',
|
19
|
+
} do %>
|
20
|
+
<thead>
|
21
|
+
<tr>
|
22
|
+
<th><%= t('attributes.sn') %></th>
|
23
|
+
<th><%= t('attributes.givenname') %></th>
|
24
|
+
<th><%= t('attributes.ort') %></th>
|
25
|
+
<th><%= t('attributes.plz') %></th>
|
26
|
+
<th><%= t('attributes.streetaddress') %></th>
|
27
|
+
<th><%= t('attributes.department') %></th>
|
28
|
+
<th><%= t('attributes.company') %></th>
|
29
|
+
<th><%= t('attributes.mail') %></th>
|
30
|
+
<th><%= t('attributes.telephonenumber') %></th>
|
31
|
+
<th><%= t('attributes.facsimiletelephonenumber') %></th>
|
32
|
+
<th><%= t('attributes.mobile') %></th>
|
33
|
+
<th><%= t('attributes.username') %></th>
|
34
|
+
<th><%= t('wobauth.action') %></th>
|
35
|
+
</tr>
|
36
|
+
</thead>
|
37
|
+
<tfoot>
|
38
|
+
<tr>
|
39
|
+
<th></th>
|
40
|
+
<th></th>
|
41
|
+
<th></th>
|
42
|
+
<th></th>
|
43
|
+
<th></th>
|
44
|
+
<th></th>
|
45
|
+
<th></th>
|
46
|
+
<th></th>
|
47
|
+
<th></th>
|
48
|
+
<th></th>
|
49
|
+
<th></th>
|
50
|
+
<th></th>
|
51
|
+
<th></th>
|
52
|
+
</tr>
|
53
|
+
</tfoot>
|
49
54
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
55
|
+
<tbody>
|
56
|
+
<% @ad_users.each do |ad_user| %>
|
57
|
+
<%= content_tag(:tr, class: aduser_class(Wobauth::User, ad_user)) do %>
|
58
|
+
<td><%= ad_user.sn %></td>
|
59
|
+
<td><%= ad_user.givenname %></td>
|
60
|
+
<td><%= ad_user.l %></td>
|
61
|
+
<td><%= ad_user.postalcode %></td>
|
62
|
+
<td><%= ad_user.streetaddress %></td>
|
63
|
+
<td><%= ad_user.department %></td>
|
64
|
+
<td><%= ad_user.company %></td>
|
65
|
+
<td><%= ad_user.mail %></td>
|
66
|
+
<td><%= ad_user.telephonenumber %></td>
|
67
|
+
<td><%= ad_user.facsimiletelephonenumber %></td>
|
68
|
+
<td><%= ad_user.mobile %></td>
|
69
|
+
<td><%= ad_user.username %></td>
|
70
|
+
<td><%= new_from_aduser_link(Wobauth::User, ad_user) %></td>
|
71
|
+
<% end %>
|
66
72
|
<% end %>
|
67
|
-
|
68
|
-
|
69
|
-
</
|
73
|
+
</tbody>
|
74
|
+
<% end %>
|
75
|
+
</div>
|
@@ -11,12 +11,16 @@
|
|
11
11
|
<%= polymorphic_selector(f,
|
12
12
|
'authorizable',
|
13
13
|
Wobauth.authorizable_types,
|
14
|
-
Wobauth.authorizable_group_method
|
14
|
+
Wobauth.authorizable_group_method,
|
15
|
+
{class: 'select2'})
|
16
|
+
%>
|
15
17
|
<%= f.association :role %>
|
16
18
|
<%= polymorphic_selector(f,
|
17
19
|
'authorized_for',
|
18
20
|
Wobauth.authorized_for_types,
|
19
|
-
Wobauth.authorized_for_group_method
|
21
|
+
Wobauth.authorized_for_group_method,
|
22
|
+
{class: 'select2'})
|
23
|
+
%>
|
20
24
|
|
21
25
|
<%= f.input :valid_from, as: :string, class: 'datepicker'
|
22
26
|
%>
|
@@ -1,40 +1,45 @@
|
|
1
1
|
<h1><%= t('controller.wobauth/authorities') %></h1>
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
<th><%= t('attributes.role') %></th>
|
10
|
-
<th><%= t('attributes.authorized_for') %></th>
|
11
|
-
<th><%= t('attributes.authorized_for_type') %></th>
|
12
|
-
<th><%= t('attributes.valid_from') %></th>
|
13
|
-
<th><%= t('attributes.valid_until') %></th>
|
14
|
-
<th><%= t('wobauth.action') %></th>
|
15
|
-
</tr>
|
16
|
-
</thead>
|
17
|
-
<tbody>
|
3
|
+
<div data-controller="datatables">
|
4
|
+
<%= content_tag :table, id: :wobauth_authorities, role: :wobauth_datatable,
|
5
|
+
class: "table table-bordered table-striped",
|
6
|
+
data: {
|
7
|
+
target: 'datatables.datatable',
|
8
|
+
} do %>
|
18
9
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
</td>
|
33
|
-
<% end %>
|
34
|
-
<% end %>
|
35
|
-
</tbody>
|
36
|
-
<% end %>
|
10
|
+
<thead>
|
11
|
+
<tr>
|
12
|
+
<th><%= t('attributes.authorizable') %></th>
|
13
|
+
<th><%= t('attributes.authorizable_type') %></th>
|
14
|
+
<th><%= t('attributes.role') %></th>
|
15
|
+
<th><%= t('attributes.authorized_for') %></th>
|
16
|
+
<th><%= t('attributes.authorized_for_type') %></th>
|
17
|
+
<th><%= t('attributes.valid_from') %></th>
|
18
|
+
<th><%= t('attributes.valid_until') %></th>
|
19
|
+
<th><%= t('wobauth.action') %></th>
|
20
|
+
</tr>
|
21
|
+
</thead>
|
22
|
+
<tbody>
|
37
23
|
|
24
|
+
<% @authorities.each do |authority| %>
|
25
|
+
<%= content_tag_for(:tr, authority) do %>
|
26
|
+
<td><%= authority.authorizable %></td>
|
27
|
+
<td><%= authority.authorizable_type %></td>
|
28
|
+
<td><%= authority.role %></td>
|
29
|
+
<td><%= authority.authorized_for %></td>
|
30
|
+
<td><%= authority.authorized_for_type %></td>
|
31
|
+
<td><%= authority.valid_from %></td>
|
32
|
+
<td><%= authority.valid_until %></td>
|
33
|
+
<td class="nowrap">
|
34
|
+
<%= show_link [wobauth, authority] %>
|
35
|
+
<%= edit_link [wobauth, authority] %>
|
36
|
+
<%= delete_link [wobauth, authority] %>
|
37
|
+
</td>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
</tbody>
|
41
|
+
<% end %>
|
42
|
+
</div>
|
38
43
|
<br />
|
39
44
|
|
40
45
|
<%= back_link %>
|
@@ -3,33 +3,33 @@
|
|
3
3
|
<h4><%= t('activerecord.models.wobauth/authority') %></h4>
|
4
4
|
</div>
|
5
5
|
<div class="card-body">
|
6
|
-
<table class="table table-
|
6
|
+
<table class="table table-sm table-borderless">
|
7
7
|
<tr>
|
8
|
-
<th><%= t('attributes.authorizable')%>:</th>
|
8
|
+
<th class="w-25 text-right"><%= t('attributes.authorizable')%>:</th>
|
9
9
|
<td><%= @authority.authorizable %></td>
|
10
10
|
</tr>
|
11
11
|
<tr>
|
12
|
-
<th><%= t('attributes.authorizable_type')%>:</th>
|
12
|
+
<th class="w-25 text-right"><%= t('attributes.authorizable_type')%>:</th>
|
13
13
|
<td><%= @authority.authorizable_type %></td>
|
14
14
|
</tr>
|
15
15
|
<tr>
|
16
|
-
<th><%= t('attributes.role')%>:</th>
|
16
|
+
<th class="w-25 text-right"><%= t('attributes.role')%>:</th>
|
17
17
|
<td><%= @authority.role %></td>
|
18
18
|
</tr>
|
19
19
|
<tr>
|
20
|
-
<th><%= t('attributes.authorized_for')%>:</th>
|
20
|
+
<th class="w-25 text-right"><%= t('attributes.authorized_for')%>:</th>
|
21
21
|
<td><%= @authority.authorized_for %></td>
|
22
22
|
</tr>
|
23
23
|
<tr>
|
24
|
-
<th><%= t('attributes.authorized_for_type')%>:</th>
|
24
|
+
<th class="w-25 text-right"><%= t('attributes.authorized_for_type')%>:</th>
|
25
25
|
<td><%= @authority.authorized_for_type %></td>
|
26
26
|
</tr>
|
27
27
|
<tr>
|
28
|
-
<th><%= t('attributes.valid_from')%>:</th>
|
28
|
+
<th class="w-25 text-right"><%= t('attributes.valid_from')%>:</th>
|
29
29
|
<td><%= @authority.valid_from %></td>
|
30
30
|
</tr>
|
31
31
|
<tr>
|
32
|
-
<th><%= t('attributes.valid_until')%>:</th>
|
32
|
+
<th class="w-25 text-right"><%= t('attributes.valid_until')%>:</th>
|
33
33
|
<td><%= @authority.valid_until %></td>
|
34
34
|
</tr>
|
35
35
|
</table>
|
@@ -1,29 +1,35 @@
|
|
1
1
|
<h1><%= t('controller.wobauth/groups') %></h1>
|
2
2
|
|
3
|
-
<%= content_tag :table, id: :wobauth_groups, role: :wobauth_datatable,
|
4
|
-
class: "table table-bordered table-striped dataTable" do %>
|
5
|
-
<thead>
|
6
|
-
<tr>
|
7
|
-
<th><%= t('attributes.name') %></th>
|
8
|
-
<th><%= t('attributes.description') %></th>
|
9
|
-
<th><%= t('wobauth.action') %></th>
|
10
|
-
</tr>
|
11
|
-
</thead>
|
12
|
-
<tbody>
|
13
3
|
|
14
|
-
|
15
|
-
<%=
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
4
|
+
<div data-controller="datatables">
|
5
|
+
<%= content_tag :table, id: :wobauth_groups, role: :wobauth_datatable,
|
6
|
+
class: "table table-bordered table-striped",
|
7
|
+
data: {
|
8
|
+
target: 'datatables.datatable',
|
9
|
+
} do %>
|
10
|
+
<thead>
|
11
|
+
<tr>
|
12
|
+
<th><%= t('attributes.name') %></th>
|
13
|
+
<th><%= t('attributes.description') %></th>
|
14
|
+
<th><%= t('wobauth.action') %></th>
|
15
|
+
</tr>
|
16
|
+
</thead>
|
17
|
+
<tbody>
|
18
|
+
|
19
|
+
<% @groups.each do |group| %>
|
20
|
+
<%= content_tag_for(:tr, group) do %>
|
21
|
+
<td><%= group.name %></td>
|
22
|
+
<td><%= group.description %></td>
|
23
|
+
<td class="nowrap">
|
24
|
+
<%= show_link [wobauth, group] %>
|
25
|
+
<%= edit_link [wobauth, group] %>
|
26
|
+
<%= delete_link [wobauth, group] %>
|
27
|
+
</td>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
</tbody>
|
23
31
|
<% end %>
|
24
|
-
|
25
|
-
</tbody>
|
26
|
-
<% end %>
|
32
|
+
</div>
|
27
33
|
|
28
34
|
<br />
|
29
35
|
|
@@ -1,31 +1,36 @@
|
|
1
1
|
<h1><%= t('controller.wobauth/memberships') %></h1>
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<
|
11
|
-
|
12
|
-
|
13
|
-
<
|
3
|
+
<div data-controller="datatables">
|
4
|
+
<%= content_tag :table, id: :wobauth_memberships, role: :wobauth_datatable,
|
5
|
+
class: "table table-bordered table-striped dataTable",
|
6
|
+
data: {
|
7
|
+
target: 'datatables.datatable',
|
8
|
+
} do %>
|
9
|
+
<thead>
|
10
|
+
<tr>
|
11
|
+
<th><%= t('attributes.user') %></th>
|
12
|
+
<th><%= t('attributes.group') %></th>
|
13
|
+
<th><%= t('attributes.auto') %></th>
|
14
|
+
<th><%= t('wobauth.action') %></th>
|
15
|
+
</tr>
|
16
|
+
</thead>
|
17
|
+
<tbody>
|
14
18
|
|
15
|
-
<% @memberships.each do |membership| %>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
<% @memberships.each do |membership| %>
|
20
|
+
<%= content_tag_for(:tr, membership) do %>
|
21
|
+
<td><%= membership.user %></td>
|
22
|
+
<td><%= membership.group %></td>
|
23
|
+
<td><%= membership.auto %></td>
|
24
|
+
<td class="nowrap">
|
25
|
+
<%= show_link [wobauth, membership] %>
|
26
|
+
<%= edit_link [wobauth, membership] %>
|
27
|
+
<%= delete_link [wobauth, membership] %>
|
28
|
+
</td>
|
29
|
+
<% end %>
|
25
30
|
<% end %>
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
</tbody>
|
32
|
+
<% end %>
|
33
|
+
</div>
|
29
34
|
|
30
35
|
<br />
|
31
36
|
|
@@ -3,17 +3,17 @@
|
|
3
3
|
<h4><%= t('attributes.membership') %></h4>
|
4
4
|
</div>
|
5
5
|
<div class="card-body">
|
6
|
-
<table class="table table-
|
6
|
+
<table class="table table-sm table-borderless ">
|
7
7
|
<tr>
|
8
|
-
<th><%= t('attributes.user')%>:</th>
|
8
|
+
<th class="w-25 text-right"><%= t('attributes.user')%>:</th>
|
9
9
|
<td><%= @membership.user %></td>
|
10
10
|
</tr>
|
11
11
|
<tr>
|
12
|
-
<th><%= t('attributes.group')%>:</th>
|
12
|
+
<th class="w-25 text-right"><%= t('attributes.group')%>:</th>
|
13
13
|
<td><%= @membership.group %></td>
|
14
14
|
</tr>
|
15
15
|
<tr>
|
16
|
-
<th><%= t('attributes.auto')%>:</th>
|
16
|
+
<th class="w-25 text-right"><%= t('attributes.auto')%>:</th>
|
17
17
|
<td><%= @membership.auto %></td>
|
18
18
|
</tr>
|
19
19
|
</table>
|
@@ -1,21 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
<div data-controller="datatables">
|
2
|
+
<%= content_tag :table, id: :wobauth_role_authorities, role: :wobauth_datatable,
|
3
|
+
class: "table table-sm table-bordered",
|
4
|
+
data: {
|
5
|
+
target: 'datatables.datatable',
|
6
|
+
} do %>
|
7
|
+
|
8
|
+
<thead>
|
9
|
+
<tr>
|
10
|
+
<th><%= t('attributes.user') %></th>
|
11
|
+
<th><%= t('attributes.authorizable_type') %></th>
|
12
|
+
<th><%= t('attributes.authorized_for') %></th>
|
13
|
+
<th><%= t('attributes.authorized_for_type') %></th>
|
14
|
+
</tr>
|
15
|
+
</thead>
|
16
|
+
<tbody>
|
17
|
+
<% authorities.valid(Date.today).each do |authority| %>
|
18
|
+
<%= content_tag_for(:tr, authority) do %>
|
19
|
+
<td><%= link_to authority.authorizable, polymorphic_path([wobauth, authority.authorizable]) %></td>
|
20
|
+
<td><%= authority.authorizable_type %></td>
|
21
|
+
<td><%= authorized_for_link(authority.authorized_for) %></td>
|
22
|
+
<td><%= authority.authorized_for_type %></td>
|
23
|
+
<% end %>
|
18
24
|
<% end %>
|
19
|
-
|
20
|
-
|
21
|
-
|
25
|
+
</tbody>
|
26
|
+
<% end %>
|
27
|
+
</div>
|
@@ -1,25 +1,31 @@
|
|
1
1
|
<h1><%= t('controller.wobauth/roles') %></h1>
|
2
2
|
|
3
|
-
<%= content_tag :table, id: :wobauth_roles, role: :wobauth_datatable,
|
4
|
-
class: "table table-bordered table-striped dataTable" do %>
|
5
|
-
<thead>
|
6
|
-
<tr>
|
7
|
-
<th><%= t('attributes.name') %></th>
|
8
|
-
<th><%= t('wobauth.action') %></th>
|
9
|
-
</tr>
|
10
|
-
</thead>
|
11
|
-
<tbody>
|
12
3
|
|
13
|
-
|
14
|
-
<%=
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
<div data-controller="datatables">
|
5
|
+
<%= content_tag :table, id: :wobauth_roles, role: :wobauth_datatable,
|
6
|
+
class: "table table-bordered table-striped",
|
7
|
+
data: {
|
8
|
+
target: 'datatables.datatable',
|
9
|
+
} do %>
|
10
|
+
<thead>
|
11
|
+
<tr>
|
12
|
+
<th><%= t('attributes.name') %></th>
|
13
|
+
<th><%= t('wobauth.action') %></th>
|
14
|
+
</tr>
|
15
|
+
</thead>
|
16
|
+
<tbody>
|
17
|
+
|
18
|
+
<% @roles.each do |role| %>
|
19
|
+
<%= content_tag_for(:tr, role) do %>
|
20
|
+
<td><%= role.name %></td>
|
21
|
+
<td class="nowrap">
|
22
|
+
<%= show_link [wobauth, role] %>
|
23
|
+
</td>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
26
|
+
</tbody>
|
19
27
|
<% end %>
|
20
|
-
|
21
|
-
</tbody>
|
22
|
-
<% end %>
|
28
|
+
</div>
|
23
29
|
|
24
30
|
<br />
|
25
31
|
|
@@ -1,49 +1,54 @@
|
|
1
1
|
<h1><%= t('controller.wobauth/users') %></h1>
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
<
|
3
|
+
<div data-controller="datatables">
|
4
|
+
<%= content_tag :table, id: :wobauth_users, role: :wobauth_datatable,
|
5
|
+
class: "table table-bordered table-striped",
|
6
|
+
data: {
|
7
|
+
target: 'datatables.datatable',
|
8
|
+
} do %>
|
9
|
+
<thead>
|
10
|
+
<tr>
|
11
|
+
<th><%= t('attributes.name') %></th>
|
12
|
+
<th class="notvisible"><%= t('attributes.sn') %></th>
|
13
|
+
<th class="notvisible"><%= t('attributes.givenname') %></th>
|
14
|
+
<th class="notvisible"><%= t('attributes.title') %></th>
|
15
|
+
<th><%= t('attributes.username') %></th>
|
16
|
+
<th><%= t('attributes.telephone') %></th>
|
17
|
+
<th><%= t('attributes.email') %></th>
|
18
|
+
<th class="notvisible"><%= t('attributes.position') %></th>
|
19
|
+
<th class="notvisible"><%= t('attributes.department') %></th>
|
20
|
+
<th class="notvisible"><%= t('attributes.company') %></th>
|
21
|
+
<th><%= t('attributes.current_sign_in_at') %></th>
|
22
|
+
<th class="notvisible"><%= t('attributes.sign_in_count') %></th>
|
23
|
+
<th><%= t('wobauth.action')%></th>
|
24
|
+
</tr>
|
25
|
+
</thead>
|
26
|
+
<tbody>
|
23
27
|
|
24
|
-
<% @users.each do |user| %>
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
28
|
+
<% @users.each do |user| %>
|
29
|
+
<%= content_tag_for(:tr, user) do %>
|
30
|
+
<td><%= user %></td>
|
31
|
+
<td><%= user.sn %></td>
|
32
|
+
<td><%= user.givenname %></td>
|
33
|
+
<td><%= user.title %></td>
|
34
|
+
<td><%= user.username %></td>
|
35
|
+
<td><%= user.telephone %></td>
|
36
|
+
<td><%= user.email %></td>
|
37
|
+
<td><%= user.position %></td>
|
38
|
+
<td><%= user.department %></td>
|
39
|
+
<td><%= user.company %></td>
|
40
|
+
<td><%= user.current_sign_in_at.try(:to_date) %></td>
|
41
|
+
<td><%= user.sign_in_count %></td>
|
42
|
+
<td class="nowrap">
|
43
|
+
<%= show_link [wobauth, user] %>
|
44
|
+
<%= edit_link [wobauth, user] %>
|
45
|
+
<%= delete_link [wobauth, user] %>
|
46
|
+
</td>
|
47
|
+
<% end %>
|
43
48
|
<% end %>
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
</tbody>
|
50
|
+
<% end %>
|
51
|
+
</div>
|
47
52
|
|
48
53
|
<br />
|
49
54
|
|
data/config/ldap.yml.example
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# simple
|
1
2
|
ldap_options:
|
2
3
|
host: 1.2.3.4
|
3
4
|
port: 3268
|
@@ -7,3 +8,34 @@ ldap_options:
|
|
7
8
|
username: myusername
|
8
9
|
password: mysecretpassword
|
9
10
|
|
11
|
+
# redundant: 1 directory with 2 redundant servers
|
12
|
+
ldap_options:
|
13
|
+
hosts:
|
14
|
+
- [1.2.3.4, 3269]
|
15
|
+
- [5.6.7.8, 3269]
|
16
|
+
encryption: :simple_tls
|
17
|
+
base: dc=example,dc=com
|
18
|
+
auth:
|
19
|
+
method: :simple
|
20
|
+
username: myusername
|
21
|
+
password: mysecretpassword
|
22
|
+
|
23
|
+
# multiple directories
|
24
|
+
ldap_options:
|
25
|
+
- host: 1.2.3.4
|
26
|
+
port: 3268
|
27
|
+
base: dc=example,dc=com
|
28
|
+
auth:
|
29
|
+
method: :simple
|
30
|
+
username: myusername
|
31
|
+
password: mysecretpassword
|
32
|
+
- host: 5.6.7.8
|
33
|
+
port: 3269
|
34
|
+
base: dc=example,dc=com
|
35
|
+
encryption: :simple_tls
|
36
|
+
auth:
|
37
|
+
method: :simple
|
38
|
+
username: myusername
|
39
|
+
password: mysecretpassword
|
40
|
+
|
41
|
+
|
data/lib/wobauth.rb
CHANGED
@@ -45,13 +45,18 @@ module Wobauth
|
|
45
45
|
config ||= Hash.new
|
46
46
|
|
47
47
|
if config['ldap_options'].present?
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
ldapopts = config['ldap_options']
|
49
|
+
if ldapopts.kind_of? Hash
|
50
|
+
ldapopts = [ldapopts]
|
51
|
+
end
|
52
|
+
ldapopts.each do |opts|
|
53
|
+
opts.symbolize_keys!
|
54
|
+
opts.each do |k,v|
|
55
|
+
opts[k] = opts[k].symbolize_keys if opts[k].kind_of? Hash
|
56
|
+
end
|
51
57
|
end
|
52
58
|
else
|
53
59
|
nil
|
54
60
|
end
|
55
61
|
end
|
56
|
-
|
57
62
|
end
|
@@ -9,7 +9,7 @@ module UserConcerns
|
|
9
9
|
has_many :group_roles, through: :groups, source: :roles
|
10
10
|
has_many :group_authorities, through: :groups, source: :authorities
|
11
11
|
|
12
|
-
validates :username, presence: true, uniqueness:
|
12
|
+
validates :username, presence: true, uniqueness: { case_sensitive: false }
|
13
13
|
end
|
14
14
|
|
15
15
|
|
data/lib/wobauth/version.rb
CHANGED
data/spec/factories.rb
CHANGED
@@ -1,12 +1,28 @@
|
|
1
1
|
FactoryBot.define do
|
2
2
|
|
3
|
+
sequence :email, 10000 do |n|
|
4
|
+
"person#{n}@example.net"
|
5
|
+
end
|
6
|
+
|
7
|
+
sequence :group do |n|
|
8
|
+
"group_#{n}"
|
9
|
+
end
|
10
|
+
|
11
|
+
sequence :username do |n|
|
12
|
+
"user_#{n}"
|
13
|
+
end
|
14
|
+
|
15
|
+
sequence :name do |n|
|
16
|
+
"name_#{n}"
|
17
|
+
end
|
18
|
+
|
3
19
|
factory :authority, class: Wobauth::Authority do
|
4
20
|
association :authorizable, factory: :user
|
5
21
|
role
|
6
22
|
end
|
7
23
|
|
8
24
|
factory :group, class: Wobauth::Group do
|
9
|
-
|
25
|
+
name { generate(:name) }
|
10
26
|
end
|
11
27
|
|
12
28
|
factory :membership, class: Wobauth::Membership do
|
@@ -15,12 +31,12 @@ FactoryBot.define do
|
|
15
31
|
end
|
16
32
|
|
17
33
|
factory :role, class: Wobauth::Role do
|
18
|
-
|
34
|
+
name { generate(:name) }
|
19
35
|
end
|
20
36
|
|
21
37
|
factory :user, class: Wobauth::User do
|
22
|
-
|
23
|
-
|
38
|
+
username { generate(:username) }
|
39
|
+
email { generate(:email) }
|
24
40
|
password { "test99" }
|
25
41
|
password_confirmation { "test99" }
|
26
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wobauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wolfgang Barth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '4.
|
33
|
+
version: '4.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '4.
|
40
|
+
version: '4.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: wobaduser
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -554,6 +554,20 @@ dependencies:
|
|
554
554
|
- - ">="
|
555
555
|
- !ruby/object:Gem::Version
|
556
556
|
version: '0'
|
557
|
+
- !ruby/object:Gem::Dependency
|
558
|
+
name: webpacker
|
559
|
+
requirement: !ruby/object:Gem::Requirement
|
560
|
+
requirements:
|
561
|
+
- - "~>"
|
562
|
+
- !ruby/object:Gem::Version
|
563
|
+
version: '4.0'
|
564
|
+
type: :development
|
565
|
+
prerelease: false
|
566
|
+
version_requirements: !ruby/object:Gem::Requirement
|
567
|
+
requirements:
|
568
|
+
- - "~>"
|
569
|
+
- !ruby/object:Gem::Version
|
570
|
+
version: '4.0'
|
557
571
|
description: Rails engine providing MVCs for User, Group, Role, Membership and Authority
|
558
572
|
email: wob@swobspace.de
|
559
573
|
executables: []
|
@@ -684,7 +698,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
684
698
|
- !ruby/object:Gem::Version
|
685
699
|
version: '0'
|
686
700
|
requirements: []
|
687
|
-
rubygems_version: 3.
|
701
|
+
rubygems_version: 3.1.6
|
688
702
|
signing_key:
|
689
703
|
specification_version: 4
|
690
704
|
summary: Rails engine providing MVCs for User, Group, Role, Membership and Authority
|