omniauth-owa 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/LICENCE +21 -0
- data/README.md +62 -0
- data/Rakefile +9 -0
- data/lib/omniauth-owa/version.rb +1 -1
- data/lib/omniauth/strategies/owa.rb +9 -9
- data/spec/omniauth/strategies/owa_spec.rb +35 -19
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5878cdb9a86f12f3fadab9ee79d19e66c2f7fd2
|
4
|
+
data.tar.gz: e8897c9397eab34454b259ed0de56c7fe9b097da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df10832c1139b9168aa19b84f36dde383201b391bd98e2db9b1b930e9c81eaef5d852d81d9829f8448008731c56d977e5d95a912f03753dfaffdd4ea23915ee5
|
7
|
+
data.tar.gz: e1a93a2386d15d4c31bc66ca9d50a8fcb4fc121a9c9c4805686270357c8a5cb2b2900b3d726e0da1f6dc92e9b7f05f736ee2de9e72665d5130d7cbf72f7cc19b
|
data/LICENCE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Kerry Buckley
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# OmniAuth-OWA
|
2
|
+
|
3
|
+
## About
|
4
|
+
|
5
|
+
This is an [OmiAuth](https://github.com/intridea/omniauth) strategy for
|
6
|
+
authenticating against an Outlook Web Access server. Might be handy if you want
|
7
|
+
to allow people to authenticate against your company's LDAP credentials but the
|
8
|
+
only way they're exposed on the Internet is through webmail login.
|
9
|
+
|
10
|
+
Currently barely more than a proof of concept, only tested against one specific
|
11
|
+
OWA server, and certainly not production quality!
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
gem install omniauth-owa
|
16
|
+
|
17
|
+
Or if you're using bundler, put it in your gemfile:
|
18
|
+
|
19
|
+
gem "omniauth-owa"
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Rails example:
|
24
|
+
|
25
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
26
|
+
provider :owa, base_url: "https://mail.example.com", form: SessionsController.action(:new)
|
27
|
+
end
|
28
|
+
|
29
|
+
If you override the form (as in the example above), it should post to
|
30
|
+
`/auth/owa/callback` with `uid` and `password` parameters.
|
31
|
+
|
32
|
+
The parameters returned in the authentication hash are:
|
33
|
+
|
34
|
+
* uid
|
35
|
+
* info.name
|
36
|
+
* info.first_name
|
37
|
+
* info.last_name
|
38
|
+
* info.email
|
39
|
+
|
40
|
+
## Licence
|
41
|
+
|
42
|
+
The MIT License (MIT)
|
43
|
+
|
44
|
+
Copyright (c) 2014 Kerry Buckley
|
45
|
+
|
46
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
47
|
+
of this software and associated documentation files (the "Software"), to deal
|
48
|
+
in the Software without restriction, including without limitation the rights
|
49
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
50
|
+
copies of the Software, and to permit persons to whom the Software is
|
51
|
+
furnished to do so, subject to the following conditions:
|
52
|
+
|
53
|
+
The above copyright notice and this permission notice shall be included in all
|
54
|
+
copies or substantial portions of the Software.
|
55
|
+
|
56
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
57
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
58
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
59
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
60
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
61
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
62
|
+
SOFTWARE.
|
data/Rakefile
ADDED
data/lib/omniauth-owa/version.rb
CHANGED
@@ -21,13 +21,17 @@ module OmniAuth
|
|
21
21
|
conn = Faraday.new url: options.base_url
|
22
22
|
conn.basic_auth uid, password
|
23
23
|
|
24
|
-
|
24
|
+
response = conn.get("/owa/?ae=Dialog&t=AddressBook&ctx=1&sch=#{uid}")
|
25
|
+
return fail!(:invalid_credentials) unless response.success?
|
26
|
+
search_results = response.body
|
25
27
|
id = search_results.match(/<h1><a href="#" id="([^"]+)"/)[1]
|
26
28
|
details = conn.get("/owa/?ae=Item&t=AD.RecipientType.User&id=#{CGI.escape id}").body
|
27
29
|
|
28
|
-
@
|
29
|
-
@
|
30
|
-
@
|
30
|
+
@info = {}
|
31
|
+
@info[:first_name] = details.match(/<td[^>]*>First name<\/td><td[^>]*>([^<]*)/)[1]
|
32
|
+
@info[:last_name] = details.match(/<td[^>]*>Last name<\/td><td[^>]*>([^<]*)/)[1]
|
33
|
+
@info[:email] = details.match(/<td[^>]*>E-mail<\/td><td[^>]*>([^<]*)/)[1]
|
34
|
+
@info[:name] = "#{@info[:first_name]} #{@info[:last_name]}"
|
31
35
|
super
|
32
36
|
end
|
33
37
|
|
@@ -36,11 +40,7 @@ module OmniAuth
|
|
36
40
|
end
|
37
41
|
|
38
42
|
info do
|
39
|
-
|
40
|
-
name: @name,
|
41
|
-
first_name: @first_name,
|
42
|
-
last_name: @last_name,
|
43
|
-
}
|
43
|
+
@info
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -46,43 +46,59 @@ describe OmniAuth::Strategies::OWA do
|
|
46
46
|
describe "callback phase" do
|
47
47
|
let(:auth_hash) { last_request.env["omniauth.auth"] }
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
context "when authentication succeeds" do
|
50
|
+
before do
|
51
|
+
stub_request(:get, "https://fred:secret@mail.example.com/owa/?ae=Dialog&t=AddressBook&ctx=1&sch=fred").
|
52
|
+
to_return body: <<-EOF
|
52
53
|
Blah blah
|
53
54
|
<h1><a href=\"#\" id=\"an=id\" onClick=\"return onClkRcpt(this, 1);\">Fred Bloggs</a></h1>
|
54
55
|
blah
|
55
56
|
EOF
|
56
57
|
|
57
|
-
|
58
|
-
|
58
|
+
stub_request(:get, "https://fred:secret@mail.example.com/owa/?ae=Item&t=AD.RecipientType.User&id=an%3Did").
|
59
|
+
to_return body: <<-EOF
|
59
60
|
Blah blah
|
60
61
|
<tr><td class="lbl lp" nowrap>First name</td><td class="txvl">Fred</td></tr>
|
61
62
|
<tr><td class="lbl lp" nowrap>Last name</td><td class="txvl">Bloggs</td></tr>
|
63
|
+
<tr><td class="lbl lp" nowrap>E-mail</td><td class="txvl">fred.bloggs@example.com</td></tr>
|
62
64
|
blah
|
63
65
|
EOF
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
+
post "/auth/owa/callback", uid: "fred", password: "secret"
|
68
|
+
end
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
-
|
70
|
+
it "sets the uid to the value submitted" do
|
71
|
+
expect(auth_hash.uid).to eq "fred"
|
72
|
+
end
|
71
73
|
|
72
|
-
|
73
|
-
|
74
|
-
|
74
|
+
it "sets the name in the auth hash" do
|
75
|
+
expect(auth_hash.info.name).to eq("Fred Bloggs")
|
76
|
+
end
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
-
|
78
|
+
it "sets the first name in the auth hash" do
|
79
|
+
expect(auth_hash.info.first_name).to eq("Fred")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "sets the last name in the auth hash" do
|
83
|
+
expect(auth_hash.info.last_name).to eq("Bloggs")
|
84
|
+
end
|
79
85
|
|
80
|
-
|
81
|
-
|
86
|
+
it "sets the email address in the auth hash" do
|
87
|
+
expect(auth_hash.info.email).to eq("fred.bloggs@example.com")
|
88
|
+
end
|
82
89
|
end
|
83
90
|
|
84
91
|
context "when authentication fails" do
|
85
|
-
|
92
|
+
before do
|
93
|
+
stub_request(:get, "https://fred:secret@mail.example.com/owa/?ae=Dialog&t=AddressBook&ctx=1&sch=fred").
|
94
|
+
to_return status: 401
|
95
|
+
post "/auth/owa/callback", uid: "fred", password: "secret"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "fails with 'invalid_credentials'" do
|
99
|
+
expect(last_response).to be_redirect
|
100
|
+
expect(last_response.location).to eq "/auth/failure?message=invalid_credentials&strategy=owa"
|
101
|
+
end
|
86
102
|
end
|
87
103
|
end
|
88
104
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-owa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kerry Buckley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
@@ -117,6 +117,9 @@ extra_rdoc_files: []
|
|
117
117
|
files:
|
118
118
|
- ".gitignore"
|
119
119
|
- Gemfile
|
120
|
+
- LICENCE
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
120
123
|
- lib/omniauth-owa.rb
|
121
124
|
- lib/omniauth-owa/version.rb
|
122
125
|
- lib/omniauth/strategies/owa.rb
|