sbsm 1.3.7 → 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7840c4f9bb73d0d6bb915470360a8d5578300a4
4
- data.tar.gz: 6d6ab86eda66166938e161de90bccb105b89d5a3
3
+ metadata.gz: c6cb626e4851ec836b764fb7b362d781d0e63f3e
4
+ data.tar.gz: e74535cdcc374099fdc168db3f5e7c6ea2343d12
5
5
  SHA512:
6
- metadata.gz: 47247200512e2e9f5e185f2492328ae7f507d6aa37e98ed3d6eddf0bdb267a4bccb33b928a7b423d649def74e2e99d4dfcae430118e01fb47f2b5230631d7437
7
- data.tar.gz: 203bacf669d76975b2b5d08e4e00b8a252113e1271f90238076b83d300187f620a40d56482c94d4359c3e365c6c5d6b41fe52fa57397eb363afc6d85fb50b503
6
+ metadata.gz: 3a00b7d42d498ad395945d082f4a2136bc077989bfeca6c3558f07c5a9679721f4072ce3abffcff42be4b67413359776b26d401d671313f6d5043cbbccfcf7dc
7
+ data.tar.gz: a96428befce20e6d19e367345886205036eed9e0af0f241842c7f7f991bf10beb2c4e5d88d8bd768f500af6bb31e5c5812528234d39f162501ef8bbb540e3cef
@@ -1,3 +1,7 @@
1
+ === 1.3.8 / 15.05.2017
2
+
3
+ * Reverted some changes to make bbmb and virbac run
4
+
1
5
  === 1.3.7 / 10.05.2017
2
6
  * Some changes for VIRBAC which uses viral modules and a KnownUser class
3
7
  ** Add @server_name to rack session
@@ -33,18 +33,16 @@ require 'mimemagic'
33
33
 
34
34
  module SBSM
35
35
  ###
36
-
36
+ # App as a member of session
37
37
  class App
38
38
 
39
39
  def initialize()
40
- SBSM.info "initialize #{self.class}"
40
+ SBSM.info "initialize"
41
41
  end
42
-
43
42
  end
44
43
 
45
44
  class RackInterface
46
45
  attr_accessor :session # thread variable!
47
- attr_reader :app, :session_store
48
46
  SESSION_ID = '_session_id'
49
47
 
50
48
  # Base class for a SBSM based WebRick HTTP server
@@ -53,10 +51,11 @@ module SBSM
53
51
  #
54
52
  # === optional arguments
55
53
  #
56
- # * +app+ - the App for the Rack-Interface
54
+ # * +app+ - A Ruby class used by the session
57
55
  # * +validator+ - A Ruby class overriding the SBSM::Validator class
58
56
  # * +trans_handler+ - A Ruby class overriding the SBSM::TransHandler class
59
57
  # * +session_class+ - A Ruby class overriding the SBSM::Session class
58
+ # * +unknown_user+ - A Ruby class overriding the SBSM::UnknownUser class
60
59
  # * +persistence_layer+ - Persistence Layer to use
61
60
  # * +cookie_name+ - The cookie to save persistent user data
62
61
  # * +multi_threaded+ - Allow multi_threaded SBSM (default is false)
@@ -65,7 +64,7 @@ module SBSM
65
64
  # Look at steinwies.ch
66
65
  # * https://github.com/zdavatz/steinwies.ch (simple, mostly static files, one form, no persistence layer)
67
66
  #
