grape_session 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/lib/grape_session/ext/api.rb +1 -1
- data/lib/grape_session/ext/cookie_jar.rb +0 -3
- data/lib/grape_session/middleware/env_setup.rb +16 -13
- data/lib/grape_session/version.rb +1 -1
- data/lib/grape_session.rb +3 -1
- data/spec/acceptance/session_spec.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e7d06bb6b8284a27df8bfb896abe49a456f64f2
|
4
|
+
data.tar.gz: f27a92fcce4b9c191133a033da00186d08d32b50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
@@ -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
|
-
|
17
|
-
|
18
|
-
|
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 =>
|
34
|
-
ActionDispatch::Cookies::ENCRYPTED_COOKIE_SALT =>
|
35
|
-
ActionDispatch::Cookies::ENCRYPTED_SIGNED_COOKIE_SALT =>
|
36
|
-
ActionDispatch::Cookies::SECRET_TOKEN =>
|
37
|
-
ActionDispatch::Cookies::SECRET_KEY_BASE =>
|
38
|
-
ActionDispatch::Cookies::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
|
|
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.
|
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['
|
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
|