ixtlan-remote 0.1.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/Gemfile +2 -0
- data/README.md +64 -0
- data/agpl-3.0.txt +661 -0
- data/lib/ixtlan-remote.rb +23 -0
- data/lib/ixtlan/passwords.rb +52 -0
- data/lib/ixtlan/passwords.rb~ +47 -0
- data/lib/ixtlan/railtie.rb~ +17 -0
- data/lib/ixtlan/remote.rb +23 -0
- data/lib/ixtlan/remote/access_controller.rb +62 -0
- data/lib/ixtlan/remote/access_controller.rb~ +25 -0
- data/lib/ixtlan/remote/constant_time_compare.rb +39 -0
- data/lib/ixtlan/remote/constant_time_compare.rb~ +19 -0
- data/lib/ixtlan/remote/heartbeat.rb~ +80 -0
- data/lib/ixtlan/remote/model_conversion.rb~ +245 -0
- data/lib/ixtlan/remote/model_helpers.rb +73 -0
- data/lib/ixtlan/remote/model_helpers.rb~ +53 -0
- data/lib/ixtlan/remote/permission.rb +40 -0
- data/lib/ixtlan/remote/permission.rb~ +19 -0
- data/lib/ixtlan/remote/railtie.rb +30 -0
- data/lib/ixtlan/remote/railtie.rb~ +9 -0
- data/lib/ixtlan/remote/remote_access_controller.rb~ +25 -0
- data/lib/ixtlan/remote/remote_permisson.rb~ +9 -0
- data/lib/ixtlan/remote/resource.rb +145 -0
- data/lib/ixtlan/remote/resource.rb-~ +165 -0
- data/lib/ixtlan/remote/resource.rb~ +152 -0
- data/lib/ixtlan/remote/rest.rb +108 -0
- data/lib/ixtlan/remote/rest.rb~ +83 -0
- data/lib/ixtlan/remote/rest_resource.rb~ +140 -0
- data/lib/ixtlan/remote/rest_resource_config.rb~ +63 -0
- data/lib/ixtlan/remote/rest_resource_factory.rb~ +259 -0
- data/lib/ixtlan/remote/rest_resource_old.rb-~ +259 -0
- data/lib/ixtlan/remote/server.rb +119 -0
- data/lib/ixtlan/remote/server.rb~ +82 -0
- data/lib/ixtlan/remote/summary.rb +46 -0
- data/lib/ixtlan/remote/summary.rb~ +23 -0
- data/lib/ixtlan/remote/sync.rb +104 -0
- data/lib/ixtlan/remote/sync.rb~ +78 -0
- data/lib/ixtlan/remote/sync_summary.rb~ +23 -0
- data/lib/ixtlan/remote/tranlation_key.rb~ +7 -0
- data/lib/ixtlan/remote/translation.rake~ +194 -0
- data/lib/ixtlan/remote/translation_models.rb~ +11 -0
- data/lib/ixtlan/remote/updater.rb~ +71 -0
- data/lib/ixtlan/user_management/application_model.rb +30 -0
- data/lib/ixtlan/user_management/application_model.rb~ +21 -0
- data/lib/ixtlan/user_management/application_resource.rb +48 -0
- data/lib/ixtlan/user_management/application_resource.rb~ +21 -0
- data/lib/ixtlan/user_management/authentcator.rb~ +31 -0
- data/lib/ixtlan/user_management/authentication_model.rb +31 -0
- data/lib/ixtlan/user_management/authentication_model.rb~ +21 -0
- data/lib/ixtlan/user_management/authenticator.rb +55 -0
- data/lib/ixtlan/user_management/authenticator.rb~ +20 -0
- data/lib/ixtlan/user_management/domain_resource.rb +48 -0
- data/lib/ixtlan/user_management/domain_resource.rb~ +21 -0
- data/lib/ixtlan/user_management/dummy_authentication.rb +50 -0
- data/lib/ixtlan/user_management/dummy_authentication.rb~ +49 -0
- data/lib/ixtlan/user_management/group.rb~ +39 -0
- data/lib/ixtlan/user_management/group_model.rb +31 -0
- data/lib/ixtlan/user_management/group_model.rb~ +21 -0
- data/lib/ixtlan/user_management/models.rb~ +39 -0
- data/lib/ixtlan/user_management/session-serializer.rb~ +18 -0
- data/lib/ixtlan/user_management/session_cuba.rb +47 -0
- data/lib/ixtlan/user_management/session_cuba.rb~ +44 -0
- data/lib/ixtlan/user_management/session_manager.rb +38 -0
- data/lib/ixtlan/user_management/session_model.rb +36 -0
- data/lib/ixtlan/user_management/session_model.rb~ +10 -0
- data/lib/ixtlan/user_management/session_plugin.rb +32 -0
- data/lib/ixtlan/user_management/session_serializer.rb +21 -0
- data/lib/ixtlan/user_management/session_serializer.rb~ +21 -0
- data/lib/ixtlan/user_management/user.rb~ +16 -0
- data/lib/ixtlan/user_management/user_model.rb +36 -0
- data/lib/ixtlan/user_management/user_model.rb~ +33 -0
- data/lib/ixtlan/user_management/user_resource.rb +55 -0
- data/lib/ixtlan/user_management/user_resource.rb~ +24 -0
- data/lib/ixtlan/user_management/user_serializer.rb +15 -0
- data/lib/ixtlan/user_management/user_serializer.rb~ +23 -0
- data/spec/access_controller_spec.rb +65 -0
- data/spec/access_controller_spec.rb~ +65 -0
- data/spec/model_helpers_spec.rb +40 -0
- data/spec/model_helpers_spec.rb~ +36 -0
- data/spec/remote_access_controller_spec.rb~ +36 -0
- data/spec/resource_spec.rb +181 -0
- data/spec/resource_spec.rb~ +173 -0
- data/spec/rest_resource_spec.rb~ +173 -0
- data/spec/rest_spec.rb +94 -0
- data/spec/rest_spec.rb~ +99 -0
- data/spec/rest_with_attribute_name_like_model_name_spec.rb +82 -0
- data/spec/sync_spec.rb +83 -0
- data/spec/sync_spec.rb~ +81 -0
- metadata +313 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ixtlan-remote - helper sync data between miniapps or communicate wth realtime
|
|
3
|
+
# rest-services
|
|
4
|
+
# Copyright (C) 2012 Christian Meier
|
|
5
|
+
#
|
|
6
|
+
# This file is part of ixtlan-remote.
|
|
7
|
+
#
|
|
8
|
+
# ixtlan-remote is free software: you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU Affero General Public License as
|
|
10
|
+
# published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
# License, or (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# ixtlan-remote is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU Affero General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
# along with ixtlan-remote. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
#
|
|
21
|
+
require 'virtus'
|
|
22
|
+
module Ixtlan
|
|
23
|
+
module UserManagement
|
|
24
|
+
class Authentication
|
|
25
|
+
include Virtus
|
|
26
|
+
|
|
27
|
+
attribute :login, String
|
|
28
|
+
attribute :password, String
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Ixtlan
|
|
2
|
+
module UserManagement
|
|
3
|
+
class Application
|
|
4
|
+
include Virtus
|
|
5
|
+
|
|
6
|
+
attribute :name, String
|
|
7
|
+
attribute :url, String
|
|
8
|
+
end
|
|
9
|
+
class Group
|
|
10
|
+
include Virtus
|
|
11
|
+
|
|
12
|
+
attribute :name, String
|
|
13
|
+
end
|
|
14
|
+
class Authentication
|
|
15
|
+
include Virtus
|
|
16
|
+
|
|
17
|
+
attribute :login, String
|
|
18
|
+
attribute :password, String
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ixtlan-remote - helper sync data between miniapps or communicate wth realtime
|
|
3
|
+
# rest-services
|
|
4
|
+
# Copyright (C) 2012 Christian Meier
|
|
5
|
+
#
|
|
6
|
+
# This file is part of ixtlan-remote.
|
|
7
|
+
#
|
|
8
|
+
# ixtlan-remote is free software: you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU Affero General Public License as
|
|
10
|
+
# published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
# License, or (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# ixtlan-remote is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU Affero General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
# along with ixtlan-remote. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
#
|
|
21
|
+
require 'ixtlan/user_management/authentication_model'
|
|
22
|
+
module Ixtlan
|
|
23
|
+
module UserManagement
|
|
24
|
+
class Authenticator
|
|
25
|
+
|
|
26
|
+
def initialize( restserver )
|
|
27
|
+
@restserver = restserver
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def user_new( params )
|
|
31
|
+
User.new( params )
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def login( username_or_email, password )
|
|
35
|
+
user = nil
|
|
36
|
+
@restserver.create( Authentication.new(:login => username_or_email, :password => password) ) do |json, req|
|
|
37
|
+
user = user_new( JSON.load( json ) ) unless json.strip == ''
|
|
38
|
+
nil
|
|
39
|
+
end
|
|
40
|
+
user
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def reset_password( username_or_email )
|
|
44
|
+
result = nil
|
|
45
|
+
@restserver.create( Authentication.new( :login => username_or_email ),
|
|
46
|
+
:reset_password ) do |json, req|
|
|
47
|
+
result = json unless json.strip == ''
|
|
48
|
+
#tell restserver to ignore response
|
|
49
|
+
nil
|
|
50
|
+
end
|
|
51
|
+
result
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Ixtlan
|
|
2
|
+
module UserManagement
|
|
3
|
+
class Authenticator
|
|
4
|
+
|
|
5
|
+
def initialize(restserver)
|
|
6
|
+
@restserver = restserver
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def login( username_or_email, password )
|
|
10
|
+
@restserver.create( Authentication.new(:login => username_or_email, :password => password) ).each do |item|
|
|
11
|
+
p item
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def reset_password(username_or_email)
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ixtlan-remote - helper sync data between miniapps or communicate wth realtime
|
|
3
|
+
# rest-services
|
|
4
|
+
# Copyright (C) 2012 Christian Meier
|
|
5
|
+
#
|
|
6
|
+
# This file is part of ixtlan-remote.
|
|
7
|
+
#
|
|
8
|
+
# ixtlan-remote is free software: you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU Affero General Public License as
|
|
10
|
+
# published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
# License, or (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# ixtlan-remote is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU Affero General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
# along with ixtlan-remote. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
#
|
|
21
|
+
module Ixtlan
|
|
22
|
+
module UserManagement
|
|
23
|
+
class Domain
|
|
24
|
+
|
|
25
|
+
include DataMapper::Resource
|
|
26
|
+
|
|
27
|
+
def self.storage_name(arg)
|
|
28
|
+
'ixtlan_domains'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# key for selectng the IdentityMap should remain this class if
|
|
32
|
+
# there is no single table inheritance with Discriminator in place
|
|
33
|
+
# i.e. the subclass used as key for the IdentityMap
|
|
34
|
+
def self.base_model
|
|
35
|
+
self
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
property :id, Serial
|
|
39
|
+
property :name, String, :unique=>true, :format => /^[a-z]+$/,:required => true, :length => 32
|
|
40
|
+
|
|
41
|
+
timestamps :updated_at
|
|
42
|
+
|
|
43
|
+
# do not record timestamps since they are set from outside
|
|
44
|
+
def set_timestamps_on_save
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Ixtlan
|
|
2
|
+
module UserManagement
|
|
3
|
+
class Domain
|
|
4
|
+
|
|
5
|
+
include DataMapper::Resource
|
|
6
|
+
|
|
7
|
+
def self.storage_name(arg)
|
|
8
|
+
'ixtlan_domains'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
property :id, Serial
|
|
12
|
+
property :name, String, :format => /^[a-z]+$/,:required => true, :length => 32
|
|
13
|
+
|
|
14
|
+
timestamps :updated_at
|
|
15
|
+
|
|
16
|
+
# do not record timestamps since they are set from outside
|
|
17
|
+
def set_timestamps_on_save
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module Ixtlan
|
|
2
|
+
module UserManagement
|
|
3
|
+
module DummyAuthentication
|
|
4
|
+
|
|
5
|
+
def self.need_dummy?( rest, server )
|
|
6
|
+
url = rest.to_server( server ).url
|
|
7
|
+
(url =~ /localhost/ || url =~ /127.0.0.1/ || url =~ /::1/) && !(ENV['SSO'] == 'true' || ENV['SSO'] == '')
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def login(login, password)
|
|
11
|
+
if ! login.blank? && password.blank?
|
|
12
|
+
result = setup_user
|
|
13
|
+
result.login = login.sub( /\[.*/, '' )
|
|
14
|
+
result.name = result.login.capitalize
|
|
15
|
+
result.groups = [ setup_group( login ) ]
|
|
16
|
+
result.applications = [] if result.respond_to? :applications
|
|
17
|
+
result
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
protected
|
|
22
|
+
|
|
23
|
+
def setup_user
|
|
24
|
+
if u = user_model.get!(1)
|
|
25
|
+
result = u
|
|
26
|
+
else
|
|
27
|
+
result.id = 1
|
|
28
|
+
result.updated_at = DateTime.now
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def user_model
|
|
33
|
+
User
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def setup_group( login )
|
|
37
|
+
group_for( Group, login )
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def group_for( model, login )
|
|
41
|
+
model.new('name' => login.sub( /\[.*/, '' ) )
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def split( login )
|
|
45
|
+
login.sub( /.*\[/ , '' ).sub( /\].*/, '' ).split( /,/ )
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Ixtlan
|
|
2
|
+
module UserManagement
|
|
3
|
+
module DummyAuthentication
|
|
4
|
+
|
|
5
|
+
def self.need_dummy?( rest, server )
|
|
6
|
+
rest.to_server( server ).url =~ /localhost/ && !(ENV['SSO'] == 'true' || ENV['SSO'] == '')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def login(login, password)
|
|
10
|
+
puts "-------------------"
|
|
11
|
+
if ! login.blank? && password.blank?
|
|
12
|
+
result = setup_user
|
|
13
|
+
result.login = login.sub( /\[.*/, '' )
|
|
14
|
+
result.name = result.login.humanize
|
|
15
|
+
result.groups = [ setup_group( login ) ]
|
|
16
|
+
result.applications = [] if result.respond_to? :applications
|
|
17
|
+
result
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
protected
|
|
22
|
+
|
|
23
|
+
def setup_user
|
|
24
|
+
if u = user_model.get!(1)
|
|
25
|
+
result = u
|
|
26
|
+
else
|
|
27
|
+
result.id = 1
|
|
28
|
+
result.updated_at = DateTime.now
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def user_model
|
|
33
|
+
raise 'overwrite "user_model"'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def group_for( model, login )
|
|
37
|
+
model.new('name' => login.sub( /\[.*/, '' ) )
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def split( login )
|
|
41
|
+
login.sub( /.*\[/ , '' ).sub( /\].*/, '' ).split( /,/ )
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def setup_group( login )
|
|
45
|
+
raise 'overwrite "setup_group( login )"'
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Ixtlan
|
|
2
|
+
module UserManagement
|
|
3
|
+
class User
|
|
4
|
+
|
|
5
|
+
include DataMapper::Resource
|
|
6
|
+
|
|
7
|
+
def self.storage_name(arg)
|
|
8
|
+
'ixtlan-users'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
property :id, Serial, :auto_validation => false
|
|
12
|
+
|
|
13
|
+
property :login, String, :required => true, :unique => true, :length => 32
|
|
14
|
+
property :name, String, :required => true, :length => 128
|
|
15
|
+
property :updated_at, DateTime, :required => true
|
|
16
|
+
|
|
17
|
+
attr_accessor :groups, :applications
|
|
18
|
+
|
|
19
|
+
# do not record timestamps since they are set from outside
|
|
20
|
+
def set_timestamps_on_save
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Application
|
|
25
|
+
|
|
26
|
+
include DataMapper::Resource
|
|
27
|
+
|
|
28
|
+
property :id, Serial, :auto_validation => false
|
|
29
|
+
|
|
30
|
+
property :name, String, :required => true, :unique => true, :length => 32
|
|
31
|
+
property :url, String, :required => true, :format => :url, :length => 64, :lazy => true
|
|
32
|
+
property :updated_at, DateTime, :required => true, :lazy => true
|
|
33
|
+
|
|
34
|
+
# do not record timestamps since they are set from outside
|
|
35
|
+
def set_timestamps_on_save
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#
|
|
2
|
+
# ixtlan-remote - helper sync data between miniapps or communicate wth realtime
|
|
3
|
+
# rest-services
|
|
4
|
+
# Copyright (C) 2012 Christian Meier
|
|
5
|
+
#
|
|
6
|
+
# This file is part of ixtlan-remote.
|
|
7
|
+
#
|
|
8
|
+
# ixtlan-remote is free software: you can redistribute it and/or modify
|
|
9
|
+
# it under the terms of the GNU Affero General Public License as
|
|
10
|
+
# published by the Free Software Foundation, either version 3 of the
|
|
11
|
+
# License, or (at your option) any later version.
|
|
12
|
+
#
|
|
13
|
+
# ixtlan-remote is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU Affero General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
19
|
+
# along with ixtlan-remote. If not, see <http://www.gnu.org/licenses/>.
|
|
20
|
+
#
|
|
21
|
+
require 'virtus'
|
|
22
|
+
module Ixtlan
|
|
23
|
+
module UserManagement
|
|
24
|
+
class Group
|
|
25
|
+
include Virtus
|
|
26
|
+
|
|
27
|
+
attribute :name, String
|
|
28
|
+
attribute :associations, Array[Object]
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Ixtlan
|
|
2
|
+
module UserManagement
|
|
3
|
+
class Application
|
|
4
|
+
include Virtus
|
|
5
|
+
|
|
6
|
+
attribute :name, String
|
|
7
|
+
attribute :url, String
|
|
8
|
+
end
|
|
9
|
+
class Group
|
|
10
|
+
include Virtus
|
|
11
|
+
|
|
12
|
+
attribute :name, String
|
|
13
|
+
end
|
|
14
|
+
class Authentication
|
|
15
|
+
include Virtus
|
|
16
|
+
|
|
17
|
+
attribute :login, String
|
|
18
|
+
attribute :password, String
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module Ixtlan
|
|
2
|
+
module UserManagement
|
|
3
|
+
class User
|
|
4
|
+
|
|
5
|
+
include DataMapper::Resource
|
|
6
|
+
|
|
7
|
+
def self.storage_name(arg)
|
|
8
|
+
'ixtlan-users'
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
property :id, Serial, :auto_validation => false
|
|
12
|
+
|
|
13
|
+
property :login, String, :required => true, :unique => true, :length => 32
|
|
14
|
+
property :name, String, :required => true, :length => 128
|
|
15
|
+
property :updated_at, DateTime, :required => true
|
|
16
|
+
|
|
17
|
+
attr_accessor :groups, :applications
|
|
18
|
+
|
|
19
|
+
# do not record timestamps since they are set from outside
|
|
20
|
+
def set_timestamps_on_save
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Application
|
|
25
|
+
|
|
26
|
+
include DataMapper::Resource
|
|
27
|
+
|
|
28
|
+
property :id, Serial, :auto_validation => false
|
|
29
|
+
|
|
30
|
+
property :name, String, :required => true, :unique => true, :length => 32
|
|
31
|
+
property :url, String, :required => true, :format => :url, :length => 64, :lazy => true
|
|
32
|
+
property :updated_at, DateTime, :required => true, :lazy => true
|
|
33
|
+
|
|
34
|
+
# do not record timestamps since they are set from outside
|
|
35
|
+
def set_timestamps_on_save
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'ixtlan/babel/serializer'
|
|
2
|
+
class SessionSerializer < Ixtlan::Babel::Serializer
|
|
3
|
+
|
|
4
|
+
root 'session'
|
|
5
|
+
|
|
6
|
+
add_context(:single,
|
|
7
|
+
:only => [:permissions, :idle_session_timeout],
|
|
8
|
+
:include=> {
|
|
9
|
+
:user => {
|
|
10
|
+
:include => [:applications]
|
|
11
|
+
},
|
|
12
|
+
:permissions => {
|
|
13
|
+
:include => [:actions, :associations]
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
end
|