omniauth-mingdao 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # OmniAuth mingdao
2
+
3
+ ## Installing
4
+
5
+ Add to your `Gemfile`:
6
+
7
+ ```ruby
8
+ gem 'omniauth-mingdao'
9
+ ```
10
+
11
+ Then `bundle install`.
12
+
13
+ Or install it yourself as:
14
+
15
+ $ gem install omniauth-mingdao
16
+
17
+ ## Usage
18
+
19
+ `OmniAuth::Strategies::Mingdao` is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.
20
+
21
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :mingdao, ENV['MINGDAO_KEY'], ENV['MINGDAO_SECRET']
26
+ end
27
+ ```
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
36
+
37
+ ## License
38
+
39
+ Copyright (c) 2012 by Yan Wang
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
42
+
43
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require "omniauth-mingdao/version"
2
+ require 'omniauth/strategies/mingdao'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Mingdao
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -0,0 +1,54 @@
1
+ require "omniauth-oauth2"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Mingdao < OmniAuth::Strategies::OAuth2
6
+ option :name, "mingdao"
7
+
8
+ option :client_options, {
9
+ :site => "https://api.mingdao.com",
10
+ :authorize_url => "/oauth2/authorize",
11
+ :token_url => "/oauth2/access_token",
12
+ :token_method =>:get
13
+ }
14
+
15
+ option :token_params, {
16
+ :parse => :json,
17
+ :format => :json
18
+ }
19
+
20
+ uid do
21
+ raw_info['id']
22
+ end
23
+
24
+ info do
25
+ {
26
+ :nickname => raw_info['name'],
27
+ :name => raw_info['name'],
28
+ :image => raw_info['avstar'],
29
+ :email => raw_info['email']
30
+ }
31
+ end
32
+
33
+ extra do
34
+ {
35
+ :raw_info => raw_info
36
+ }
37
+ end
38
+
39
+ def raw_info
40
+ access_token.options[:mode] = :query
41
+ access_token.options[:parse] = :json
42
+ access_token.options[:param_name] = 'access_token'
43
+
44
+ @raw_info ||= client.request(:get, "https://api.mingdao.com/passport/detail", :params => {
45
+ :format => :json,
46
+ :access_token => access_token.token
47
+ }, :parse => :json).parsed['user']
48
+ end
49
+
50
+ end
51
+ end
52
+ end
53
+
54
+ OmniAuth.config.add_camelization "mingdao", "Mingdao"
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-mingdao/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = "Yan Wang"
6
+ gem.email = "wangyan87@gmail.com"
7
+ gem.description = %q{OmniAuth Oauth2 strategy for mingdao.}
8
+ gem.summary = %q{OmniAuth Oauth2 strategy for mingdao.}
9
+ gem.homepage = "https://github.com/iamroody/omniauth-mingdao"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "omniauth-mingdao"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::Mingdao::VERSION
17
+ gem.license = 'MIT'
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0'
20
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-mingdao
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
+ platform: ruby
11
+ authors:
12
+ - Yan Wang
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2013-08-17 00:00:00 +08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: omniauth
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 0
30
+ version: "1.0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: omniauth-oauth2
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 1
42
+ - 0
43
+ version: "1.0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ description: OmniAuth Oauth2 strategy for mingdao.
47
+ email: wangyan87@gmail.com
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ extra_rdoc_files: []
53
+
54
+ files:
55
+ - Gemfile
56
+ - README.md
57
+ - lib/omniauth-mingdao.rb
58
+ - lib/omniauth-mingdao/version.rb
59
+ - lib/omniauth/strategies/mingdao.rb
60
+ - omniauth-mingdao.gemspec
61
+ has_rdoc: true
62
+ homepage: https://github.com/iamroody/omniauth-mingdao
63
+ licenses:
64
+ - MIT
65
+ post_install_message:
66
+ rdoc_options: []
67
+
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project:
87
+ rubygems_version: 1.3.6
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: OmniAuth Oauth2 strategy for mingdao.
91
+ test_files: []
92
+