rack-pubcookie 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,5 @@
1
- require 'active_support/core_ext/object/to_query'
1
+ require 'rack/utils'
2
2
  require 'openssl'
3
- require 'openssl/evp'
4
3
  require 'base64'
5
4
 
6
5
  module Rack
@@ -57,7 +56,7 @@ module Rack
57
56
  index2 = bytes.pop
58
57
  index1 = bytes.pop
59
58
 
60
- if true # Should eventually check for aes vs des encryption...
59
+ if true # TODO: should check for aes vs des encryption...
61
60
  decrypted = des_decrypt bytes, index1, index2
62
61
  else
63
62
  decrypted = aes_decrypt bytes, index1, index2
@@ -107,7 +106,10 @@ module Rack
107
106
  end
108
107
 
109
108
  def login_page_html
110
- input_val = Base64.encode64 request_login_arguments.to_query
109
+ query = request_login_arguments.to_a.map{ |k, v|
110
+ "#{k}=#{Rack::Utils.escape v}"
111
+ }.join '&'
112
+ input_val = Base64.encode64 query
111
113
  input_val = input_val.gsub("\n", '')
112
114
 
113
115
  # Curious why exactly this template? This was taken from the pubcookie
@@ -19,7 +19,7 @@ module Rack
19
19
  signature = c.update(bytes[0..127].pack('c*'))
20
20
  decrypted = c.update(bytes[128..-1].pack('c*'))
21
21
 
22
- if OpenSSL::EVP.verify_md5(@granting, signature, decrypted)
22
+ if @granting.public_key.verify(OpenSSL::Digest::MD5.new, signature, decrypted)
23
23
  decrypted
24
24
  else
25
25
  nil
@@ -1,5 +1,11 @@
1
1
  module Rack
2
2
  module Pubcookie
3
+
4
+ # This Rack interface is meant to be used in development. It mocks out
5
+ # pubcookie authentication by always setting the REMOTE_USER variable to
6
+ # a specific username given to the constructor.
7
+ #
8
+ # This is not meant to be used in production obviously...
3
9
  class Fake
4
10
 
5
11
  def initialize app, username
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Pubcookie
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alex Crichton
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-28 00:00:00 -04:00
17
+ date: 2010-12-18 00:00:00 -06:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -31,7 +31,7 @@ dependencies:
31
31
  type: :runtime
32
32
  version_requirements: *id001
33
33
  - !ruby/object:Gem::Dependency
34
- name: activesupport
34
+ name: rspec
35
35
  prerelease: false
36
36
  requirement: &id002 !ruby/object:Gem::Requirement
37
37
  none: false
@@ -41,10 +41,10 @@ dependencies:
41
41
  segments:
42
42
  - 0
43
43
  version: "0"
44
- type: :runtime
44
+ type: :development
45
45
  version_requirements: *id002
46
46
  - !ruby/object:Gem::Dependency
47
- name: rspec
47
+ name: rack-test
48
48
  prerelease: false
49
49
  requirement: &id003 !ruby/object:Gem::Requirement
50
50
  none: false
@@ -57,7 +57,7 @@ dependencies:
57
57
  type: :development
58
58
  version_requirements: *id003
59
59
  - !ruby/object:Gem::Dependency
60
- name: rack-test
60
+ name: nokogiri
61
61
  prerelease: false
62
62
  requirement: &id004 !ruby/object:Gem::Requirement
63
63
  none: false
@@ -69,36 +69,16 @@ dependencies:
69
69
  version: "0"
70
70
  type: :development
71
71
  version_requirements: *id004
72
- - !ruby/object:Gem::Dependency
73
- name: nokogiri
74
- prerelease: false
75
- requirement: &id005 !ruby/object:Gem::Requirement
76
- none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- segments:
81
- - 0
82
- version: "0"
83
- type: :development
84
- version_requirements: *id005
85
72
  description: Pubcookie finally leaves the world of apache!
86
73
  email:
87
74
  - alex@alexcrichton.com
88
75
  executables: []
89
76
 
90
- extensions:
91
- - ext/openssl/extconf.rb
77
+ extensions: []
78
+
92
79
  extra_rdoc_files: []
93
80
 
94
81
  files:
95
- - .gitignore
96
- - Gemfile
97
- - Gemfile.lock
98
- - README.md
99
- - Rakefile
100
- - ext/openssl/evp.c
101
- - ext/openssl/extconf.rb
102
82
  - lib/rack-pubcookie.rb
103
83
  - lib/rack/pubcookie.rb
104
84
  - lib/rack/pubcookie/aes.rb
@@ -106,7 +86,7 @@ files:
106
86
  - lib/rack/pubcookie/des.rb
107
87
  - lib/rack/pubcookie/fake.rb
108
88
  - lib/rack/pubcookie/version.rb
109
- - rack-pubcookie.gemspec
89
+ - README.md
110
90
  - spec/fixtures/granting.crt
111
91
  - spec/fixtures/invalid.crt
