omniauth-mailup 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.
- data/README.md +22 -8
- data/example/config.ru +1 -2
- data/lib/omniauth/strategies/mailup.rb +13 -7
- data/lib/omniauth-mailup/version.rb +1 -1
- data/omniauth-mailup.gemspec +2 -0
- metadata +34 -2
data/README.md
CHANGED
@@ -20,7 +20,7 @@ use OmniAuth::Builder do
|
|
20
20
|
end
|
21
21
|
```
|
22
22
|
|
23
|
-
In Rails, you'll want to add to the middleware stack:
|
23
|
+
In Rails, you'll want to add to the middleware stack (`config/initializers/omniauth.rb`):
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
@@ -35,18 +35,32 @@ Here's an example _Authentication Hash_ available in `request.env['omniauth.auth
|
|
35
35
|
```ruby
|
36
36
|
{
|
37
37
|
:provider => 'mailup',
|
38
|
+
:uid => '10',
|
39
|
+
:info => {
|
40
|
+
:company => 'ACME, Inc.',
|
41
|
+
:nickname => 'm12345',
|
42
|
+
:is_trial => true
|
43
|
+
},
|
38
44
|
:credentials => {
|
39
|
-
:token => '
|
40
|
-
|
45
|
+
:token => 'adsf456lkj758klfdsg5634kl', # OAuth 2.0 access_token.
|
46
|
+
:refresh_token => '6l5k37hl345656lh342345lh', # OAuth 2.0 refresh_token.
|
47
|
+
:expires => true,
|
48
|
+
:expires_at => 1369866442
|
49
|
+
},
|
50
|
+
:extra => {...}
|
41
51
|
}
|
42
52
|
```
|
43
53
|
|
44
|
-
##
|
54
|
+
## Example
|
45
55
|
|
46
|
-
|
56
|
+
An example Sinatra app is provided in `example/config.ru`. Simply follow these instructions:
|
47
57
|
|
48
|
-
|
58
|
+
```
|
59
|
+
cd example
|
60
|
+
bundle
|
61
|
+
rackup config.ru
|
62
|
+
```
|
49
63
|
|
50
|
-
|
64
|
+
You can then view the app in your browser at `localhost:9292`.
|
51
65
|
|
52
|
-
|
66
|
+
Please note that in order to authenticate with MailUp you will need to tunnel your local app using a service like [PageKite](http://pagekite.net) (recommended) or [Localtunnel](http://progrium.com/localtunnel/).
|
data/example/config.ru
CHANGED
@@ -18,8 +18,7 @@ class App < Sinatra::Base
|
|
18
18
|
|
19
19
|
get '/auth/:provider/callback' do
|
20
20
|
content_type 'text/plain'
|
21
|
-
|
22
|
-
"Access token is #{token}".inspect rescue "No data"
|
21
|
+
"AuthHash: #{request.env['omniauth.auth']}".inspect rescue "No data"
|
23
22
|
end
|
24
23
|
|
25
24
|
get '/auth/failure' do
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'omniauth-oauth2'
|
2
2
|
require 'multi_json'
|
3
|
+
require 'multi_xml'
|
3
4
|
|
4
5
|
module OmniAuth
|
5
6
|
module Strategies
|
@@ -14,22 +15,27 @@ module OmniAuth
|
|
14
15
|
}
|
15
16
|
|
16
17
|
# TODO: Do we need this?
|
17
|
-
|
18
|
-
|
19
|
-
uid { raw_info["id"] }
|
18
|
+
option :provider_ignores_state, true
|
20
19
|
|
20
|
+
# AuthHash data for Omniauth
|
21
|
+
uid { raw_info["UID"] } # TODO: Need uid from MailUp
|
22
|
+
|
21
23
|
info do
|
22
24
|
{
|
23
|
-
:
|
24
|
-
|
25
|
+
:company => raw_info["Company"],
|
26
|
+
:nickname => raw_info["Username"],
|
27
|
+
:is_trial => raw_info["IsTrial"]
|
25
28
|
}
|
26
29
|
end
|
27
|
-
|
30
|
+
|
31
|
+
# Get more information about the user.
|
28
32
|
def raw_info
|
29
|
-
|
33
|
+
req = access_token.get('/API/v1/Rest/ConsoleService.svc/Console/Authentication/Info')
|
34
|
+
@raw_info ||= MultiXml.parse(req.body)["ConsoleCurrentAuthenticatedUserInfo"]
|
30
35
|
end
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
34
39
|
|
40
|
+
# Make sure that 'mailup' camelizes properly to 'MailUp'.
|
35
41
|
OmniAuth.config.add_camelization 'mailup', 'MailUp'
|
data/omniauth-mailup.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.0'
|
21
|
+
gem.add_runtime_dependency 'multi_json', '~> 1.7.3'
|
22
|
+
gem.add_runtime_dependency 'multi_xml', '~> 0.5.3'
|
21
23
|
|
22
24
|
gem.add_development_dependency "rspec"
|
23
25
|
gem.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-mailup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth-oauth2
|
@@ -27,6 +27,38 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 1.1.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: multi_json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.7.3
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.7.3
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: multi_xml
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.5.3
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.5.3
|
30
62
|
- !ruby/object:Gem::Dependency
|
31
63
|
name: rspec
|
32
64
|
requirement: !ruby/object:Gem::Requirement
|