jj-middleware 0.1.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: b41b197664e0fd6b79b8ff386ab11cf947ee358e
4
+ data.tar.gz: 05591a4106897935b6e1d008ccc149cec7c1ba5d
5
+ SHA512:
6
+ metadata.gz: 2549bc8ba1cfea0f9e45ca7f54aa90b4a461cc8627c49ebd7ad201c263af46579d194d48048e4f1eefe62bd0fda0fb8fd51d6b9fb15d50623e27e5e9487f1e27
7
+ data.tar.gz: db971e99686c62ef3bc93ac1c52fb437110b1642a32f69d3f791798e1b03c7df30c4c5c6e01d70812fd02e4ac62aac96a786b019e9665692621c3fa8b9719af2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "jj/middleware"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jj-middleware"
8
+ spec.version = JJ::Middleware::VERSION
9
+ spec.authors = [""]
10
+ spec.email = [""]
11
+
12
+ spec.summary = ""
13
+ spec.homepage = ""
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{\A(jj-middleware.gemspec|lib|Gemfile)}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.9"
21
+ spec.add_development_dependency "pry"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+
25
+ spec.add_dependency "json"
26
+ end
@@ -0,0 +1,5 @@
1
+ module JJ
2
+ module Middleware
3
+ VERSION = "0.1.0".freeze
4
+ end
5
+ end
@@ -0,0 +1,26 @@
1
+ require "jj/middleware/base"
2
+
3
+ module JJ
4
+ module Middleware
5
+ class Auth < Base
6
+ def initialize(app)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ logged_in?(env) ? @app.call(env) : redirect
12
+ end
13
+
14
+ private
15
+
16
+ def logged_in?(env)
17
+ s = session(env)
18
+ s && s["user"] && s["user"].email && s["user"].data_api
19
+ end
20
+
21
+ def redirect
22
+ [302, { "Location" => "/login", "Content-Type" => "text/html" }, []]
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ module JJ
2
+ module Middleware
3
+ class Base
4
+ protected
5
+
6
+ def session(env)
7
+ env["rack.session"].to_hash
8
+ end
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jj-middleware
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ''
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-17 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.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - ''
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - Gemfile
91
+ - jj-middleware.gemspec
92
+ - lib/jj/middleware.rb
93
+ - lib/jj/middleware/auth.rb
94
+ - lib/jj/middleware/base.rb
95
+ homepage: ''
96
+ licenses: []
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.5.1
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: ''
118
+ test_files: []