rack-auth-krb 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/basic_and_nego/auth/basic.rb +17 -3
- data/rack-auth-krb.gemspec +1 -1
- data/spec/basic_and_nego/auth/basic_spec.rb +32 -2
- metadata +99 -110
@@ -20,9 +20,23 @@ module BasicAndNego
|
|
20
20
|
private
|
21
21
|
|
22
22
|
def authenticate(user, password)
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
#We will firstly try to authenticate the user
|
24
|
+
#suffixing his username with the realm If not already specified
|
25
|
+
is_authenticated = false
|
26
|
+
if !user.include?("@")
|
27
|
+
user_domain = [user, "@", @realm].join
|
28
|
+
is_authenticated = @krb.authenticate(user_domain, password)
|
29
|
+
if !is_authenticated
|
30
|
+
@logger.debug "Unable to authenticate #{user_domain}, trying with #{user}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
#If authentication with suffix failed, try with user's given information
|
35
|
+
if !is_authenticated
|
36
|
+
unless @krb.authenticate(user, password)
|
37
|
+
@logger.debug "Unable to authenticate (401)"
|
38
|
+
@response = unauthorized
|
39
|
+
end
|
26
40
|
end
|
27
41
|
end
|
28
42
|
|
data/rack-auth-krb.gemspec
CHANGED
@@ -22,10 +22,11 @@ describe BasicAndNego::Auth::Basic do
|
|
22
22
|
it "should try authentication against Kerberos in case of Basic" do
|
23
23
|
@krb.should_receive(:authenticate).with("fred", "pass").and_return(true)
|
24
24
|
@a.process
|
25
|
+
@a.client_name.should == "fred"
|
25
26
|
end
|
26
27
|
|
27
|
-
it "should return 'unauthorized' if authentication fails" do
|
28
|
-
@krb.should_receive(:authenticate).and_return(false)
|
28
|
+
it "should return 'unauthorized' if authentication fails" do
|
29
|
+
@krb.should_receive(:authenticate).and_return(false, false)
|
29
30
|
@a.process
|
30
31
|
@a.response.should_not be_nil
|
31
32
|
@a.response[0].should == 401
|
@@ -42,5 +43,34 @@ describe BasicAndNego::Auth::Basic do
|
|
42
43
|
@a.process
|
43
44
|
@a.client_name.should == "fred"
|
44
45
|
end
|
46
|
+
|
47
|
+
it "should try authentication against Kerberos in case of Basic adding automatically the realm" do
|
48
|
+
@krb.should_receive(:authenticate).and_return(true)
|
49
|
+
@a.process
|
50
|
+
@a.client_name.should == "fred"
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
45
54
|
|
55
|
+
describe "BasicAndNego::Auth::Basic with specific realm" do
|
56
|
+
|
57
|
+
before(:each) do
|
58
|
+
env = {'HTTP_AUTHORIZATION' => "Basic #{::Base64.encode64('fred@customRealm:pass')}"}
|
59
|
+
@realm = "my realm"
|
60
|
+
@keytab = "my keytab"
|
61
|
+
@service = "http/hostname"
|
62
|
+
@logger = BasicAndNego::NullLogger.new
|
63
|
+
@request = BasicAndNego::Request.new(env)
|
64
|
+
@request.should_receive(:credentials).and_return(['fred@customRealm', 'pass'])
|
65
|
+
@krb = double('kerberos').as_null_object
|
66
|
+
BasicAndNego::Auth::Krb.should_receive(:new).with(@logger, @realm, @keytab).and_return(@krb)
|
67
|
+
@a = BasicAndNego::Auth::Basic.new(@request, @logger, @realm, @keytab, @service)
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should try authentication against Kerberos in case of Basic" do
|
71
|
+
@krb.should_receive(:authenticate).with("fred@customRealm", "pass").and_return(true)
|
72
|
+
@a.process
|
73
|
+
@a.client_name.should == "fred@customRealm"
|
74
|
+
end
|
75
|
+
|
46
76
|
end
|
metadata
CHANGED
@@ -1,121 +1,104 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-auth-krb
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
6
10
|
platform: ruby
|
7
|
-
authors:
|
11
|
+
authors:
|
8
12
|
- Frederick Ros
|
9
13
|
autorequire:
|
10
14
|
bindir: bin
|
11
15
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
|
17
|
+
date: 2013-07-01 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: rack
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
name: gssapi
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
38
30
|
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: gssapi
|
39
34
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
name: rkerberos
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
54
42
|
type: :runtime
|
43
|
+
version_requirements: *id002
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: rkerberos
|
55
46
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
type: :runtime
|
55
|
+
version_requirements: *id003
|
56
|
+
- !ruby/object:Gem::Dependency
|
63
57
|
name: rspec
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ~>
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '2.0'
|
70
|
-
type: :development
|
71
58
|
prerelease: false
|
72
|
-
|
73
|
-
|
74
|
-
requirements:
|
59
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
75
61
|
- - ~>
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
-
|
79
|
-
|
80
|
-
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 2
|
65
|
+
- 0
|
66
|
+
version: "2.0"
|
86
67
|
type: :development
|
68
|
+
version_requirements: *id004
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: goliath
|
87
71
|
prerelease: false
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
name: puma
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
72
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
102
79
|
type: :development
|
80
|
+
version_requirements: *id005
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: puma
|
103
83
|
prerelease: false
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
84
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
type: :development
|
92
|
+
version_requirements: *id006
|
93
|
+
description: " This library allows Kerberos/GSSAPI authentication using either Basic method\n or Negotiate (i.e. authentication without the need of user/password combo).\n"
|
113
94
|
email: frederick.ros@gmail.com
|
114
95
|
executables: []
|
96
|
+
|
115
97
|
extensions: []
|
116
|
-
|
98
|
+
|
99
|
+
extra_rdoc_files:
|
117
100
|
- README.md
|
118
|
-
files:
|
101
|
+
files:
|
119
102
|
- .gitignore
|
120
103
|
- Gemfile
|
121
104
|
- Gemfile.lock
|
@@ -148,31 +131,37 @@ files:
|
|
148
131
|
- spec/goliath/goliath_krb_spec.rb
|
149
132
|
- spec/rack/rack_krb_spec.rb
|
150
133
|
- spec/spec_helper.rb
|
134
|
+
has_rdoc: true
|
151
135
|
homepage: https://github.com/sleeper/rack-auth-krb
|
152
136
|
licenses: []
|
137
|
+
|
153
138
|
post_install_message:
|
154
139
|
rdoc_options: []
|
155
|
-
|
140
|
+
|
141
|
+
require_paths:
|
156
142
|
- lib
|
157
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
requirements:
|
166
|
-
- -
|
167
|
-
- !ruby/object:Gem::Version
|
168
|
-
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
segments:
|
148
|
+
- 0
|
149
|
+
version: "0"
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
169
157
|
requirements: []
|
158
|
+
|
170
159
|
rubyforge_project:
|
171
|
-
rubygems_version: 1.
|
160
|
+
rubygems_version: 1.3.6
|
172
161
|
signing_key:
|
173
162
|
specification_version: 3
|
174
163
|
summary: Kerberos/GSSAPI authentication (Basic and Negotiate) Rack library
|
175
|
-
test_files:
|
164
|
+
test_files:
|
176
165
|
- spec/basic_and_nego/auth/basic_spec.rb
|
177
166
|
- spec/basic_and_nego/auth/gss_spec.rb
|
178
167
|
- spec/basic_and_nego/auth/krb_spec.rb
|