omniauth-kanbox 1.0.0 → 1.0.1

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTc5ODQzYmU0MDAyNTJhODM4ZTAyOTk2OTA2Y2JjMTEwMWNiYTljMg==
4
+ MTMzODg4MWFiZmVlODZjMjRkM2MxMGY4Yzg3MDk1ZGY3ZDVlZTQyMg==
5
5
  data.tar.gz: !binary |-
6
- MGQ3ZjA4YWQ0MTU5ZTU1YTNhMWE4MmU5ODZkMTZiMjMzYTM2ZTJlNA==
6
+ OTIwZTk4ZWM0OTIzNWM2NTUyYTcxODkxNTM5N2QwZjY0OTc3ZGE0Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTU5YzQ0ZDFmODUyMDhkYTc1ZmRmZDUxZjM3MmExZGYwZDFhMmE1YjI0YmJh
10
- NmY2NGUwNDBlOWZmYjkxYzRjMDdhYzY5N2MxNjU5MjEzNTA5ZjMwYTc4MDI5
11
- NDVmNWI1NWE4MDIyMzc5ZjQ2M2RlYmUwYjA3Y2UyOTMwNzlhNjQ=
9
+ NjU5ZDVmYWUyNjZlNDc0NzEzNjA2ODg5OTYzMThlNmNmMjhmYmYyNzU0MTgy
10
+ NmI2MzcwNWZhMjRmMDI5NjVkZGU1OGFjZmViNmI5ZDhhMDMyZDE3MTY1Yzc0
11
+ OGZhZDVjMzEyMjFmOGY2OTA3OWE1ZDBjMTgzZjMxMmFhMTk3Njc=
12
12
  data.tar.gz: !binary |-
13
- MzBiNWYxYjE0N2JmMzNiMmNiNGY5NDMzOTI2NDE0ZDA1YzEyMDkyNDk3NWNj
14
- MDk3MTU0MjNjNTgwNGJmYmJkNzE3MWY1NjQzMTA2ZDY0ZDk3NWQyOGRhMzhh
15
- NjJmZDI2ZjcwODQwMDc1M2EwNjBmNzBlNTgwOTY5Y2Y0ZDBhMmU=
13
+ MzA5OTZkOGQzMDVlNDE5MjFlODA3ZDNhNDdlMzk3ZDY5NWMxMWIxMjJmNzkz
14
+ MzM3ZDc0NmE4YjcxZGEyMGJkOGFlZjdiMTRmOTU5MTE4ZDU1MDA2YjhjYWUw
15
+ MzhlZDk5Y2FhNzRkZmZlMTVmZTRkZjc0YWUwNGE2NjRmZmVhNDg=
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- =======
2
- omniauth-workxp
1
+ omniauth-kanbox
3
2
  ===============
4
3
 
5
4
  Unofficial OmniAuth strategy for Kanbox.
@@ -18,36 +17,53 @@ Or install it yourself as:
18
17
 
19
18
  $ gem install omniauth-kanbox
20
19
 
20
+
21
21
  ## Usage
