omniauth-zimbraadmin 0.0.3.3 → 0.0.3.22
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6302a7098ae528cdd6e2cc9e24b4faf2f5a9d034
|
4
|
+
data.tar.gz: 80b381e1e2a38b4a25a260fbe46c585f9d92c4cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aed9841d02b29cc6789147dbc9aadb91bb181a7c74f42aee8cba72ac36ab9ec0181cce30d6f85269e79a9f2c3b63928653af6ca7a51d288dc6e63669495eae99
|
7
|
+
data.tar.gz: 77265213f8e7eec8b9ecf35e6f8168f35ad3bc31ce1f71a5e71e175cd16bdcf99b3db523326f353fe517d655d24b4545a31a8f94034cfc1123e42e4a4fd39185
|
data/README.md
CHANGED
@@ -1,24 +1,54 @@
|
|
1
|
-
# Omniauth::
|
1
|
+
# Omniauth::ZimbraAdmin
|
2
2
|
|
3
|
-
|
3
|
+
OmniAuth strategy for authenticate against a [Zimbra Server](http://www.zimbra.com) as a `Global` or `Domain` admin using the [SOAP Api](https://wiki.zimbra.com/wiki/SOAP_API_Reference_Material_Beginning_with_ZCS_8).
|
4
|
+
|
5
|
+
You'll need access to the Zimbra Admin Port, `7071` or `9071` if using Proxy, for this to work.
|
6
|
+
|
7
|
+
By the default this Gem returns the following information after a succesfully login:
|
8
|
+
|
9
|
+
* Email address of the logged user as the `request.env["omniauth.auth"].uid`
|
10
|
+
* `request.env["omniauth.auth"].credentials.token` with the `ZM_AUTH_TOKEN` given by Zimbra.
|
4
11
|
|
5
12
|
## Installation
|
6
13
|
|
7
|
-
Add this
|
14
|
+
Add this lines to your application's Gemfile:
|
8
15
|
|
9
|
-
gem '
|
16
|
+
gem 'zimbra', :github => 'pbruna/ruby-zimbra', :branch => :master
|
17
|
+
gem 'omniauth-zimbraadmin'
|
10
18
|
|
11
19
|
And then execute:
|
12
20
|
|
13
21
|
$ bundle
|
14
22
|
|
15
|
-
|
16
|
-
|
17
|
-
$ gem install omniauth-zimbra
|
23
|
+
**Note:** You will need my version of the [zimbra gem](https://github.com/pbruna/ruby-zimbra) for the moment.
|
18
24
|
|
19
25
|
## Usage
|
20
26
|
|
21
|
-
|
27
|
+
Add :zimbraadmin provider to omniauth builder:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
use OmniAuth::Builder do
|
31
|
+
provider :zimbraadmin, "https://zimbra.example.com:7071/service/admin/soap"
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
Example for Rails with complete options:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
endpoint = "https://mail.example.com:9071/service/admin/soap"
|
39
|
+
|
40
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
41
|
+
provider :zimbraadmin, :endpoint => endpoint, :debug => true, :new_session_path => "/sessions/new",
|
42
|
+
:zimbra_attributes => ["zimbraId", "mail", "displayName", "zimbraMailAlias"]
|
43
|
+
end
|
44
|
+
|
45
|
+
OmniAuth.config.logger = Rails.logger
|
46
|
+
```
|
47
|
+
|
48
|
+
About the options:
|
49
|
+
|
50
|
+
* `new_session_path`, is the path with the login form
|
51
|
+
* `zimbra_attributes`, extra Zimbra information that will be returned in the `extra` element of the Omniauth [Auth Hash Schema](https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema)
|
22
52
|
|
23
53
|
## Contributing
|
24
54
|
|
@@ -9,21 +9,37 @@ module OmniAuth
|
|
9
9
|
args [:endpoint]
|
10
10
|
|
11
11
|
option :title, "Zimbra Admin Auth"
|
12
|
+
option :name, "zimbraadmin"
|
13
|
+
option :fields, [:name, :email]
|
14
|
+
option :zimbra_attributes, %w( displayName )
|
12
15
|
option :debug, false
|
16
|
+
option :new_session_path, "/sessions/new"
|
17
|
+
option :uid_field, :email
|
13
18
|
|
14
19
|
def request_phase
|
15
|
-
|
16
|
-
text_field 'Email', 'email'
|
17
|
-
password_field 'Password', 'password'
|
18
|
-
button "Sign In"
|
19
|
-
end.to_response
|
20
|
+
redirect options[:new_session_path]
|
20
21
|
end
|
21
|
-
|
22
|
+
|
22
23
|
def callback_phase
|
23
|
-
return fail!(:invalid_credentials)
|
24
|
+
return fail!(:invalid_credentials) unless authentication_response
|
24
25
|
super
|
25
26
|
end
|
26
27
|
|
28
|
+
uid { username }
|
29
|
+
|
30
|
+
info do {
|
31
|
+
name: @authentication_response[:account_attrs]["displayName"]
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
credentials do
|
36
|
+
{ :token => @authentication_response[:token] }
|
37
|
+
end
|
38
|
+
|
39
|
+
extra do
|
40
|
+
@authentication_response[:account_attrs]
|
41
|
+
end
|
42
|
+
|
27
43
|
protected
|
28
44
|
|
29
45
|
# by default we use static uri. If dynamic uri is required, override
|
@@ -31,34 +47,40 @@ module OmniAuth
|
|
31
47
|
def endpoint
|
32
48
|
options.endpoint
|
33
49
|
end
|
34
|
-
|
50
|
+
|
35
51
|
def debug
|
36
52
|
options[:debug]
|
37
53
|
end
|
38
54
|
|
39
55
|
def username
|
40
|
-
request['email']
|
56
|
+
request[:sessions]['email']
|
41
57
|
end
|
42
58
|
|
43
59
|
def password
|
44
|
-
request['password']
|
60
|
+
request[:sessions]['password']
|
45
61
|
end
|
46
62
|
|
47
63
|
def authentication_response
|
48
64
|
unless @authentication_response
|
49
65
|
return unless username && password
|
50
|
-
|
51
|
-
|
52
|
-
Zimbra.admin_api_url = endpoint
|
53
|
-
begin
|
54
|
-
@authentication_response = Zimbra.reset_login(username, password)
|
55
|
-
rescue Exception => e
|
56
|
-
@authentication_response = false
|
57
|
-
end
|
66
|
+
@authentication_response = login_and_data(username, password)
|
67
|
+
return unless @authentication_response
|
58
68
|
end
|
59
|
-
|
60
69
|
@authentication_response
|
61
70
|
end
|
71
|
+
|
72
|
+
def login_and_data(username, password)
|
73
|
+
Zimbra.debug = debug
|
74
|
+
Zimbra.admin_api_url = endpoint
|
75
|
+
begin
|
76
|
+
token = Zimbra.reset_login(username, password)
|
77
|
+
account = Zimbra::Account.find_by_name username
|
78
|
+
account_attrs = account.get_attributes options[:zimbra_attributes]
|
79
|
+
{token: token, account: account, account_attrs: account_attrs}
|
80
|
+
rescue Exception => e
|
81
|
+
false
|
82
|
+
end
|
83
|
+
end
|
62
84
|
|
63
85
|
end
|
64
86
|
end
|
File without changes
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-zimbraadmin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.3.
|
4
|
+
version: 0.0.3.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patricio Bruna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
@@ -101,7 +101,7 @@ files:
|
|
101
101
|
- lib/omniauth-zimbraadmin.rb
|
102
102
|
- lib/omniauth-zimbraadmin/version.rb
|
103
103
|
- lib/omniauth/strategies/zimbra_admin.rb
|
104
|
-
- omniauth-
|
104
|
+
- omniauth-zimbraadmin.gemspec
|
105
105
|
- test/test_helper.rb
|
106
106
|
homepage: https://github.com/pbruna/omniauth-zimbra
|
107
107
|
licenses:
|