68
- def initialize(app: ,
67
+ def initialize(app:,
69
68
  validator: nil,
70
69
  trans_handler: nil,
71
70
  session_class: nil,
@@ -76,12 +75,13 @@ module SBSM
76
75
  )
77
76
  @@last_session = nil
78
77
  @app = app
79
- SBSM.info "initialize validator #{validator} th #{trans_handler} cookie #{cookie_name} session #{session_class} app #{app.class} multi_threaded #{multi_threaded}"
78
+ SBSM.info "initialize validator #{validator} th #{trans_handler} cookie #{cookie_name} session #{session_class} app #{app} multi_threaded #{multi_threaded}"
80
79
  @session_store = SessionStore.new(app: app,
81
80
  persistence_layer: persistence_layer,
82
81
  trans_handler: trans_handler,
83
82
  session_class: session_class,
84
83
  cookie_name: cookie_name,
84
+ unknown_user: unknown_user,
85
85
  validator: validator,
86
86
  multi_threaded: multi_threaded)
87
87
  end
@@ -129,6 +129,7 @@ module SBSM
129
129
  end
130
130
  response.set_cookie(SESSION_ID, { :value => session_id, :path => '/' }) unless request.cookies[SESSION_ID]
131
131
 
132
+ # response.set_cookie(SBSM::Session.get_cookie_name, session_id)
132
133
  @@last_session = session
133
134
  if response.headers['Set-Cookie'].to_s.index(session_id)
134
135
  SBSM.debug "finish session_id.1 #{session_id}: matches response.headers['Set-Cookie']"
@@ -36,12 +36,10 @@ module SBSM
36
36
  # by the different process. Should probably later be replaced by a Rack based logger
37
37
  def self.info(msg)
38
38
  info = "#{File.basename(caller[0])} #{msg}"
39
- puts info if defined? Pry
40
39
  @@logger.info(info) if @@logger
41
40
  end
42
41
  def self.debug(msg)
43
42
  info = "#{File.basename(caller[0])} #{msg}"
44
- puts info if defined? Pry
45
43
  @@logger.debug(info) if @@logger
46
44
  end
47
45
  end
@@ -132,7 +132,7 @@ module SBSM
132
132
  @session.navigation
133
133
  end
134
134
  def resource(rname, rstr=nil)
135
- collect_resource([ self::class::RESOURCE_BASE, @session.flavor ],
135
+ collect_resource([ self::class::RESOURCE_BASE, @session.flavor ],
136
136
  rname, rstr)
137
137
  end
138
138
  def resource_external(rname)
@@ -166,8 +166,8 @@ module SBSM
166
166
  end
167
167
  end
168
168
  def _collect_resource(base, part, rstr)
169
- [ @session.http_protocol + ':/',
170
- @session.server_name,
169
+ [ @session.http_protocol + ':/',
170
+ @session.server_name,
171
171
  base, part, rstr].flatten.compact.join('/')
172
172
  end
173
173
  def set_dictionary(language)
@@ -106,7 +106,8 @@ module SBSM
106
106
  def initialize(app:,
107
107
  trans_handler: nil,
108
108
  validator: nil,
109
- cookie_name: nil,
109
+ unknown_user: nil,
110
+ cookie_name: nil,
110
111
  multi_threaded: false)
111
112
  SBSM.info "initialize th #{trans_handler} validator #{validator} app #{app.class}"
112
113
  @app = app
@@ -60,7 +60,6 @@ module SBSM
60
60
  multi_threaded: nil)
61
61
  fail "You must specify an app!" unless app
62
62
  @sessions = {}
63
- @admin_enabled = false
64
63
  @mutex = Mutex.new
65
64
  @cleaner = run_cleaner if(self.class.const_get(:RUN_CLEANER))
66
65
  @admin_threads = ThreadGroup.new
@@ -77,11 +76,8 @@ module SBSM
77
76
  @unknown_user ||= UNKNOWN_USER
78
77
  @validator = validator
79
78
  end
80
- def enable_admin
81
- @admin_enabled = true
82
- end
83
79
  def _admin(src, result, priority=0)
84
- raise "admin interface disabled" unless @admin_enabled
80
+ raise "admin interface disabled" unless(self::class::ENABLE_ADMIN)
85
81
  t = Thread.new {
86
82
  Thread.current.abort_on_exception = false
87
83
  result << begin
@@ -173,12 +169,12 @@ module SBSM
173
169
  end
174
170
  def [](key)
175
171
  @mutex.synchronize do
176
- unless((session = @sessions[key]) && !session.expired?)
177
- session = @sessions[key] = @session_class.new(app: @app, cookie_name: @cookie_name, trans_handler: @trans_handler, validator: @validator)
172
+ unless((s = @sessions[key]) && !s.expired?)
173
+ s = @sessions[key] = @session_class.new(app: @app, cookie_name: @cookie_name, trans_handler: @trans_handler, validator: @validator, unknown_user: @unknown_user)
178
174
  end
179
- session.reset()
180
- session.touch()
181
- session
175
+ s.reset()
176
+ s.touch()
177
+ s
182
178
  end
183
179
  end
184
180
  end
@@ -1,3 +1,3 @@
1
1
  module SBSM
2
- VERSION = '1.3.7'
2
+ VERSION = '1.3.8'
3
3
  end
@@ -144,11 +144,9 @@ end
144
144
  class TestSession < Minitest::Test
145
145
  include Rack::Test::Methods
146
146
  def setup
147
- @app = StubSessionApp.new(validator: StubSessionValidator.new,
148
- unknown_user: StubSessionUnknownUser.new)
147
+ @app = StubSessionApp.new(validator: StubSessionValidator.new)
149
148
  @session = StubSessionWithView.new(app: @app,
150
- validator: StubSessionValidator.new,
151
- unknown_user: StubSessionUnknownUser.new)
149
+ validator: StubSessionValidator.new)
152
150
  @request = StubSessionRequest.new
153
151
  @state = StubSessionState.new(@session, nil)
154
152
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 1.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-10 00:00:00.000000000 Z
11
+ date: 2017-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -270,7 +270,6 @@ files:
270
270
  - data/zone_uri.grammar
271
271
  - install.rb
272
272
  - lib/sbsm.rb
273
- - lib/sbsm/admin_server.rb
274
273
  - lib/sbsm/app.rb
275
274
  - lib/sbsm/cgi.rb
276
275
  - lib/sbsm/exception.rb
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
- #--
4
- #
5
- # State Based Session Management
6
- # Copyright (C) 2004 Hannes Wyss
7
- #
8
- # This library is free software; you can redistribute it and/or
9
- # modify it under the terms of the GNU Lesser General Public
10
- # License as published by the Free Software Foundation; either
11
- # version 2.1 of the License, or (at your option) any later version.
12
- #
13
- # This library 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 GNU
16
- # Lesser General Public License for more details.
17
- #
18
- # You should have received a copy of the GNU Lesser General Public
19
- # License along with this library; if not, write to the Free Software
20
- # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
- #
22
- # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zürich, Switzerland
23
- # hwyss@ywesee.com
24
- #
25
- #++
26
- # AdminServer -- sbsm -- niger@ywesee.com
27
- # 2017: Moved the old _admin interface into a separate class for BBMB and Virbac
28
-
29
- require 'delegate'
30
- require 'sbsm/session'
31
- require 'sbsm/user'
32
- require 'thread'
33
- require 'digest/md5'
34
- require 'sbsm/logger'
35
- require 'sbsm/session_store'
36
-
37
- module SBSM
38
- # AdminClass must be tied to an Rack app
39
- class AdminServer
40
- def initialize(app:)
41
- @session = SBSM::SessionStore.new(app: app)
42
- @admin_threads = ThreadGroup.new
43
- end
44
- def _admin(src, result, priority=0)
45
- t = Thread.new {
46
- Thread.current.abort_on_exception = false
47
- result << begin
48
- response = begin
49
- instance_eval(src)
50
- rescue NameError => e
51
- e
52
- end
53
- str = response.to_s
54
- if(str.length > 200)
55
- response.class
56
- else
57
- str
58
- end
59
- rescue StandardError => e
60
- e.message
61
- end.to_s
62
- }
63
- t[:source] = src
64
- t.priority = priority
65
- @admin_threads.add(t)
66
- t
67
- end
68
- end
69
- end