omniauth-workxp 0.0.3 → 0.0.4

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGJjOGRlZmZmZTY4ZTVkZjdkNDc0MzkxM2M3ODI4ODc1ODVhZGE2NQ==
5
+ data.tar.gz: !binary |-
6
+ MzhmMzgzZjVmYzRjNzkyMmIwMGI2MDViYWNlZjU5ZDkzMGFkZjczNg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MzI0ZTNlZjkyMDA0NTdjNGJhMWMyZWZkNjg4MWViZDUwMzYzMTVkYjQ3MGE2
10
+ NTY3ZDk0ODM5NWJiMzZkODg4MjRlYjYxMzY1NDQ2ZjBhZTAxMDYyZjQ1MjY3
11
+ NTM3OGIwZWQxMjhjOWI2NDY5ZGI0NjI2ZDgwOTY5NDU3NDFjZmM=
12
+ data.tar.gz: !binary |-
13
+ ZTlhMjQzOWZhZDIyZTYzMWQyZmY2Y2MzOGIwMjBjYTA2MzUzOTlhMmNkYzBl
14
+ NjY1M2Q0MzgxYTM5ZmJhYzg0MmEzYzlkNzEzYTVjZWFmYjBlZTE2Y2U5YmRl
15
+ N2ZkMzFjOGEzMDVmNDU1ZGI4NDNiMmEyODIwNTYxZDg3NWE1YjA=
data/.gitignore CHANGED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ Gemfile.lock
6
+ coverage
7
+ InstalledFiles
8
+ lib/bundler/man
9
+ pkg
10
+ rdoc
11
+ spec/reports
12
+ test/tmp
13
+ test/version_tmp
14
+ tmp
15
+
16
+ # YARD artifacts
17
+ .yardoc
18
+ _yardoc
19
+ doc/
20
+ .DS_Store
data/README.md CHANGED
@@ -20,7 +20,60 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ `OmniAuth::Strategies::WorkXP` 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 :workxp, ENV['WORKXP_KEY'], ENV['WORKXP_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 => 'workxp',
41
+ :uid => 'user email',
42
+ :info => {
43
+ :email => 'yuanping@workxp.info',
44
+ :name => '袁平',
45
+ :image => 'http://workxp.info/avatar.png',
46
+ :accounts => {
47
+ "company": "容平志远科技(北京)有限公司",
48
+ "domain": "rongping"
49
+ }
50
+ },
51
+ :credentials => {
52
+ :expires => false,
53
+ :token => 'ABCDEF...', # OAuth 2.0 access_token, which you may wish to store
54
+ :refresh_token => 'decfa',
55
+ :expires_at => 1321747205 # when the access token expires (it always will)
56
+ },
57
+ :extra => {
58
+ :raw_info => {
59
+ "identity": {
60
+ "id": 12,
61
+ "name": "袁平",
62
+ "email": "yuanping@workxp.info",
63
+ "avatar_url": "http://workxp.info/avatar.png"
64
+ },
65
+ "accounts": {
66
+ "company": "容平志远科技(北京)有限公司",
67
+ "domain": "rongping"
68
+ }
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ The precise information available may depend on the permissions which you request.
75
+
76
+
24
77
 
25
78
  ## Contributing
26
79
 
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Workxp
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -2,65 +2,37 @@ require 'omniauth-oauth2'
2
2
 
3
3
  module OmniAuth
4
4
  module Strategies
5
- class Workxp < OmniAuth::Strategies::OAuth2
5
+ class WorkXP < OmniAuth::Strategies::OAuth2
6
+ option :name, 'workxp'
7
+
6
8
  option :client_options, {
7
- :site => 'https://workxp.info',
8
- :authorize_url => 'https://workxp.info/oauth/authorize',
9
- :token_url => 'https://workxp.info/oauth/token'
9
+ :site => 'https://workxp.info'
10
10
  }
11
11
 
12
- def request_phase
13
- super
14
- end
15
-
16
- def authorize_params
17
- if request.params["scope"]
18
- super.merge({:scope => request.params["scope"]})
19
- else
20
- super
21
- end
22
- end
23
-
24
- uid { raw_info['id'].to_s }
12
+ uid { raw_info['identity']['id'].to_s }
25
13
 
26
14
  info do
27
15
  {
28
- 'nickname' => raw_info['login'],
29
- 'email' => email,
30
- 'name' => raw_info['name'],
16
+ 'email' => raw_info['identity']['email'],
17
+ 'name' => raw_info['identity']['name'],
31
18
  'image' => raw_info['avatar_url'],
32
- 'urls' => {
33
- 'Workxp' => "https://workxp.info/#{raw_info['login']}",
34
- 'Blog' => raw_info['blog'],
35
- },
19
+ 'accounts' => raw_info['accounts']
36
20
  }
37
21
  end
38
22
 
39
23
  extra do
40
- {:raw_info => raw_info}
24
+ {
25
+ :raw_info => raw_info
26
+ }
41
27
  end
42
28
 
43
29
  def raw_info
44
- # access_token.options[:mode] = :query
45
- # @raw_info ||= access_token.get('/user').parsed
46
- @raw_info = {}
47
- end
48
-
49
- def email
50
- raw_info['email'] || (email_access_allowed? ? emails.first : nil)
51
- end
52
-
53
- def emails
54
30
  access_token.options[:mode] = :query
55
- @emails ||= access_token.get('/user/emails').parsed
56
- end
57
-
58
- def email_access_allowed?
59
- options['scope'] && !(options['scope'] == 'public')
31
+ @raw_info ||= access_token.get('/api/authorization.json').parsed
60
32
  end
61
33
 
62
34
  end
63
35
  end
64
36
  end
65
37
 
66
- OmniAuth.config.add_camelization 'workxp', 'Workxp'
38
+ OmniAuth.config.add_camelization 'workxp', 'WorkXP'
@@ -4,8 +4,8 @@ require File.expand_path('../lib/omniauth-workxp/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "omniauth-workxp"
6
6
  gem.version = Omniauth::Workxp::VERSION
7
- gem.authors = ["liuqi"]
8
- gem.email = ["keyboarder5211@gmail.com"]
7
+ gem.authors = ["liuqi", "yuanping"]
8
+ gem.email = ["keyboarder5211@gmail.com", "yp.xjgz@gmail.com"]
9
9
  gem.description = %q{Official OmniAuth strategy for Workxp.}
10
10
  gem.summary = %q{Official OmniAuth strategy for Workxp.}
11
11
  gem.homepage = "https://github.com/liuqi1024/omniauth-workxp"
@@ -15,8 +15,8 @@ Gem::Specification.new do |gem|
15
15
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
16
  gem.require_paths = ["lib"]
17
17
 
18
- gem.add_dependency 'omniauth', '~> 1.0'
19
- gem.add_dependency 'omniauth-oauth2', '~> 1.1'
18
+ gem.add_dependency 'omniauth', '~> 1.2'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.2'
20
20
  gem.add_development_dependency 'rspec', '~> 2.7'
21
21
  gem.add_development_dependency 'rack-test'
22
22
  gem.add_development_dependency 'simplecov'
metadata CHANGED
@@ -1,52 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-workxp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - liuqi
8
+ - yuanping
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-03 00:00:00.000000000 Z
12
+ date: 2014-09-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: omniauth
16
16
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
17
  requirements:
19
18
  - - ~>
20
19
  - !ruby/object:Gem::Version
21
- version: '1.0'
20
+ version: '1.2'
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ~>
28
26
  - !ruby/object:Gem::Version
29
- version: '1.0'
27
+ version: '1.2'
30
28
  - !ruby/object:Gem::Dependency
31
29
  name: omniauth-oauth2
32
30
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
31
  requirements:
35
32
  - - ~>
36
33
  - !ruby/object:Gem::Version
37
- version: '1.1'
34
+ version: '1.2'
38
35
  type: :runtime
39
36
  prerelease: false
40
37
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
38
  requirements:
43
39
  - - ~>
44
40
  - !ruby/object:Gem::Version
45
- version: '1.1'
41
+ version: '1.2'
46
42
  - !ruby/object:Gem::Dependency
47
43
  name: rspec
48
44
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
45
  requirements:
51
46
  - - ~>
52
47
  - !ruby/object:Gem::Version
@@ -54,7 +49,6 @@ dependencies:
54
49
  type: :development
55
50
  prerelease: false
56
51
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
52
  requirements:
59
53
  - - ~>
60
54
  - !ruby/object:Gem::Version
@@ -62,7 +56,6 @@ dependencies:
62
56
  - !ruby/object:Gem::Dependency
63
57
  name: rack-test
64
58
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
59
  requirements:
67
60
  - - ! '>='
68
61
  - !ruby/object:Gem::Version
@@ -70,7 +63,6 @@ dependencies:
70
63
  type: :development
71
64
  prerelease: false
72
65
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
66
  requirements:
75
67
  - - ! '>='
76
68
  - !ruby/object:Gem::Version
@@ -78,7 +70,6 @@ dependencies:
78
70
  - !ruby/object:Gem::Dependency
79
71
  name: simplecov
80
72
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
73
  requirements:
83
74
  - - ! '>='
84
75
  - !ruby/object:Gem::Version
@@ -86,7 +77,6 @@ dependencies:
86
77
  type: :development
87
78
  prerelease: false
88
79
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
80
  requirements:
91
81
  - - ! '>='
92
82
  - !ruby/object:Gem::Version
@@ -94,7 +84,6 @@ dependencies:
94
84
  - !ruby/object:Gem::Dependency
95
85
  name: webmock
96
86
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
87
  requirements:
99
88
  - - ! '>='
100
89
  - !ruby/object:Gem::Version
@@ -102,7 +91,6 @@ dependencies:
102
91
  type: :development
103
92
  prerelease: false
104
93
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
94
  requirements:
107
95
  - - ! '>='
108
96
  - !ruby/object:Gem::Version
@@ -110,14 +98,13 @@ dependencies:
110
98
  description: Official OmniAuth strategy for Workxp.
111
99
  email:
112
100
  - keyboarder5211@gmail.com
101
+ - yp.xjgz@gmail.com
113
102
  executables: []
114
103
  extensions: []
115
104
  extra_rdoc_files: []
116
105
  files:
117
- - .DS_Store
118
106
  - .gitignore
119
107
  - Gemfile
120
- - Gemfile.lock
121
108
  - LICENSE.txt
122
109
  - README.md
123
110
  - Rakefile
@@ -126,29 +113,27 @@ files:
126
113
  - lib/omniauth-workxp/version.rb
127
114
  - lib/omniauth/strategies/workxp.rb
128
115
  - omniauth-workxp.gemspec
129
- - pkg/omniauth-workxp-0.0.1.gem
130
116
  homepage: https://github.com/liuqi1024/omniauth-workxp
131
117
  licenses: []
118
+ metadata: {}
132
119
  post_install_message:
133
120
  rdoc_options: []
134
121
  require_paths:
135
122
  - lib
136
123
  required_ruby_version: !ruby/object:Gem::Requirement
137
- none: false
138
124
  requirements:
139
125
  - - ! '>='
140
126
  - !ruby/object:Gem::Version
141
127
  version: '0'
142
128
  required_rubygems_version: !ruby/object:Gem::Requirement
143
- none: false
144
129
  requirements:
145
130
  - - ! '>='
146
131
  - !ruby/object:Gem::Version
147
132
  version: '0'
148
133
  requirements: []
149
134
  rubyforge_project:
150
- rubygems_version: 1.8.24
135
+ rubygems_version: 2.1.11
151
136
  signing_key:
152
- specification_version: 3
137
+ specification_version: 4
153
138
  summary: Official OmniAuth strategy for Workxp.
154
139
  test_files: []
data/.DS_Store DELETED
Binary file
data/Gemfile.lock DELETED
@@ -1,61 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- omniauth-workxp (0.0.2)
5
- omniauth (~> 1.0)
6
- omniauth-oauth2 (~> 1.1)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- addressable (2.3.2)
12
- crack (0.3.1)
13
- diff-lcs (1.1.3)
14
- faraday (0.8.4)
15
- multipart-post (~> 1.1)
16
- hashie (1.2.0)
17
- httpauth (0.2.0)
18
- jwt (0.1.5)
19
- multi_json (>= 1.0)
20
- multi_json (1.4.0)
21
- multipart-post (1.1.5)
22
- oauth2 (0.8.0)
23
- faraday (~> 0.8)
24
- httpauth (~> 0.1)
25
- jwt (~> 0.1.4)
26
- multi_json (~> 1.0)
27
- rack (~> 1.2)
28
- omniauth (1.1.1)
29
- hashie (~> 1.2)
30
- rack
31
- omniauth-oauth2 (1.1.1)
32
- oauth2 (~> 0.8.0)
33
- omniauth (~> 1.0)
34
- rack (1.4.1)
35
- rack-test (0.6.2)
36
- rack (>= 1.0)
37
- rspec (2.12.0)
38
- rspec-core (~> 2.12.0)
39
- rspec-expectations (~> 2.12.0)
40
- rspec-mocks (~> 2.12.0)
41
- rspec-core (2.12.1)
42
- rspec-expectations (2.12.0)
43
- diff-lcs (~> 1.1.3)
44
- rspec-mocks (2.12.0)
45
- simplecov (0.7.1)
46
- multi_json (~> 1.0)
47
- simplecov-html (~> 0.7.1)
48
- simplecov-html (0.7.1)
49
- webmock (1.9.0)
50
- addressable (>= 2.2.7)
51
- crack (>= 0.1.7)
52
-
53
- PLATFORMS
54
- ruby
55
-
56
- DEPENDENCIES
57
- omniauth-workxp!
58
- rack-test
59
- rspec (~> 2.7)
60
- simplecov
61
- webmock
Binary file