112
92
  - spec/fixtures/test.com
@@ -121,7 +101,6 @@ rdoc_options: []
121
101
 
122
102
  require_paths:
123
103
  - lib
124
- - ext
125
104
  required_ruby_version: !ruby/object:Gem::Requirement
126
105
  none: false
127
106
  requirements:
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- pkg/*
2
- *.gem
3
- .bundle
4
-
5
- ext/**/*.bundle
6
- ext/**/Makefile
7
- ext/**/*.so
8
- ext/**/*.o
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source :rubygems
2
-
3
- # Specify your gem's dependencies in rack-pubcookie.gemspec
4
- gemspec :require => 'rack/pubcookie'
data/Gemfile.lock DELETED
@@ -1,37 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- rack-pubcookie (0.0.1)
5
- activesupport
6
- rack
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- activesupport (3.0.1)
12
- diff-lcs (1.1.2)
13
- nokogiri (1.4.3.1)
14
- rack (1.2.1)
15
- rack-test (0.5.6)
16
- rack (>= 1.0)
17
- rspec (2.0.1)
18
- rspec-core (~> 2.0.1)
19
- rspec-expectations (~> 2.0.1)
20
- rspec-mocks (~> 2.0.1)
21
- rspec-core (2.0.1)
22
- rspec-expectations (2.0.1)
23
- diff-lcs (>= 1.1.2)
24
- rspec-mocks (2.0.1)
25
- rspec-core (~> 2.0.1)
26
- rspec-expectations (~> 2.0.1)
27
-
28
- PLATFORMS
29
- ruby
30
-
31
- DEPENDENCIES
32
- activesupport
33
- nokogiri
34
- rack
35
- rack-pubcookie!
36
- rack-test
37
- rspec
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- desc "Build the C extensions"
5
- task :build_extensions do
6
- Dir.chdir(File.expand_path('../ext/openssl', __FILE__)) do
7
- sh 'make distclean' if File.exists? 'Makefile'
8
- sh 'ruby extconf.rb && make'
9
- end
10
- end
data/ext/openssl/evp.c DELETED
@@ -1,36 +0,0 @@
1
- #include <openssl/evp.h>
2
- #include <openssl/x509.h>
3
- #include <ruby.h>
4
-
5
- #define GetX509(obj, x509) Data_Get_Struct(obj, X509, x509)
6
-
7
- #ifndef RUBY_19
8
- # define RSTRING_LEN(s) (RSTRING(s)->len)
9
- # define RSTRING_PTR(s) (RSTRING(s)->ptr)
10
- #endif
11
-
12
- VALUE evp_verify_md5(VALUE self, VALUE cert, VALUE signature, VALUE str) {
13
- X509 *x509;
14
- EVP_MD_CTX ctx;
15
- EVP_PKEY *key;
16
-
17
- GetX509(cert, x509);
18
- key = X509_extract_key(x509);
19
-
20
- EVP_VerifyInit(&ctx, EVP_md5());
21
- EVP_VerifyUpdate(&ctx, RSTRING_PTR(str), RSTRING_LEN(str));
22
-
23
- int ret_val = EVP_VerifyFinal(&ctx,
24
- (unsigned char*) RSTRING_PTR(signature),
25
- (unsigned int) RSTRING_LEN(signature),
26
- key);
27
-
28
- return ret_val == 1 ? Qtrue : Qfalse;
29
- }
30
-
31
- Init_evp() {
32
- VALUE cOpenSSL = rb_define_module("OpenSSL");
33
- VALUE cEVP = rb_define_module_under(cOpenSSL, "EVP");
34
-
35
- rb_define_singleton_method(cEVP, "verify_md5", evp_verify_md5, 3);
36
- }
@@ -1,9 +0,0 @@
1
- require 'mkmf'
2
-
3
- if RUBY_VERSION =~ /1\.9/
4
- $CFLAGS << ' -DRUBY_19'
5
- end
6
-
7
- if have_header('openssl/evp.h') && have_header('openssl/x509.h')
8
- create_makefile('evp')
9
- end
@@ -1,26 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
3
- require 'rack/pubcookie/version'
4
-
5
- Gem::Specification.new do |s|
6
- s.name = 'rack-pubcookie'
7
- s.version = Rack::Pubcookie::VERSION
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ['Alex Crichton']
10
- s.email = ['alex@alexcrichton.com']
11
- s.homepage = 'http://github.com/alexcrichton/rack-pubcookie'
12
- s.summary = 'An implentation of pubcookie based on Rack in Ruby'
13
- s.description = 'Pubcookie finally leaves the world of apache!'
14
-
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.extensions = ['ext/openssl/extconf.rb']
18
- s.require_paths = ['lib', 'ext']
19
-
20
- s.add_dependency 'rack'
21
- s.add_dependency 'activesupport'
22
-
23
- s.add_development_dependency 'rspec'
24
- s.add_development_dependency 'rack-test'
25
- s.add_development_dependency 'nokogiri'
26
- end