ixtlan-user-management 0.1.3 → 0.2.0
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.
- data/lib/ixtlan/user_management/{session_plugin.rb → guard.rb} +31 -20
- data/lib/ixtlan/user_management/permission_model.rb +79 -0
- data/lib/ixtlan/user_management/session_cuba.rb +2 -1
- data/lib/ixtlan/user_management/session_model.rb +2 -1
- data/lib/ixtlan/user_management/session_serializer.rb +4 -2
- data/lib/ixtlan/user_management/user_serializer.rb +5 -3
- data/spec/guard_spec.rb +110 -0
- data/spec/session_manager_spec.rb +39 -0
- data/spec/session_serializer_spec.rb +155 -0
- data/spec/spec_helper.rb +40 -0
- metadata +140 -4
@@ -18,35 +18,46 @@
|
|
18
18
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
19
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
20
|
#
|
21
|
-
require 'ixtlan/user_management/
|
22
|
-
|
21
|
+
require 'ixtlan/user_management/permission_model'
|
23
22
|
module Ixtlan
|
24
23
|
module UserManagement
|
25
|
-
|
24
|
+
class Guard
|
25
|
+
METHODS = {
|
26
|
+
:post => 'create',
|
27
|
+
:get => 'retrieve',
|
28
|
+
:put => 'update',
|
29
|
+
:delete => 'delete'
|
30
|
+
}
|
26
31
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
def allow?( resource ,method, association = nil )
|
33
|
+
perm = permissions( resource )
|
34
|
+
(perm.associations.empty? ||
|
35
|
+
perm.associations.include?( association.to_s ) ) &&
|
36
|
+
perm.allow?( METHODS[ method ] ) #TODO, associations )
|
31
37
|
end
|
32
38
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
warn( "[#{login}] #{msg}" )
|
39
|
+
def associations( resource, method )
|
40
|
+
perm = permissions( resource )
|
41
|
+
unless perm.associations.empty?
|
42
|
+
perm.associations
|
38
43
|
end
|
44
|
+
# TODO method
|
39
45
|
end
|
40
|
-
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
+
|
47
|
+
def all_permissions
|
48
|
+
@permissions.values
|
49
|
+
end
|
50
|
+
|
51
|
+
def permissions( resource )
|
52
|
+
@permissions ||= {}
|
53
|
+
@permissions[ resource ] ||= Permission.new( :resource => resource )
|
46
54
|
end
|
47
55
|
|
48
|
-
def
|
49
|
-
|
56
|
+
def permission( resource, *associations, &block )
|
57
|
+
current = permissions( resource )
|
58
|
+
current.associations = associations unless associations.empty?
|
59
|
+
block.call current if block
|
60
|
+
current
|
50
61
|
end
|
51
62
|
end
|
52
63
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2013 Christian Meier
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
require 'virtus'
|
22
|
+
module Ixtlan
|
23
|
+
module UserManagement
|
24
|
+
class Action
|
25
|
+
include Virtus
|
26
|
+
|
27
|
+
attribute :verb, String
|
28
|
+
attribute :name, String
|
29
|
+
# attribute :associations, Array[String]
|
30
|
+
end
|
31
|
+
class Permission
|
32
|
+
include Virtus
|
33
|
+
|
34
|
+
METHODS = [ :allow_retrieve,
|
35
|
+
:allow_create,
|
36
|
+
:allow_update,
|
37
|
+
:allow_delete ]
|
38
|
+
|
39
|
+
attribute :resource, String
|
40
|
+
attribute :actions, Array[Action], :default => []
|
41
|
+
attribute :allow, Boolean, :default => true
|
42
|
+
attribute :associations, Array[String]
|
43
|
+
|
44
|
+
def allow?( method )#TODO, association = nil )
|
45
|
+
action = self.actions.detect { |a| a.name == method }
|
46
|
+
if self.allow
|
47
|
+
! action.nil? #TODO && ( associations.nil || action.associations.include?( association ) )
|
48
|
+
else
|
49
|
+
action.nil? #TODO associations
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def allow_all
|
54
|
+
self.allow = false
|
55
|
+
self.actions.clear
|
56
|
+
end
|
57
|
+
|
58
|
+
def deny_all
|
59
|
+
self.allow = true
|
60
|
+
self.actions.clear
|
61
|
+
end
|
62
|
+
|
63
|
+
def allow_mutate( *associations )
|
64
|
+
allow_retrieve( *associations )
|
65
|
+
allow_create( *associations )
|
66
|
+
allow_update( *associations )
|
67
|
+
end
|
68
|
+
|
69
|
+
def method_missing( method, *args )
|
70
|
+
if METHODS.include?( method )
|
71
|
+
actions << Action.new( :name => method.to_s.sub( /allow_/, '' ),
|
72
|
+
:associations => args )
|
73
|
+
else
|
74
|
+
super
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -64,10 +64,11 @@ module Ixtlan
|
|
64
64
|
# be compliant with rack-protection and rack-csrf
|
65
65
|
csrf = session[ :csrf ] || session[ "csrf.token" ]
|
66
66
|
res[ 'X-CSRF-TOKEN' ] = csrf if csrf
|
67
|
+
# self.class.sessions is from CubaApi::CurrentUser
|
67
68
|
write self.class.sessions.create( user )
|
68
69
|
else
|
69
70
|
log "access denied"
|
70
|
-
|
71
|
+
no_body :forbidden # 403
|
71
72
|
end
|
72
73
|
end
|
73
74
|
|
@@ -19,6 +19,7 @@
|
|
19
19
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
20
|
#
|
21
21
|
require 'virtus'
|
22
|
+
require 'ixtlan/user_management/permission_model'
|
22
23
|
module Ixtlan
|
23
24
|
module UserManagement
|
24
25
|
class Session
|
@@ -26,7 +27,7 @@ module Ixtlan
|
|
26
27
|
|
27
28
|
attribute :idle_session_timeout, Integer, :default => 30
|
28
29
|
attribute :user, User
|
29
|
-
attribute :permissions, Array[
|
30
|
+
attribute :permissions, Array[Permission]
|
30
31
|
|
31
32
|
def to_s
|
32
33
|
"Session( #{user.name}<#{user.login}> groups:[ #{user.groups.collect { |g| g.name }.join ',' } ] idle_timeout:#{idle_session_timeout} )"
|
@@ -26,10 +26,12 @@ module Ixtlan
|
|
26
26
|
root 'session'
|
27
27
|
|
28
28
|
add_context( :single,
|
29
|
-
:only => [
|
29
|
+
:only => [],
|
30
|
+
:methods => [:idle_session_timeout ],
|
30
31
|
:include => {
|
31
32
|
:user => {
|
32
|
-
:only => [
|
33
|
+
:only => [],
|
34
|
+
:methods => [ :id, :login, :name ]
|
33
35
|
},
|
34
36
|
:permissions => {
|
35
37
|
:include => [ :actions, :associations ]
|
@@ -24,12 +24,14 @@ module Ixtlan
|
|
24
24
|
class UserSerializer < Ixtlan::Babel::Serializer
|
25
25
|
|
26
26
|
add_context(:session,
|
27
|
-
:only => [
|
27
|
+
:only => [],
|
28
|
+
:methods => [:login, :name],
|
28
29
|
:include=> {
|
29
30
|
:groups => {
|
30
|
-
:only => [
|
31
|
+
:only => [],
|
32
|
+
:methods => [:name]
|
31
33
|
}
|
32
34
|
})
|
33
35
|
end
|
34
36
|
end
|
35
|
-
end
|
37
|
+
end
|
data/spec/guard_spec.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ),
|
3
|
+
'spec_helper.rb' ) )
|
4
|
+
|
5
|
+
require 'ixtlan/user_management/guard'
|
6
|
+
|
7
|
+
describe Ixtlan::UserManagement::Guard do
|
8
|
+
|
9
|
+
subject { Ixtlan::UserManagement::Guard.new }
|
10
|
+
|
11
|
+
let( :root ) do
|
12
|
+
unless u = Ixtlan::UserManagement::User.first
|
13
|
+
u = Ixtlan::UserManagement::User.create( :login => 'root',
|
14
|
+
:name => 'Root',
|
15
|
+
:updated_at => DateTime.now )
|
16
|
+
u.groups << Ixtlan::UserManagement::Group.create( :name => 'root' )
|
17
|
+
end
|
18
|
+
u
|
19
|
+
end
|
20
|
+
|
21
|
+
let( :resources ) { %w( audits errors configuration ) }
|
22
|
+
|
23
|
+
before do
|
24
|
+
%w( audits errors configuration ).each do |resource|
|
25
|
+
subject.permission( resource ).deny_all
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'allows all' do
|
30
|
+
subject.all_permissions.each { |p| p.allow_all }
|
31
|
+
|
32
|
+
[ :get, :post, :put, :delete ].each do |m|
|
33
|
+
%w( audits errors configuration ).each do |resource|
|
34
|
+
[ 'domain1', nil ].each do |asso|
|
35
|
+
subject.allow?( resource, m, asso ).must_equal true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'allows all with associations' do
|
42
|
+
subject.all_permissions.each do |p|
|
43
|
+
p.allow_all
|
44
|
+
p.associations = [ 'domain', 'nodomain' ]
|
45
|
+
end
|
46
|
+
|
47
|
+
[ :get, :post, :put, :delete ].each do |m|
|
48
|
+
%w( audits errors configuration ).each do |resource|
|
49
|
+
[ 'something', nil ].each do |asso|
|
50
|
+
subject.allow?( resource, m, asso ).must_equal false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
[ :get, :post, :put, :delete ].each do |m|
|
55
|
+
%w( audits errors configuration ).each do |resource|
|
56
|
+
subject.allow?( resource, m, 'domain' ).must_equal true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'denies all' do
|
62
|
+
[ :get, :post, :put, :delete ].each do |m|
|
63
|
+
%w( audits errors configuration ).each do |resource|
|
64
|
+
[ 'domain', nil ].each do |asso|
|
65
|
+
subject.allow?( resource, m, asso ).must_equal false
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
Ixtlan::UserManagement::Permission::METHODS.each do |method|
|
72
|
+
|
73
|
+
it "#{method.to_s.sub( /_/, 's ')}" do
|
74
|
+
subject.all_permissions.each { |p| p.send method }
|
75
|
+
|
76
|
+
#subject.all_permissions.each { |p| puts p.attributes.to_yaml }
|
77
|
+
meth = method.to_s.sub( /allow_/, '' )
|
78
|
+
[ :get, :post, :put, :delete ].each do |m|
|
79
|
+
%w( audits errors configuration ).each do |resource|
|
80
|
+
[ 'domain', nil ].each do |asso|
|
81
|
+
expected = Ixtlan::UserManagement::Guard::METHODS[ m ]
|
82
|
+
subject.allow?( resource, m, asso ).must_equal (expected == meth)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
it "#{method.to_s.sub( /_/, 's ')} with associations" do
|
89
|
+
subject.all_permissions.each do |p|
|
90
|
+
p.send method
|
91
|
+
p.associations = [ 'domain', 'nodomain' ]
|
92
|
+
end
|
93
|
+
|
94
|
+
meth = method.to_s.sub( /allow_/, '' )
|
95
|
+
[ :get, :post, :put, :delete ].each do |m|
|
96
|
+
%w( audits errors configuration ).each do |resource|
|
97
|
+
[ 'something', nil ].each do |asso|
|
98
|
+
subject.allow?( resource, m, asso ).must_equal false
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
[ :get, :post, :put, :delete ].each do |m|
|
103
|
+
%w( audits errors configuration ).each do |resource|
|
104
|
+
expected = Ixtlan::UserManagement::Guard::METHODS[ m ]
|
105
|
+
subject.allow?( resource, m, 'domain' ).must_equal (expected == meth)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ),
|
3
|
+
'spec_helper.rb' ) )
|
4
|
+
|
5
|
+
require 'ixtlan/user_management/session_manager'
|
6
|
+
require 'ixtlan/user_management/user_resource'
|
7
|
+
require 'ixtlan/user_management/group_model'
|
8
|
+
|
9
|
+
describe Ixtlan::UserManagement::SessionManager do
|
10
|
+
|
11
|
+
subject { Ixtlan::UserManagement::SessionManager.new }
|
12
|
+
|
13
|
+
let( :user ) do
|
14
|
+
unless u = Ixtlan::UserManagement::User.first
|
15
|
+
u = Ixtlan::UserManagement::User.create( :login => 'root',
|
16
|
+
:name => 'Root',
|
17
|
+
:updated_at => DateTime.now )
|
18
|
+
end
|
19
|
+
u.groups = [ Ixtlan::UserManagement::Group.new( :name => 'root' ),
|
20
|
+
Ixtlan::UserManagement::Group.new( :name => 'admin' )]
|
21
|
+
u
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'roundtrip convert the session' do
|
25
|
+
expected = {
|
26
|
+
"login"=>"root",
|
27
|
+
"name"=>"Root",
|
28
|
+
"groups"=>[{"name"=>"root"},
|
29
|
+
{"name"=>"admin"}]
|
30
|
+
}
|
31
|
+
|
32
|
+
data = subject.to_session( user )
|
33
|
+
data.must_equal expected
|
34
|
+
|
35
|
+
roundtrip = subject.from_session( data )
|
36
|
+
user.must_equal roundtrip
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.expand_path( File.join( File.dirname( __FILE__ ),
|
3
|
+
'spec_helper.rb' ) )
|
4
|
+
|
5
|
+
require 'ixtlan/user_management/session_model'
|
6
|
+
require 'ixtlan/user_management/session_serializer'
|
7
|
+
require 'ixtlan/user_management/guard'
|
8
|
+
require 'ixtlan/babel/factory'
|
9
|
+
|
10
|
+
describe Ixtlan::UserManagement::Session do
|
11
|
+
|
12
|
+
subject do
|
13
|
+
c = Ixtlan::UserManagement::Session.new
|
14
|
+
c.user = root
|
15
|
+
c
|
16
|
+
end
|
17
|
+
|
18
|
+
let( :root ) do
|
19
|
+
unless u = Ixtlan::UserManagement::User.first
|
20
|
+
u = Ixtlan::UserManagement::User.create( :login => 'root',
|
21
|
+
:name => 'Root',
|
22
|
+
:updated_at => DateTime.now )
|
23
|
+
end
|
24
|
+
u
|
25
|
+
end
|
26
|
+
|
27
|
+
let( :factory ) { Ixtlan::Babel::Factory.new }
|
28
|
+
|
29
|
+
let( :guard ) { Ixtlan::UserManagement::Guard.new }
|
30
|
+
|
31
|
+
it 'serializes without permissions' do
|
32
|
+
expected = {
|
33
|
+
"session"=>{"idle_session_timeout"=>30,
|
34
|
+
"user"=>{
|
35
|
+
"id"=>1,
|
36
|
+
"login"=>"root",
|
37
|
+
"name"=>"Root"
|
38
|
+
},
|
39
|
+
"permissions"=>[]
|
40
|
+
}
|
41
|
+
}
|
42
|
+
result = factory.new_serializer( subject ).to_hash
|
43
|
+
result.must_equal expected
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'serializes with root permissions' do
|
47
|
+
%w( audits errors configuration ).each do |resource|
|
48
|
+
guard.permission( resource ).allow_all
|
49
|
+
end
|
50
|
+
|
51
|
+
subject.permissions = guard.all_permissions
|
52
|
+
|
53
|
+
expected = {
|
54
|
+
"session"=>{"idle_session_timeout"=>30,
|
55
|
+
"user"=>{
|
56
|
+
"id"=>1,
|
57
|
+
"login"=>"root",
|
58
|
+
"name"=>"Root"
|
59
|
+
},
|
60
|
+
"permissions"=>[{"resource"=>"audits",
|
61
|
+
"actions"=>[],
|
62
|
+
"allow"=>false,
|
63
|
+
"associations"=>[]},
|
64
|
+
{"resource"=>"errors",
|
65
|
+
"actions"=>[],
|
66
|
+
"allow"=>false,
|
67
|
+
"associations"=>[]},
|
68
|
+
{"resource"=>"configuration",
|
69
|
+
"actions"=>[],
|
70
|
+
"allow"=>false,
|
71
|
+
"associations"=>[]}
|
72
|
+
]
|
73
|
+
}
|
74
|
+
}
|
75
|
+
result = factory.new_serializer( subject ).to_hash
|
76
|
+
result.must_equal expected
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'serializes with some permissions' do
|
80
|
+
guard.permission( 'audits' ).allow_retrieve
|
81
|
+
guard.permission( 'errors' ).allow_create
|
82
|
+
guard.permission( 'configuration' ).allow_update
|
83
|
+
guard.permission( 'users' ).allow_delete
|
84
|
+
|
85
|
+
subject.permissions = guard.all_permissions
|
86
|
+
|
87
|
+
expected = {
|
88
|
+
"session"=>{"idle_session_timeout"=>30,
|
89
|
+
"user"=>{
|
90
|
+
"id"=>1,
|
91
|
+
"login"=>"root",
|
92
|
+
"name"=>"Root"
|
93
|
+
},
|
94
|
+
"permissions"=>[{"resource"=>"audits",
|
95
|
+
"actions"=>[{"verb"=>nil,
|
96
|
+
"name"=>"retrieve"}],
|
97
|
+
"allow"=>true,
|
98
|
+
"associations"=>[]},
|
99
|
+
{"resource"=>"errors",
|
100
|
+
"actions"=>[{"verb"=>nil,
|
101
|
+
"name"=>"create"}],
|
102
|
+
"allow"=>true,
|
103
|
+
"associations"=>[]},
|
104
|
+
{"resource"=>"configuration",
|
105
|
+
"actions"=>[{"verb"=>nil,
|
106
|
+
"name"=>"update"}],
|
107
|
+
"allow"=>true,
|
108
|
+
"associations"=>[]},
|
109
|
+
{"resource"=>"users",
|
110
|
+
"actions"=>[{"verb"=>nil,
|
111
|
+
"name"=>"delete"}],
|
112
|
+
"allow"=>true,
|
113
|
+
"associations"=>[]}
|
114
|
+
]
|
115
|
+
}
|
116
|
+
}
|
117
|
+
result = factory.new_serializer( subject ).to_hash
|
118
|
+
result.must_equal expected
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'serializes permissions with assoications' do
|
122
|
+
guard.permission( 'audits', 'domain' ).allow_mutate
|
123
|
+
guard.permission( 'users', 'nodomain', 'domain' ).allow_delete
|
124
|
+
|
125
|
+
subject.permissions = guard.all_permissions
|
126
|
+
|
127
|
+
expected = {
|
128
|
+
"session"=>{"idle_session_timeout"=>30,
|
129
|
+
"user"=>{
|
130
|
+
"id"=>1,
|
131
|
+
"login"=>"root",
|
132
|
+
"name"=>"Root"
|
133
|
+
},
|
134
|
+
"permissions"=>[{"resource"=>"audits",
|
135
|
+
"actions"=>[{"verb"=>nil,
|
136
|
+
"name"=>"retrieve"},
|
137
|
+
{"verb"=>nil,
|
138
|
+
"name"=>"create"},
|
139
|
+
{"verb"=>nil,
|
140
|
+
"name"=>"update"}],
|
141
|
+
"allow"=>true,
|
142
|
+
"associations"=>["domain"]},
|
143
|
+
{"resource"=>"users",
|
144
|
+
"actions"=>[{"verb"=>nil,
|
145
|
+
"name"=>"delete"}],
|
146
|
+
"allow"=>true,
|
147
|
+
"associations"=>["nodomain", "domain"]}
|
148
|
+
]
|
149
|
+
}
|
150
|
+
}
|
151
|
+
result = factory.new_serializer( subject ).to_hash
|
152
|
+
result.must_equal expected
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# single spec setup
|
2
|
+
$LOAD_PATH.unshift File.join( File.dirname( File.expand_path( File.dirname( __FILE__ ) ) ),
|
3
|
+
'lib' )
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'minitest'
|
7
|
+
rescue LoadError
|
8
|
+
end
|
9
|
+
require 'minitest/autorun'
|
10
|
+
|
11
|
+
require 'dm-timestamps'
|
12
|
+
require 'dm-migrations'
|
13
|
+
require 'dm-validations'
|
14
|
+
#DataMapper::Logger.new(STDOUT, :debug)
|
15
|
+
|
16
|
+
#require 'ixtlan/session'
|
17
|
+
require 'ixtlan/user_management/user_resource'
|
18
|
+
require 'ixtlan/audit/resource'
|
19
|
+
require 'ixtlan/errors/resource'
|
20
|
+
require 'ixtlan/remote'
|
21
|
+
require 'ixtlan/gettext'
|
22
|
+
|
23
|
+
require 'ixtlan/configuration/resource'
|
24
|
+
|
25
|
+
DataMapper.setup :default, 'sqlite3::memory:'
|
26
|
+
DataMapper.finalize
|
27
|
+
|
28
|
+
# single entry in pool for the memory sqlite3
|
29
|
+
# otherwise sqlite3 sometimes does not find certain tables :(
|
30
|
+
class DataObjects::Pooling::Pool
|
31
|
+
|
32
|
+
alias :initialize_old :initialize
|
33
|
+
|
34
|
+
def initialize(max_size, resource, args)
|
35
|
+
initialize_old( 1, resource, args)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
DataObjects::Pooling.pools
|
40
|
+
DataMapper.auto_migrate!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ixtlan-user-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
none: false
|
28
28
|
prerelease: false
|
29
29
|
type: :runtime
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: virtus
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ~>
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0.5'
|
37
|
+
none: false
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0.5'
|
43
|
+
none: false
|
44
|
+
prerelease: false
|
45
|
+
type: :runtime
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: rake
|
32
48
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -91,6 +107,118 @@ dependencies:
|
|
91
107
|
none: false
|
92
108
|
prerelease: false
|
93
109
|
type: :development
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: dm-timestamps
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.2.0
|
117
|
+
none: false
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 1.2.0
|
123
|
+
none: false
|
124
|
+
prerelease: false
|
125
|
+
type: :development
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: dm-validations
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - '='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 1.2.0
|
133
|
+
none: false
|
134
|
+
requirement: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 1.2.0
|
139
|
+
none: false
|
140
|
+
prerelease: false
|
141
|
+
type: :development
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: ixtlan-audit
|
144
|
+
version_requirements: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
none: false
|
150
|
+
requirement: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
none: false
|
156
|
+
prerelease: false
|
157
|
+
type: :development
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: ixtlan-error-handler
|
160
|
+
version_requirements: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - '>='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
none: false
|
166
|
+
requirement: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - '>='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
none: false
|
172
|
+
prerelease: false
|
173
|
+
type: :development
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: ixtlan-remote
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - '>='
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
none: false
|
182
|
+
requirement: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - '>='
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: '0'
|
187
|
+
none: false
|
188
|
+
prerelease: false
|
189
|
+
type: :development
|
190
|
+
- !ruby/object:Gem::Dependency
|
191
|
+
name: ixtlan-gettext
|
192
|
+
version_requirements: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - '>='
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
197
|
+
none: false
|
198
|
+
requirement: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - '>='
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
none: false
|
204
|
+
prerelease: false
|
205
|
+
type: :development
|
206
|
+
- !ruby/object:Gem::Dependency
|
207
|
+
name: ixtlan-configuration
|
208
|
+
version_requirements: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - '>='
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
213
|
+
none: false
|
214
|
+
requirement: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - '>='
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
none: false
|
220
|
+
prerelease: false
|
221
|
+
type: :development
|
94
222
|
- !ruby/object:Gem::Dependency
|
95
223
|
name: json
|
96
224
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -143,11 +271,12 @@ files:
|
|
143
271
|
- lib/ixtlan/user_management/session_cuba.rb
|
144
272
|
- lib/ixtlan/user_management/session_model.rb
|
145
273
|
- lib/ixtlan/user_management/dummy_authentication.rb
|
146
|
-
- lib/ixtlan/user_management/session_plugin.rb
|
147
274
|
- lib/ixtlan/user_management/authenticator.rb
|
148
275
|
- lib/ixtlan/user_management/user_serializer.rb
|
149
276
|
- lib/ixtlan/user_management/session_manager.rb
|
150
277
|
- lib/ixtlan/user_management/session_serializer.rb
|
278
|
+
- lib/ixtlan/user_management/permission_model.rb
|
279
|
+
- lib/ixtlan/user_management/guard.rb
|
151
280
|
- lib/ixtlan/user_management/authentication_model.rb
|
152
281
|
- lib/ixtlan/user_management/application_model.rb
|
153
282
|
- lib/ixtlan/user_management/group_model.rb
|
@@ -155,6 +284,10 @@ files:
|
|
155
284
|
- lib/ixtlan/user_management/user_model.rb
|
156
285
|
- lib/ixtlan/user_management/application_resource.rb
|
157
286
|
- lib/ixtlan/user_management/user_resource.rb
|
287
|
+
- spec/session_serializer_spec.rb
|
288
|
+
- spec/guard_spec.rb
|
289
|
+
- spec/session_manager_spec.rb
|
290
|
+
- spec/spec_helper.rb
|
158
291
|
- MIT-LICENSE
|
159
292
|
- README.md
|
160
293
|
- Gemfile
|
@@ -183,4 +316,7 @@ rubygems_version: 1.8.24
|
|
183
316
|
signing_key:
|
184
317
|
specification_version: 3
|
185
318
|
summary: helper for managing users with login/password
|
186
|
-
test_files:
|
319
|
+
test_files:
|
320
|
+
- spec/session_serializer_spec.rb
|
321
|
+
- spec/guard_spec.rb
|
322
|
+
- spec/session_manager_spec.rb
|