ixtlan-remote 0.1.7 → 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.
- metadata +2 -38
- data/lib/ixtlan/passwords.rb +0 -72
- data/lib/ixtlan/passwords.rb~ +0 -47
- data/lib/ixtlan/railtie.rb~ +0 -17
- data/lib/ixtlan/user_management/application_model.rb +0 -30
- data/lib/ixtlan/user_management/application_model.rb~ +0 -21
- data/lib/ixtlan/user_management/application_resource.rb +0 -48
- data/lib/ixtlan/user_management/application_resource.rb~ +0 -21
- data/lib/ixtlan/user_management/authentcator.rb~ +0 -31
- data/lib/ixtlan/user_management/authentication_model.rb +0 -31
- data/lib/ixtlan/user_management/authentication_model.rb~ +0 -21
- data/lib/ixtlan/user_management/authenticator.rb +0 -55
- data/lib/ixtlan/user_management/authenticator.rb~ +0 -20
- data/lib/ixtlan/user_management/domain_resource.rb +0 -78
- data/lib/ixtlan/user_management/domain_resource.rb~ +0 -21
- data/lib/ixtlan/user_management/dummy_authentication.rb +0 -70
- data/lib/ixtlan/user_management/dummy_authentication.rb~ +0 -49
- data/lib/ixtlan/user_management/group.rb~ +0 -39
- data/lib/ixtlan/user_management/group_model.rb +0 -31
- data/lib/ixtlan/user_management/group_model.rb~ +0 -21
- data/lib/ixtlan/user_management/models.rb~ +0 -39
- data/lib/ixtlan/user_management/session-serializer.rb~ +0 -18
- data/lib/ixtlan/user_management/session_cuba.rb +0 -67
- data/lib/ixtlan/user_management/session_cuba.rb~ +0 -44
- data/lib/ixtlan/user_management/session_manager.rb +0 -71
- data/lib/ixtlan/user_management/session_model.rb +0 -36
- data/lib/ixtlan/user_management/session_model.rb~ +0 -10
- data/lib/ixtlan/user_management/session_plugin.rb +0 -52
- data/lib/ixtlan/user_management/session_serializer.rb +0 -41
- data/lib/ixtlan/user_management/session_serializer.rb~ +0 -21
- data/lib/ixtlan/user_management/user.rb~ +0 -16
- data/lib/ixtlan/user_management/user_model.rb +0 -36
- data/lib/ixtlan/user_management/user_model.rb~ +0 -33
- data/lib/ixtlan/user_management/user_resource.rb +0 -55
- data/lib/ixtlan/user_management/user_resource.rb~ +0 -24
- data/lib/ixtlan/user_management/user_serializer.rb +0 -35
- data/lib/ixtlan/user_management/user_serializer.rb~ +0 -23
@@ -1,20 +0,0 @@
|
|
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
|
@@ -1,78 +0,0 @@
|
|
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
|
-
ALL_ID = 1
|
39
|
-
DEFAULT_ID = 2
|
40
|
-
|
41
|
-
ALL_NAME= 'ALL'
|
42
|
-
DEFAULT_NAME = 'DEFAULT'
|
43
|
-
|
44
|
-
def self.ALL
|
45
|
-
first_or_create( :id => ALL_ID, :name => ALL_NAME )
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.DEFAULT
|
49
|
-
first_or_create( :id => DEFAULT_ID, :name => DEFAULT_NAME )
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.almost_all( args = {} )
|
53
|
-
all( { :id.gt => ALL_ID }.merge( args ) )
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.first_or_create( args )
|
57
|
-
first( args ) || create!( args.merge( {:updated_at => DateTime.new( 1 ) } ) )
|
58
|
-
end
|
59
|
-
|
60
|
-
property :id, Serial
|
61
|
-
property :name, String, :unique => true, :format => /ALL|DEFAULT|^[a-z]+$/,:required => true, :length => 32
|
62
|
-
|
63
|
-
timestamps :updated_at
|
64
|
-
|
65
|
-
# do not record timestamps since they are set from outside
|
66
|
-
def set_timestamps_on_save
|
67
|
-
end
|
68
|
-
|
69
|
-
def all?
|
70
|
-
name == ALL_NAME
|
71
|
-
end
|
72
|
-
|
73
|
-
def default?
|
74
|
-
name == DEFAULT_NAME
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,70 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# ixtlan-remote - helper sync data between miniapps or communicate wth realtime
|
3
|
-
# rest-services
|
4
|
-
# Copyright (C) 2013 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
|
-
module DummyAuthentication
|
24
|
-
|
25
|
-
def self.need_dummy?( rest, server )
|
26
|
-
url = rest.to_server( server ).url
|
27
|
-
(url =~ /localhost/ || url =~ /127.0.0.1/ || url =~ /::1/) && !(ENV['SSO'] == 'true' || ENV['SSO'] == '')
|
28
|
-
end
|
29
|
-
|
30
|
-
def login(login, password)
|
31
|
-
if ! login.blank? && password.blank?
|
32
|
-
result = setup_user
|
33
|
-
result.login = login.sub( /\[.*/, '' )
|
34
|
-
result.name = result.login.capitalize
|
35
|
-
result.groups = [ setup_group( login ) ]
|
36
|
-
result.applications = [] if result.respond_to? :applications
|
37
|
-
result
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
protected
|
42
|
-
|
43
|
-
def setup_user
|
44
|
-
if u = user_model.get!(1)
|
45
|
-
result = u
|
46
|
-
else
|
47
|
-
result.id = 1
|
48
|
-
result.updated_at = DateTime.now
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def user_model
|
53
|
-
User
|
54
|
-
end
|
55
|
-
|
56
|
-
def setup_group( login )
|
57
|
-
group_for( Group, login )
|
58
|
-
end
|
59
|
-
|
60
|
-
def group_for( model, login )
|
61
|
-
model.new('name' => login.sub( /\[.*/, '' ) )
|
62
|
-
end
|
63
|
-
|
64
|
-
def split( login )
|
65
|
-
login.sub( /.*\[/ , '' ).sub( /\].*/, '' ).split( /,/ )
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,49 +0,0 @@
|
|
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
|
@@ -1,39 +0,0 @@
|
|
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
|
@@ -1,31 +0,0 @@
|
|
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
|
@@ -1,21 +0,0 @@
|
|
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
|
@@ -1,39 +0,0 @@
|
|
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
|
@@ -1,18 +0,0 @@
|
|
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
|
@@ -1,67 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# ixtlan-remote - helper sync data between miniapps or communicate wth realtime
|
3
|
-
# rest-services
|
4
|
-
# Copyright (C) 2013 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
|
-
# -*- Coding: utf-8 -*-
|
22
|
-
require 'ixtlan/user_management/session_plugin'
|
23
|
-
|
24
|
-
module Ixtlan
|
25
|
-
module UserManagement
|
26
|
-
|
27
|
-
class SessionCuba < CubaAPI
|
28
|
-
|
29
|
-
plugin SessionPlugin
|
30
|
-
|
31
|
-
define do
|
32
|
-
on post, :reset_password do
|
33
|
-
if msg = self.class.authenticator.reset_password( login_and_password[ 0 ] )
|
34
|
-
log msg
|
35
|
-
head 200
|
36
|
-
else
|
37
|
-
log "user/email not found"
|
38
|
-
head 404
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
on post do
|
43
|
-
user = self.class.authenticator.login( *login_and_password )
|
44
|
-
if user
|
45
|
-
current_user( user )
|
46
|
-
# be compliant with rack-protection and rack-csrf
|
47
|
-
csrf = session[ :csrf ] || session[ "csrf.token" ]
|
48
|
-
res[ 'X-CSRF-TOKEN' ] = csrf if csrf
|
49
|
-
write self.class.sessions.create( user )
|
50
|
-
else
|
51
|
-
log "access denied"
|
52
|
-
head 403
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
on get, :ping do
|
57
|
-
head 200
|
58
|
-
end
|
59
|
-
|
60
|
-
on delete do
|
61
|
-
log "logout"
|
62
|
-
reset_current_user
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|