rack-auth-simples 0.0.1

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.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rack-auth-ip.gemspec
4
+ gemspec
@@ -0,0 +1,61 @@
1
+ require 'ipaddr'
2
+ require 'ipaddr_list'
3
+ module Rack
4
+ module Auth
5
+
6
+ class Simples
7
+
8
+ class Rules
9
+
10
+ def initialize
11
+ @ips = []
12
+ @triggers = []
13
+ end
14
+
15
+ def add_ip ip
16
+ @ips << ip
17
+ end
18
+
19
+ def allow_local
20
+ @ips << '127.0.0.1'
21
+ end
22
+
23
+ def add_trigger_url url
24
+ @triggers << url
25
+ end
26
+
27
+ def parse_rules env
28
+
29
+ if env['HTTP_X_FORWARDED_FOR']
30
+ ip = env['HTTP_X_FORWARDED_FOR'].split(',').pop
31
+ else
32
+ ip = env["REMOTE_ADDR"]
33
+ end
34
+
35
+
36
+ if @ips.any?
37
+ addrs_list = IPAddrList.new(@ips)
38
+ return false unless addrs_list.include? ip
39
+ end
40
+
41
+ if @triggers.any?
42
+
43
+ # check cookie, return true if present
44
+
45
+ # check trigger url, if match set cookie and return true
46
+
47
+ # return false
48
+
49
+ end
50
+
51
+ # default to true
52
+ return true
53
+
54
+ end
55
+
56
+
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,25 @@
1
+ require 'rack/auth/simples/rules'
2
+ module Rack
3
+ module Auth
4
+ class Simples
5
+
6
+ def initialize app, &block
7
+ @rules = Rules.new
8
+
9
+ block.call(@rules)
10
+
11
+ @app = app
12
+ end
13
+
14
+ def call env
15
+
16
+ if @rules.parse_rules
17
+ @app.call env
18
+ else
19
+ return [403, {'Content-Type' => 'text/plain' }, ['Forbidden'] ]
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,7 @@
1
+ module Rack
2
+ module Auth
3
+ module Simples
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/rack-auth-simples/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Roberts, Marc"]
6
+ gem.email = ["marc@neutroncreations.com"]
7
+ gem.description = %q{rack middleware for multiple simple auth}
8
+ gem.summary = %q{rack middleware for multiple simple auth}
9
+ gem.homepage = "http://github.com/neutroncreations/rack-auth-simples"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/.*_spec.rb})
14
+ gem.name = "rack-auth-simples"
15
+ gem.require_paths = ["lib"]
16
+ gem.add_dependency('ipaddr_list', '>= 0.0.2')
17
+ gem.version = Rack::Auth::Simples::VERSION
18
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-auth-simples
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Roberts, Marc
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ipaddr_list
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.2
30
+ description: rack middleware for multiple simple auth
31
+ email:
32
+ - marc@neutroncreations.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - Gemfile
38
+ - lib/rack-auth-simples/version.rb
39
+ - lib/rack/auth/simples.rb
40
+ - lib/rack/auth/simples/rules.rb
41
+ - rack-auth-simples.gemspec
42
+ homepage: http://github.com/neutroncreations/rack-auth-simples
43
+ licenses: []
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 1.8.23
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: rack middleware for multiple simple auth
66
+ test_files: []