grape_session 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8aa3622c45f6e4d00d07b087463cb1f7aebeebd5
4
- data.tar.gz: 921d5c6600ca7b2e94b8b09fac15bda648dd2e54
3
+ metadata.gz: 7e7d06bb6b8284a27df8bfb896abe49a456f64f2
4
+ data.tar.gz: f27a92fcce4b9c191133a033da00186d08d32b50
5
5
  SHA512:
6
- metadata.gz: f1a01a0ff99ae715987831c523403436f194fd4e0a37e102a9d742000b458e3fc8d6efe2c96048c2ce5471ca7f7e9d1deb81e8687550d97cee4ae34f966231d5
7
- data.tar.gz: dd14f93559867f81c70209fb61123d9132926cc85d1967dffd7a204d298fc58c13846b07281fe11e10b97a353ffe6937667bbef8798a86181959c7478c0006c0
6
+ metadata.gz: 1b3ec0ef90c5cf13f77a262b87904b9857b4587add4dd5a59626e7ebb9b87b7252c34b4787ce88a4aeb0acd41ee2875aa2fb39b00e98a1f8be0c8d439e2bd701
7
+ data.tar.gz: c04593f25a502070d6773cd3f5f4ad183c276b20fb0967662e58215583be24ad8eb328c575a4054a84c8b8269fc01c9728b22a5c9caa0e5b7f93ff4044200d8f
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # GrapeSession
1
+ # GrapeSession (Project-State: Proposal)
2
2
 
3
3
  Make Rails session and cookie handling available for grape. `cookies` method
4
4
  will return an `ActionDispatch::Cookies::CookieJar` instead of `Grape::Cookie`.
@@ -40,6 +40,19 @@ class API < Grape::API
40
40
  secret_token: 'secret_token',
41
41
  secret_key_base: 'secret base',
42
42
  cookies_serializer: :json
43
+
44
+ session_options: {
45
+ # Rails specific ActionDispatch::Compatibility
46
+ key: '_grape_session_id'
47
+ # Rack::Session::Abstract::ID specific
48
+ domain: 'foo.com',
49
+ path: '/',
50
+ expire_after: 2592000,
51
+ secure: false,
52
+ httponly: true,
53
+ defer: false,
54
+ renew: false,
55
+ }
43
56
  }
44
57
 
45
58
 
@@ -10,7 +10,7 @@ module GrapeSession
10
10
 
11
11
  use GrapeSession::Middleware::EnvSetup
12
12
  use ActionDispatch::Cookies
13
- use ActionDispatch::Session::CookieStore
13
+ use ActionDispatch::Session::CookieStore, GrapeSession::Middleware::EnvSetup.settings[:session_options]
14
14
 
15
15
  end
16
16
 
@@ -12,9 +12,6 @@ module GrapeSession
12
12
  def read(*)
13
13
  end
14
14
 
15
- def write(*)
16
- end
17
-
18
15
  module ClassMethods
19
16
  end
20
17
  end
@@ -8,14 +8,19 @@ module GrapeSession
8
8
  encrypted_signed_cookie_salt: 'signed encrypted cookie',
9
9
  secret_token: 'secret_token',
10
10
  secret_key_base: 'secret base',
11
- cookies_serializer: :json
11
+ cookies_serializer: :json,
12
+ session_options: { key: '_grape_session_id' }
12
13
  }.freeze
13
14
  end
14
15
 
15
- def self.settings(new_settings)
16
- @settings_for_env = nil
17
- @caching_key_generator = nil
18
- @settings = default_settings.merge new_settings
16
+ def self.settings(new_settings = nil)
17
+ if new_settings
18
+ @settings_for_env = nil
19
+ @caching_key_generator = nil
20
+ @settings = default_settings.merge new_settings
21
+ else
22
+ @settings ||= default_settings
23
+ end
19
24
  end
20
25
 
21
26
  def self.key_generator
@@ -26,16 +31,14 @@ module GrapeSession
26
31
  end
27
32
 
28
33
  def self.settings_for_env
29
- @settings ||= default_settings
30
-
31
34
  @settings_for_env ||= {
32
35
  ActionDispatch::Cookies::GENERATOR_KEY => key_generator,
33
- ActionDispatch::Cookies::SIGNED_COOKIE_SALT => @settings[:signed_cookie_salt],
34
- ActionDispatch::Cookies::ENCRYPTED_COOKIE_SALT => @settings[:encrypted_cookie_salt],
35
- ActionDispatch::Cookies::ENCRYPTED_SIGNED_COOKIE_SALT => @settings[:encrypted_signed_cookie_salt],
36
- ActionDispatch::Cookies::SECRET_TOKEN => @settings[:secret_token],
37
- ActionDispatch::Cookies::SECRET_KEY_BASE => @settings[:secret_key_base],
38
- ActionDispatch::Cookies::COOKIES_SERIALIZER => @settings[:cookies_serializer]
36
+ ActionDispatch::Cookies::SIGNED_COOKIE_SALT => settings[:signed_cookie_salt],
37
+ ActionDispatch::Cookies::ENCRYPTED_COOKIE_SALT => settings[:encrypted_cookie_salt],
38
+ ActionDispatch::Cookies::ENCRYPTED_SIGNED_COOKIE_SALT => settings[:encrypted_signed_cookie_salt],
39
+ ActionDispatch::Cookies::SECRET_TOKEN => settings[:secret_token],
40
+ ActionDispatch::Cookies::SECRET_KEY_BASE => settings[:secret_key_base],
41
+ ActionDispatch::Cookies::COOKIES_SERIALIZER => settings[:cookies_serializer]
39
42
  }.freeze
40
43
  end
41
44
 
@@ -1,3 +1,3 @@
1
1
  module GrapeSession
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
data/lib/grape_session.rb CHANGED
@@ -18,4 +18,6 @@ Grape::Endpoint.send(:include, GrapeSession::Ext::Endpoint)
18
18
  Grape::Request.send(:include, GrapeSession::Ext::Request)
19
19
  # Grape::API.send(:include, GrapeSession::Ext::API)
20
20
 
21
- ActionDispatch::Cookies::CookieJar.send(:include, GrapeSession::Ext::CookieJar)
21
+ unless ActionDispatch::Cookies::CookieJar.instance_methods.include? :read
22
+ ActionDispatch::Cookies::CookieJar.send(:include, GrapeSession::Ext::CookieJar)
23
+ end
@@ -44,7 +44,7 @@ feature 'Use an encrypted session' do
44
44
 
45
45
  expect(last_response.status).to eq 200
46
46
 
47
- expect(decryptor.decrypt_and_verify response_cookies['_session_id']).to include('session_test' => 'session_test_value')
47
+ expect(decryptor.decrypt_and_verify response_cookies['_grape_session_id']).to include('session_test' => 'session_test_value')
48
48
  end
49
49
 
50
50
  scenario 'Get session' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape_session
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dieter Späth