omniauth-workxp 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-workxp.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,14 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-workxp (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ ruby
12
+
13
+ DEPENDENCIES
14
+ omniauth-workxp!
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 liuqi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ =======
2
+ omniauth-workxp
3
+ ===============
4
+
5
+ Official OmniAuth strategy for Workxp.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'omniauth-workxp'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-workxp
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
32
+
33
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,65 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Workxp < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ :site => 'https://api.github.com',
8
+ :authorize_url => 'https://github.com/login/oauth/authorize',
9
+ :token_url => 'https://github.com/login/oauth/access_token'
10
+ }
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 }
25
+
26
+ info do
27
+ {
28
+ 'nickname' => raw_info['login'],
29
+ 'email' => email,
30
+ 'name' => raw_info['name'],
31
+ 'image' => raw_info['avatar_url'],
32
+ 'urls' => {
33
+ 'GitHub' => "https://github.com/#{raw_info['login']}",
34
+ 'Blog' => raw_info['blog'],
35
+ },
36
+ }
37
+ end
38
+
39
+ extra do
40
+ {:raw_info => raw_info}
41
+ end
42
+
43
+ def raw_info
44
+ access_token.options[:mode] = :query
45
+ @raw_info ||= access_token.get('/user').parsed
46
+ end
47
+
48
+ def email
49
+ raw_info['email'] || (email_access_allowed? ? emails.first : nil)
50
+ end
51
+
52
+ def emails
53
+ access_token.options[:mode] = :query
54
+ @emails ||= access_token.get('/user/emails').parsed
55
+ end
56
+
57
+ def email_access_allowed?
58
+ options['scope'] && !(options['scope'] == 'public')
59
+ end
60
+
61
+ end
62
+ end
63
+ end
64
+
65
+ OmniAuth.config.add_camelization 'workxp', 'Workxp'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Workxp
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "omniauth-workxp/version"
2
+ require 'omniauth/strategies/workxp'
3
+
4
+ module Omniauth
5
+ module Workxp
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-workxp/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "omniauth-workxp"
8
+ gem.version = Omniauth::Workxp::VERSION
9
+ gem.authors = ["liuqi"]
10
+ gem.email = ["keyboarder5211@gmail.com"]
11
+ gem.description = %q{Official OmniAuth strategy for Workxp.}
12
+ gem.summary = %q{Official OmniAuth strategy for Workxp.}
13
+ gem.homepage = "https://github.com/liuqi1024/omniauth-workxp"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
Binary file
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-workxp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - liuqi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-03 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Official OmniAuth strategy for Workxp.
15
+ email:
16
+ - keyboarder5211@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .DS_Store
22
+ - .gitignore
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - lib/.DS_Store
29
+ - lib/omniauth-workxp.rb
30
+ - lib/omniauth-workxp/version.rb
31
+ - lib/omniauth/strategies/workxp.rb
32
+ - omniauth-workxp.gemspec
33
+ - pkg/omniauth-workxp-0.0.1.gem
34
+ homepage: https://github.com/liuqi1024/omniauth-workxp
35
+ licenses: []
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 1.8.24
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Official OmniAuth strategy for Workxp.
58
+ test_files: []