omniauth-redis-store 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c1b6cd0fa7f800902d633452c60434c67de77b67
4
+ data.tar.gz: 0478e6fe50fb9d2a057d28dab1ea02095e036ba3
5
+ SHA512:
6
+ metadata.gz: 6c931e62038239cc9dc9715564963ef7a67350d680d97cf08f2d0b87a2f74b3c994737c9014508ed88b74c30523513e2bba72c5ef62722ddf8188306aef29f4b
7
+ data.tar.gz: b49884353a864c550617c4fb70670d81db0dba3ace9ebbfd915ab472483dc624442bf9373f9183e752a6b0e707a116a2ac6704349e9aa58c808b935752014362
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.gem
2
+ *~
3
+ .bundle
4
+ .rvmrc
5
+ .yardoc
6
+ Gemfile.lock
7
+ coverage/*
8
+ doc/*
9
+ log/*
10
+ measurement/*
11
+ pkg/*
@@ -0,0 +1,3 @@
1
+ module OmniAuth
2
+ autoload :RedisStore, 'omniauth/redis_store'
3
+ end
@@ -0,0 +1,4 @@
1
+ module OmniAuthRedisStore
2
+ VERSION = '1.0.0'
3
+ OMNIAUTH_COMPAT = '1.2.1'
4
+ end
@@ -0,0 +1,53 @@
1
+ module OmniAuth
2
+ class Configuration
3
+ attr_accessor :redis
4
+ end
5
+
6
+ class RedisStore
7
+ require 'securerandom'
8
+ require 'json'
9
+
10
+ OMNIAUTH_REDIS_KEY= 'omniauth.redis_store'
11
+ REDIS_EXPIRE_TIME= 60 #seconds
12
+
13
+ attr_reader :env
14
+
15
+ def initialize(env)
16
+ @env = env
17
+ end
18
+
19
+ def []= (key,value)
20
+ redis.hset(session_id, key, value.to_json)
21
+ redis.expire(session_id, REDIS_EXPIRE_TIME)
22
+ end
23
+
24
+ def [] (key)
25
+ JSON.parse(redis.hget(session_id,key))
26
+ rescue TypeError
27
+ {}
28
+ end
29
+
30
+ def delete (key)
31
+ val = [key]
32
+ redis.hdel(session_id, key)
33
+ session.delete(OMNIAUTH_REDIS_KEY) unless redis.exists(session_id)
34
+ val
35
+ end
36
+
37
+ protected
38
+
39
+ def redis
40
+ OmniAuth.config.redis
41
+ end
42
+
43
+ def session
44
+ @env['rack.session']
45
+ end
46
+
47
+ def session_id
48
+ session[OMNIAUTH_REDIS_KEY] = SecureRandom.uuid if session[OMNIAUTH_REDIS_KEY].nil?
49
+ session[OMNIAUTH_REDIS_KEY]
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-redis-store/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.add_development_dependency 'bundler', '~> 1.0'
8
+ spec.authors = ['Paul Scarrone']
9
+ spec.description = %Q(An adapter for using Redis like a session keystore during requests compatible with #{OmniAuthRedisStore::OMNIAUTH_COMPAT})
10
+ spec.email = ['paul.scarrone@gmail.com']
11
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
12
+ spec.homepage = 'http://github.com/ninjapanzer/omniauth-redis-store'
13
+ spec.licenses = %w(MIT)
14
+ spec.name = 'omniauth-redis-store'
15
+ spec.require_paths = %w(lib)
16
+ spec.required_rubygems_version = '>= 1.3.5'
17
+ spec.summary = spec.description
18
+ spec.version = OmniAuthRedisStore::VERSION
19
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-redis-store
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Paul Scarrone
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: An adapter for using Redis like a session keystore during requests compatible
28
+ with 1.2.1
29
+ email:
30
+ - paul.scarrone@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - .gitignore
36
+ - lib/omniauth-redis-store.rb
37
+ - lib/omniauth-redis-store/version.rb
38
+ - lib/omniauth/redis_store.rb
39
+ - omniauth-redis-store.gemspec
40
+ homepage: http://github.com/ninjapanzer/omniauth-redis-store
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: 1.3.5
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.2.2
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: An adapter for using Redis like a session keystore during requests compatible
64
+ with 1.2.1
65
+ test_files: []