22
- Example with devise:
23
-
24
- #### routes:
25
- devise_for :users, :controllers => { omniauth_callbacks: "omniauth_callbacks"}
26
- #### user.rb:
27
- open omniauthable in devise:
28
- devise :omniauthable
29
- #### controller:
30
- rails g controller omniauth_callbacks --skip-helper --skip-assets
31
- class OmniauthCallbacksController < ApplicationController
32
- def all
33
- auth = request.env["omniauth.auth"]
34
- raise auth.to_yaml
35
- end
36
-
37
- alias_method :kanbox, :all
38
- end
39
- #### devise.rb:
40
- config.omniauth :kanbox, 'a9acabbfd9be74d4f77d2227b7621e18c7ba6290d87459801014039f8af63290', '0deb222c9602cedefc7ba17f6820e5c926e20bc9113406ec8fd71fff678189f0'
41
-
42
- #### views:
43
- <%= link_to "login by kanbox", http://lvh.me:3000/users/auth/kanbox %>
44
-
45
-
46
- ## Contributing
47
-
48
- 1. Fork it
49
- 2. Create your feature branch (`git checkout -b my-new-feature`)
50
- 3. Commit your changes (`git commit -am 'Add some feature'`)
51
- 4. Push to the branch (`git push origin my-new-feature`)
52
- 5. Create new Pull Request
22
+
23
+ `OmniAuth::Strategies::Kanbox` is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: https://github.com/intridea/omniauth.
24
+
25
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
26
+
27
+ ```ruby
28
+ Rails.application.config.middleware.use OmniAuth::Builder do
29
+ provider :kanbox, ENV['KANBOX_KEY'], ENV['KANBOX_SECRET']
30
+ end
31
+ ```
32
+
33
+
34
+ ## Auth Hash
35
+
36
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
37
+
38
+ ```ruby
39
+ {
40
+ :provider => 'kanbox',
41
+ :uid => 'user email',
42
+ :info => {
43
+ :email => 'yp.xjgz@gmail.com',
44
+ :name => 'yp.xjgz@gmail.com',
45
+ :phone => '18612553650',
46
+ ::description => 'spaceUsed:200/20000'
47
+ },
48
+ :credentials => {
49
+ :token => 'ABCDEF...', # OAuth 2.0 access_token, which you may wish to store
50
+ :expires_at => 1321747205, # when the access token expires (it always will)
51
+ :expires => true # this will always be true
52
+ },
53
+ :extra => {
54
+ :raw_info => {
55
+ :status => 'ok',
56
+ :email => 'yp.xjgz@gmail.com',
57
+ :phone => '18612553650',
58
+ :spaceQuota => '200',
59
+ :spaceUsed => '20000',
60
+ :emailIsActive => 1,
61
+ :phoneIsActive => 0
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ The precise information available may depend on the permissions which you request.
68
+
53
69
 
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Kanbox
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -1,13 +1,12 @@
1
- require 'omniauth-oauth'
2
- require 'multi_json'
1
+ require 'omniauth-oauth2'
3
2
 
4
3
  module OmniAuth
5
4
  module Strategies
6
- class Kanbox < OmniAuth::Strategies::OAuth
5
+ class Kanbox < OmniAuth::Strategies::OAuth2
7
6
  option :name, 'kanbox'
8
7
 
9
8
  option :client_options, {
10
- :authorize_path => '/0/auth',
9
+ :authorize_url => '/0/auth',
11
10
  :site => 'https://auth.kanbox.com',
12
11
  :token_url => "/0/token",
13
12
  }
@@ -16,8 +15,10 @@ module OmniAuth
16
15
 
17
16
  info do
18
17
  {
19
- :name => raw_info['email']
20
- :email => raw_info['email']
18
+ :name => raw_info['email'],
19
+ :email => raw_info['email'],
20
+ :phone => raw_info['phone'],
21
+ :description => "spaceUsed:#{raw_info['spaceUsed']}/#{raw_info['spaceQuota']}"
21
22
  }
22
23
  end
23
24
 
@@ -28,10 +29,9 @@ module OmniAuth
28
29
  end
29
30
 
30
31
  def raw_info
31
- @raw_info ||= access_token.get('0/info').parsed
32
+ @raw_info ||= MultiJson.decode(access_token.get("https://api.kanbox.com/0/info").body)
32
33
  end
33
34
 
34
-
35
35
  end
36
36
  end
37
37
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_dependency 'omniauth', '~> 1.2'
23
- s.add_dependency 'omniauth-oauth2', '~> 1.1'
23
+ s.add_dependency 'omniauth-oauth2', '~> 1.2'
24
24
  s.add_development_dependency 'rspec', '~> 2.7'
25
25
  s.add_development_dependency 'rack-test'
26
26
  s.add_development_dependency 'simplecov'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-kanbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - YuanPing
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-29 00:00:00.000000000 Z
11
+ date: 2014-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '1.1'
33
+ version: '1.2'
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
- version: '1.1'
40
+ version: '1.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement