zimbra_intercepting_proxy 0.0.4.1 → 0.0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/zimbra_intercepting_proxy.rb +1 -0
- data/lib/zimbra_intercepting_proxy/request.rb +19 -2
- data/lib/zimbra_intercepting_proxy/server.rb +1 -1
- data/lib/zimbra_intercepting_proxy/version.rb +1 -1
- data/test/fixtures/zco_soap.xml +1 -0
- data/test/test_helper.rb +1 -0
- data/test/test_request.rb +29 -10
- data/zimbra_intercepting_proxy.gemspec +2 -1
- metadata +38 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c43322897f826dfb60b13d7f600624311debaa4e
|
4
|
+
data.tar.gz: 52c6130238ffb9f4d7ab0be5a8381f8ac6238ed5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92ddfc17968639cc7a521e909df6519da27792647441c987571425f22013541348cb6284a103349fb344191d73176b2b0a2687f7a843a08aa06ae711aee58bc9
|
7
|
+
data.tar.gz: 85976c28eed04ae7b12e105638c7d2d5e44bde9e162467cf5058d4e34800c4925c42bd755134b97565df4fa3fce2ed91a961da309b65cdd8457afaa28443fd21
|
data/README.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
# ZimbraInterceptingProxy
|
2
2
|
|
3
|
-
|
3
|
+
This software is used to Intercept and Transform the traffic to and from the Zimbra Mailboxes when using a Zimbra Proxy.
|
4
|
+
If you don't know what Zimbra Proxy is, You can read about it here: [https://wiki.zimbra.com/wiki/Zimbra_Proxy_Guide](https://wiki.zimbra.com/wiki/Zimbra_Proxy_Guide)
|
4
5
|
|
6
|
+
## What is good for?
|
7
|
+
|
8
|
+
### Zimbra Migrations
|
9
|
+
Suppose you
|
5
10
|
|
6
11
|
## TODO:
|
7
12
|
|
@@ -4,16 +4,26 @@ module ZimbraInterceptingProxy
|
|
4
4
|
|
5
5
|
attr_accessor :body, :headers, :parser
|
6
6
|
|
7
|
-
def initialize(connection, parser)
|
7
|
+
def initialize(connection, parser = nil)
|
8
8
|
@body = connection.body
|
9
9
|
@headers = connection.headers
|
10
10
|
@parser = parser
|
11
11
|
end
|
12
12
|
|
13
13
|
def auth_request?
|
14
|
+
default_auth_request? || zco_auth_request?
|
15
|
+
end
|
16
|
+
|
17
|
+
# This is the post Auth request sent by Webmail, ActiveSync and POP and IMAP
|
18
|
+
def default_auth_request?
|
14
19
|
@parser.http_method == "POST" && @parser.request_url == "/zimbra/" && @headers["Cookie"] = "ZM_TEST=true" && auth_request_params?
|
15
20
|
end
|
16
21
|
|
22
|
+
def zco_auth_request?
|
23
|
+
@parser.http_method == "POST" && @parser.request_url == "/service/soap/AuthRequest" && @headers["User-Agent"].match(/Zimbra-ZCO/)
|
24
|
+
end
|
25
|
+
|
26
|
+
|
17
27
|
def auth_request_params?
|
18
28
|
uri = Addressable::URI.parse("http://localhost/?#{@body}")
|
19
29
|
uri.query_values["loginOp"] == "login"
|
@@ -29,14 +39,21 @@ module ZimbraInterceptingProxy
|
|
29
39
|
end
|
30
40
|
|
31
41
|
def user_token
|
32
|
-
return auth_username if
|
42
|
+
return auth_username if default_auth_request?
|
33
43
|
return auth_zimbraId if route_request?
|
44
|
+
return auth_zco_username if zco_auth_request?
|
34
45
|
end
|
35
46
|
|
36
47
|
def auth_zimbraId
|
37
48
|
headers["Auth-User"]
|
38
49
|
end
|
39
50
|
|
51
|
+
def auth_zco_username
|
52
|
+
# Hold on, we have to dig deeper
|
53
|
+
xml = XmlSimple.xml_in @body
|
54
|
+
xml["Body"].first["AuthRequest"].first["account"].first["content"]
|
55
|
+
end
|
56
|
+
|
40
57
|
def auth_username
|
41
58
|
uri = Addressable::URI.parse("http://localhost/?#{@body}")
|
42
59
|
uri.query_values["username"]
|
@@ -11,7 +11,7 @@ module ZimbraInterceptingProxy
|
|
11
11
|
|
12
12
|
Proxy.start(:host => host, :port => port) do |conn|
|
13
13
|
|
14
|
-
debug.logger "Starting server on #{host}:#{port}"
|
14
|
+
debug.logger "Starting server on #{host}:#{port} - V. #{ZimbraInterceptingProxy::VERSION}"
|
15
15
|
|
16
16
|
@backend = {host: ZimbraInterceptingProxy::Config.old_backend, port: 80}
|
17
17
|
connection = ZimbraInterceptingProxy::Connection.new
|
@@ -0,0 +1 @@
|
|
1
|
+
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Header><context xmlns="urn:zimbra"><userAgent name="ZimbraConnectorForOutlook" version="8.5.1.1259"/><nonotify/><noqualify/></context></soap:Header><soap:Body><AuthRequest xmlns="urn:zimbraAccount"><account by="name">watson@example.com</account><password>watson</password><virtualHost>200.91.20.186</virtualHost></AuthRequest></soap:Body></soap:Envelope>
|
data/test/test_helper.rb
CHANGED
data/test/test_request.rb
CHANGED
@@ -3,18 +3,37 @@ require 'test_helper'
|
|
3
3
|
class Request < Minitest::Test
|
4
4
|
|
5
5
|
def setup
|
6
|
+
@done = false
|
6
7
|
@auth_request = IO.read("./test/fixtures/auth_80.txt")
|
7
8
|
@route_request = IO.read("./test/fixtures/route_7072.txt")
|
9
|
+
@soap_auth_request = IO.read("./test/fixtures/zco_soap.xml")
|
10
|
+
@connection = OpenStruct.new
|
11
|
+
@parser = OpenStruct.new
|
8
12
|
end
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
def test_should_return_user_token_from_auth_request
|
15
|
+
@parser.http_method = "POST"
|
16
|
+
@parser.request_url = "/zimbra/"
|
17
|
+
@connection.headers = {"Cookie" => "ZM_TEST=true"}
|
18
|
+
@connection.body = "loginOp=login&username=pbruna&password=5693537374&client=preferred"
|
19
|
+
request = ZimbraInterceptingProxy::Request.new @connection, @parser
|
20
|
+
assert_equal("pbruna", request.user_token)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_should_return_user_token_from_route_request
|
24
|
+
@parser.request_url = ZimbraInterceptingProxy::Config::ROUTE_URL
|
25
|
+
@connection.headers = {"Auth-User" => "251b1902-2250-4477-bdd1-8a101f7e7e4e"}
|
26
|
+
request = ZimbraInterceptingProxy::Request.new @connection, @parser
|
27
|
+
assert_equal("251b1902-2250-4477-bdd1-8a101f7e7e4e", request.user_token)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_should_get_username_from_zco_auth_request
|
31
|
+
@parser.http_method = "POST"
|
32
|
+
@parser.request_url = "/service/soap/AuthRequest"
|
33
|
+
@connection.headers = {"User-Agent" => "Zimbra-ZCO"}
|
34
|
+
@connection.body = @soap_auth_request
|
35
|
+
request = ZimbraInterceptingProxy::Request.new @connection, @parser
|
36
|
+
assert_equal("watson@example.com", request.user_token)
|
37
|
+
end
|
38
|
+
|
20
39
|
end
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["pbruna@itlinux.cl"]
|
11
11
|
spec.summary = "A HTTP intercepting Proxy for the Zimbra Proxy"
|
12
12
|
spec.description = spec.summary
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/pbruna/zimbra_intercepting_proxy"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency 'uuid'
|
24
24
|
spec.add_dependency 'http_parser.rb'
|
25
25
|
spec.add_dependency 'addressable'
|
26
|
+
spec.add_dependency 'xml-simple'
|
26
27
|
|
27
28
|
|
28
29
|
spec.add_development_dependency "bundler", "~> 1.6"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zimbra_intercepting_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.4.
|
4
|
+
version: 0.0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patricio Bruna
|
@@ -14,112 +14,126 @@ dependencies:
|
|
14
14
|
name: em-proxy
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: uuid
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: http_parser.rb
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: addressable
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: xml-simple
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: bundler
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- - ~>
|
101
|
+
- - "~>"
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '1.6'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
|
-
- - ~>
|
108
|
+
- - "~>"
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '1.6'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- -
|
115
|
+
- - ">="
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '0'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
|
-
- -
|
122
|
+
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: minitest-reporters
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- -
|
129
|
+
- - ">="
|
116
130
|
- !ruby/object:Gem::Version
|
117
131
|
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- -
|
136
|
+
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
description: A HTTP intercepting Proxy for the Zimbra Proxy
|
@@ -130,7 +144,7 @@ executables:
|
|
130
144
|
extensions: []
|
131
145
|
extra_rdoc_files: []
|
132
146
|
files:
|
133
|
-
- .gitignore
|
147
|
+
- ".gitignore"
|
134
148
|
- Gemfile
|
135
149
|
- LICENSE.txt
|
136
150
|
- README.md
|
@@ -148,12 +162,13 @@ files:
|
|
148
162
|
- test/fixtures/auth_80.txt
|
149
163
|
- test/fixtures/route_7072.txt
|
150
164
|
- test/fixtures/users.yml
|
165
|
+
- test/fixtures/zco_soap.xml
|
151
166
|
- test/test_backend.rb
|
152
167
|
- test/test_helper.rb
|
153
168
|
- test/test_request.rb
|
154
169
|
- test/test_user.rb
|
155
170
|
- zimbra_intercepting_proxy.gemspec
|
156
|
-
homepage:
|
171
|
+
homepage: https://github.com/pbruna/zimbra_intercepting_proxy
|
157
172
|
licenses:
|
158
173
|
- MIT
|
159
174
|
metadata: {}
|
@@ -163,17 +178,17 @@ require_paths:
|
|
163
178
|
- lib
|
164
179
|
required_ruby_version: !ruby/object:Gem::Requirement
|
165
180
|
requirements:
|
166
|
-
- -
|
181
|
+
- - ">="
|
167
182
|
- !ruby/object:Gem::Version
|
168
183
|
version: '0'
|
169
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
185
|
requirements:
|
171
|
-
- -
|
186
|
+
- - ">="
|
172
187
|
- !ruby/object:Gem::Version
|
173
188
|
version: '0'
|
174
189
|
requirements: []
|
175
190
|
rubyforge_project:
|
176
|
-
rubygems_version: 2.
|
191
|
+
rubygems_version: 2.2.2
|
177
192
|
signing_key:
|
178
193
|
specification_version: 4
|
179
194
|
summary: A HTTP intercepting Proxy for the Zimbra Proxy
|
@@ -181,6 +196,7 @@ test_files:
|
|
181
196
|
- test/fixtures/auth_80.txt
|
182
197
|
- test/fixtures/route_7072.txt
|
183
198
|
- test/fixtures/users.yml
|
199
|
+
- test/fixtures/zco_soap.xml
|
184
200
|
- test/test_backend.rb
|
185
201
|
- test/test_helper.rb
|
186
202
|
- test/test_request.rb
|