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.
Files changed (37) hide show
  1. metadata +2 -38
  2. data/lib/ixtlan/passwords.rb +0 -72
  3. data/lib/ixtlan/passwords.rb~ +0 -47
  4. data/lib/ixtlan/railtie.rb~ +0 -17
  5. data/lib/ixtlan/user_management/application_model.rb +0 -30
  6. data/lib/ixtlan/user_management/application_model.rb~ +0 -21
  7. data/lib/ixtlan/user_management/application_resource.rb +0 -48
  8. data/lib/ixtlan/user_management/application_resource.rb~ +0 -21
  9. data/lib/ixtlan/user_management/authentcator.rb~ +0 -31
  10. data/lib/ixtlan/user_management/authentication_model.rb +0 -31
  11. data/lib/ixtlan/user_management/authentication_model.rb~ +0 -21
  12. data/lib/ixtlan/user_management/authenticator.rb +0 -55
  13. data/lib/ixtlan/user_management/authenticator.rb~ +0 -20
  14. data/lib/ixtlan/user_management/domain_resource.rb +0 -78
  15. data/lib/ixtlan/user_management/domain_resource.rb~ +0 -21
  16. data/lib/ixtlan/user_management/dummy_authentication.rb +0 -70
  17. data/lib/ixtlan/user_management/dummy_authentication.rb~ +0 -49
  18. data/lib/ixtlan/user_management/group.rb~ +0 -39
  19. data/lib/ixtlan/user_management/group_model.rb +0 -31
  20. data/lib/ixtlan/user_management/group_model.rb~ +0 -21
  21. data/lib/ixtlan/user_management/models.rb~ +0 -39
  22. data/lib/ixtlan/user_management/session-serializer.rb~ +0 -18
  23. data/lib/ixtlan/user_management/session_cuba.rb +0 -67
  24. data/lib/ixtlan/user_management/session_cuba.rb~ +0 -44
  25. data/lib/ixtlan/user_management/session_manager.rb +0 -71
  26. data/lib/ixtlan/user_management/session_model.rb +0 -36
  27. data/lib/ixtlan/user_management/session_model.rb~ +0 -10
  28. data/lib/ixtlan/user_management/session_plugin.rb +0 -52
  29. data/lib/ixtlan/user_management/session_serializer.rb +0 -41
  30. data/lib/ixtlan/user_management/session_serializer.rb~ +0 -21
  31. data/lib/ixtlan/user_management/user.rb~ +0 -16
  32. data/lib/ixtlan/user_management/user_model.rb +0 -36
  33. data/lib/ixtlan/user_management/user_model.rb~ +0 -33
  34. data/lib/ixtlan/user_management/user_resource.rb +0 -55
  35. data/lib/ixtlan/user_management/user_resource.rb~ +0 -24
  36. data/lib/ixtlan/user_management/user_serializer.rb +0 -35
  37. data/lib/ixtlan/user_management/user_serializer.rb~ +0 -23
