omniauth-gitcafe-oauth2 0.1.0

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d0455a06b4939cf9da09b364cb0abd197017208a
4
+ data.tar.gz: 64ed5dd6964c16b2fbf39a550dfb70e6d2666683
5
+ SHA512:
6
+ metadata.gz: b066f89be6c7b113b41fe5b4625614b677f0e56fd78620c8b147fc82454ecbf06f6d9ee6c3884d4e02ed2550609371f46d67a409c41d29074923f29f60268fdf
7
+ data.tar.gz: 963d9810b4c96a947091055b538b3bc4a26b4d46af94d4139c323ce535977d649ea390e842336c1749f60625c02f7a729717bcffe886b22c4fda3d7b4cc9e82b
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .bundle
2
+ *.swp
3
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # OmniAuth GitCafe OAuth2
2
+
3
+ GitCafe OAuth2 Strategy for OmniAuth 1.0.
4
+
5
+ ## Installing
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'omniauth-gitcafe-oauth2'
11
+ ```
12
+
13
+ Then `bundle install`.
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-gitcafe-oauth2
18
+
19
+ ## Usage
20
+
21
+ `OmniAuth::Strategies::GitCafe` is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.
22
+
23
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
24
+
25
+ ```ruby
26
+ Rails.application.config.middleware.use OmniAuth::Builder do
27
+ provider :gitcafe, ENV['GITCAFE_KEY'], ENV['GITCAFE_SECRET'], scope: "read, public"
28
+ end
29
+ ```
30
+
31
+ ## Authentication Hash
32
+
33
+ Here's an example *Authentication Hash* available in `request.env['omniauth.auth']`:
34
+
35
+ ```ruby
36
+ {
37
+ "provider"=>"gitcafe",
38
+ "uid"=>"548e8630c54d2d29f6000002",
39
+ "info"=>{
40
+ "id"=>"548e8630c54d2d29f6000002",
41
+ "email"=>"test@example.com",
42
+ "username"=>"test",
43
+ "fullname"=>nil,
44
+ "location"=>nil,
45
+ "url"=>nil,
46
+ "avatar_url"=>"http://gravatar.com/avatar/76e23ac36354d843ba34ea458c19f648?default=identicon&size=60", "company"=>nil, "public_repos"=>5,
47
+ "followers"=>0,
48
+ "following"=>0,
49
+ "name"=>"test@example.com"
50
+ },
51
+ "credentials"=>{
52
+ "token"=>"d1aa55539cf7d732ae81f6663080f294bb44dc179d77039166071ab44a268d01",
53
+ "expires"=>false
54
+ },
55
+ "extra"=>{
56
+ "raw_info"=>
57
+ {
58
+ "id"=>"548e8630c54d2d29f6000002",
59
+ "username"=>"test",
60
+ "email"=>"test@example.com",
61
+ "fullname"=>nil,
62
+ "location"=>nil,
63
+ "url"=>nil,
64
+ "avatar_url"=>"http://gravatar.com/avatar/76e23ac36354d843ba34ea458c19f648?default=identicon&size=60", "company"=>nil,
65
+ "public_repos"=>5,
66
+ "followers"=>0,
67
+ "following"=>0,
68
+ "created_at"=>"2014-12-15T06:56:48Z",
69
+ "updated_at"=>"2015-01-26T16:41:02Z"
70
+ }
71
+ }
72
+ }
73
+ ```
74
+
75
+ ## Contributing
76
+
77
+ 1. Fork it
78
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
79
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
80
+ 4. Push to the branch (`git push origin my-new-feature`)
81
+ 5. Create new Pull Request
82
+
83
+ ## License
84
+
85
+ Copyright (c) 2012
86
+
87
+ 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:
88
+
89
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
90
+
91
+ 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,48 @@
1
+ require "omniauth-oauth2"
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class GitCafe < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ :site => "https://api.gitcafe.com",
8
+ :authorize_url => "/oauth/authorize",
9
+ }
10
+
11
+ option :token_params, {
12
+ :parse => :json
13
+ }
14
+
15
+ uid do
16
+ raw_info['id']
17
+ end
18
+
19
+ info do
20
+ {
21
+ :id => raw_info['id'],
22
+ :email => raw_info['email'],
23
+ :username => raw_info['username'],
24
+ :fullname => raw_info['fullname'],
25
+ :location => raw_info['location'],
26
+ :url => raw_info['url'],
27
+ :avatar_url => raw_info['avatar_url'],
28
+ :company => raw_info['company'],
29
+ :public_repos => raw_info['public_repos'],
30
+ :followers => raw_info['followers'],
31
+ :following => raw_info['following']
32
+ }
33
+ end
34
+
35
+ extra do
36
+ {
37
+ :raw_info => raw_info
38
+ }
39
+ end
40
+
41
+ def raw_info
42
+ @raw_info ||= access_token.get("/api/v1/user.json").parsed
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ OmniAuth.config.add_camelization "gitcafe", "GitCafe"
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module GitCafeOauth2
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-gitcafe-oauth2/version"
2
+ require 'omniauth/strategies/gitcafe'
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-gitcafe-oauth2/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = "Xyu Wang"
6
+ gem.email = "awsam@gitcafe.com"
7
+ gem.description = %q{OmniAuth Oauth2 strategy for gitcafe.com.}
8
+ gem.summary = %q{OmniAuth Oauth2 strategy for gitcafe.com.}
9
+ gem.homepage = "https://gitcafe.com/awsam/omniauth-gitcafe-oauth2"
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-gitcafe-oauth2"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::GitCafeOauth2::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0'
20
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-gitcafe-oauth2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Xyu Wang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description: OmniAuth Oauth2 strategy for gitcafe.com.
42
+ email: awsam@gitcafe.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ".gitignore"
48
+ - Gemfile
49
+ - README.md
50
+ - lib/omniauth-gitcafe-oauth2.rb
51
+ - lib/omniauth-gitcafe-oauth2/version.rb
52
+ - lib/omniauth/strategies/gitcafe.rb
53
+ - omniauth-gitcafe-oauth2.gemspec
54
+ homepage: https://gitcafe.com/awsam/omniauth-gitcafe-oauth2
55
+ licenses: []
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.2.2
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: OmniAuth Oauth2 strategy for gitcafe.com.
77
+ test_files: []