@@ -1,44 +0,0 @@
1
- # -*- Coding: utf-8 -*-
2
- require 'session_plugin'
3
-
4
- module Ixtlan
5
- module UserManagement
6
-
7
- class SessionCuba < CubaAPI
8
-
9
- plugin SessionPlugin
10
-
11
- define do
12
- on post, :reset_password do
13
- if msg = self.class.authenticator.reset_password( login_and_password[ 0 ] )
14
- log msg
15
- head 200
16
- else
17
- log "user/email not found"
18
- head 404
19
- end
20
- end
21
-
22
- on post do
23
- user = self.class.authenticator.login( *login_and_password )
24
- if user
25
- current_user( user )
26
- write self.class.sessions.create( user )
27
- else
28
- log "access denied"
29
- head 403
30
- end
31
- end
32
-
33
- on get, :ping do
34
- head 200
35
- end
36
-
37
- on delete do
38
- log "logout"
39
- reset_current_user
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,71 +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/user_serializer'
23
- require 'ixtlan/user_management/session_model'
24
- require 'ixtlan/user_management/session_serializer'
25
-
26
- module Ixtlan
27
- module UserManagement
28
- class SessionManager
29
-
30
- attr_accessor :idle_session_timeout, :block
31
-
32
- def initialize( &block )
33
- @block = block || lambda { [] }
34
- end
35
-
36
- def serializer( user )
37
- UserSerializer.new( user )
38
- end
39
-
40
- def to_session( user )
41
- serializer( user ).use( :session ).to_hash
42
- end
43
-
44
- if User.respond_to?( :properties )
45
- def from_session( data )
46
- if data
47
- data = data.dup
48
- groups = (data.delete( 'groups' ) || []).collect do |g|
49
- Group.new( g )
50
- end
51
- user = User.first( :login => data[ 'login' ] )
52
- user.groups = groups
53
- user
54
- end
55
- end
56
- else
57
- def from_session( data )
58
- if data
59
- User.new( data )
60
- end
61
- end
62
- end
63
-
64
- def create( user )
65
- Session.new( 'user' => user,
66
- 'permissions' => block.call( user.groups ),
67
- 'idle_session_timeout' => idle_session_timeout )
68
- end
69
- end
70
- end
71
- end
@@ -1,36 +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 Session
25
- include Virtus
26
-
27
- attribute :idle_session_timeout, Integer
28
- attribute :user, User
29
- attribute :permissions, Array[Object]
30
-
31
- def to_s
32
- "Session( #{user.name}<#{user.login}> groups[ #{user.groups.collect { |g| g.name }.join ',' } ] #{idle_session_timeout} )"
33
- end
34
- end
35
- end
36
- end
@@ -1,10 +0,0 @@
1
- module Ixtlan
2
- module UserManagement
3
- class Session
4
- include Virtus
5
-
6
- attribute :name, String
7
- attribute :url, String
8
- end
9
- end
10
- end
@@ -1,52 +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/authenticator'
23
-
24
- module Ixtlan
25
- module UserManagement
26
- module SessionPlugin
27
-
28
- module ClassMethods
29
- def authenticator
30
- self[ :authenticator ] ||= Authenticator.new( self[ :rest ] )
31
- end
32
- end
33
-
34
- def log( msg )
35
- if self.respond_to? :audit
36
- audit( msg, { :username => login } )
37
- else
38
- warn( "[#{login}] #{msg}" )
39
- end
40
- end
41
-
42
- def login_and_password
43
- auth = req[:authentication] || req
44
- [ auth[:login] || auth[:email], auth[:password] ]
45
- end
46
-
47
- def login
48
- login_and_password[ 0 ]
49
- end
50
- end
51
- end
52
- end
@@ -1,41 +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
- require 'ixtlan/babel/serializer'
22
- module Ixtlan
23
- module UserManagement
24
- class SessionSerializer < Ixtlan::Babel::Serializer
25
-
26
- root 'session'
27
-
28
- add_context(:single,
29
- :only => [:idle_session_timeout],
30
- :include => {
31
- :user => {
32
- },
33
- :permissions => {
34
- :include => [:actions, :associations]
35
- }
36
- }
37
- )
38
-
39
- end
40
- end
41
- end
@@ -1,21 +0,0 @@
1
- require 'ixtlan/babel/serializer'
2
- module Ixtlan
3
- module UserManagement
4
- class SessionSerializer < Ixtlan::Babel::Serializer
5
-
6
- root 'session'
7
-
8
- add_context(:single,
9
- :only => [:permissions, :idle_session_timeout],
10
- :include=> {
11
- :user => {
12
- },
13
- :permissions => {
14
- :include => [:actions, :associations]
15
- }
16
- }
17
- )
18
-
19
- end
20
- end
21
- end
@@ -1,16 +0,0 @@
1
- class User
2
-
3
- include DataMapper::Resource
4
-
5
- property :id, Serial, :auto_validation => false
6
-
7
- property :login, String, :required => true, :unique => true, :length => 32
8
- property :name, String, :required => true, :length => 128
9
- property :updated_at, DateTime, :required => true
10
-
11
- attr_accessor :groups, :applications
12
-
13
- # do not record timestamps since they are set from outside
14
- def set_timestamps_on_save
15
- end
16
- end
@@ -1,36 +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 'ixtlan/user_management/group_model'
22
- module Ixtlan
23
- module UserManagement
24
- class User
25
- include Virtus
26
-
27
- attribute :login, String
28
- attribute :name, String
29
- attribute :groups, Array[Group]
30
-
31
- def initialize( params = {} )
32
- super params[ 'user' ] || params
33
- end
34
- end
35
- end
36
- end
@@ -1,33 +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 'ixtlan/user_management/group_model'
22
- module Ixtlan
23
- module UserManagement
24
- class User
25
- include Virtus
26
-
27
- attribute :login, String
28
- attribute :name, String
29
- attribute :groups, Array[Group]
30
-
31
- end
32
- end
33
- end
@@ -1,55 +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 User
24
-
25
- include DataMapper::Resource
26
-
27
- def self.storage_name(arg)
28
- 'ixtlan_users'
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, :auto_validation => false
39
-
40
- property :login, String, :required => true, :unique => true, :length => 32
41
- property :name, String, :required => true, :length => 128
42
- property :updated_at, DateTime, :required => true
43
-
44
- attr_accessor :groups, :applications
45
-
46
- # do not record timestamps since they are set from outside
47
- def set_timestamps_on_save
48
- end
49
-
50
- def to_s
51
- "User( #{name} <#{login}> )"
52
- end
53
- end
54
- end
55
- end
@@ -1,24 +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, :domains, :locales
18
-
19
- # do not record timestamps since they are set from outside
20
- def set_timestamps_on_save
21
- end
22
- end
23
- end
24
- end