omniauth-sportngin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0abd3130d4adc1fcda5101c5eb5a2248ebee067e
4
+ data.tar.gz: b573d284a264ddeed4c70a6c03aa1a4191f2c0f2
5
+ SHA512:
6
+ metadata.gz: 4db8e656227a27df76ed8c6e283f0a376b0cf4b6ec11f2fe4f3dcbaf06739f6e2cdd989ec642fb8a40aca704797f1a8a3e6f64b4e793a6809456d9c3b811a385
7
+ data.tar.gz: 2374cfae773d29a9968eed9595c189dc22e866785fd0ab5bfa56da11416f22feb6052f1222fe02b26d9a672e8158fbba51689cd9441835ea7b9f17b3bc1c3d1a
@@ -0,0 +1,10 @@
1
+ *.gem
2
+ .bundle
3
+ .rspec
4
+ /Gemfile.lock
5
+ pkg/*
6
+ .powenv
7
+ tmp
8
+ bin
9
+ .idea
10
+ /coverage/
@@ -0,0 +1,2 @@
1
+ deploy_branch: master
2
+ github_repo: sportngin/omniauth-ngin
@@ -0,0 +1 @@
1
+ omniauth-ngin
@@ -0,0 +1 @@
1
+ 2.2.2
@@ -0,0 +1,16 @@
1
+ sudo: false
2
+ branches:
3
+ only:
4
+ - master
5
+ notifications:
6
+ slack:
7
+ secure: eWKTZAxUxwp/G34aHNtNlaQtlkyUwhSMntDQ3mBERgFhEEd9ofmKlGHPDMHMtFwjRdhDA3gj5poYv4UjT05BlyU0SKlXvCpxjaMH07FABVtdXLNmNmX3v+gwV4DL5MzPl6qkPQuZH/1LGXXg6nI846GDhQ5uD5ox5BFZ82ns69M=
8
+ after_script:
9
+ - uptime && vmstat -S M
10
+ language: ruby
11
+ rvm:
12
+ - 1.9.3
13
+ - 2.0.0
14
+ - 2.1
15
+ - 2.2
16
+ cache: bundler
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'jruby-openssl', :platform => :jruby
@@ -0,0 +1,107 @@
1
+ SportNgin OAuth2 Strategy for OmniAuth 1.0.
2
+
3
+ Supports connection with Sport Ngin users.
4
+
5
+ ## Installing
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'omniauth-sportngin'
11
+ ```
12
+
13
+ Then `bundle install`.
14
+
15
+ ## Usage
16
+
17
+ `OmniAuth::Strategies::SportNgin` is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.
18
+
19
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
20
+
21
+ ```ruby
22
+ config.omniauth :sportngin, key, secret
23
+ ```
24
+
25
+ ### Custom Callback URL/Path
26
+
27
+ You can (and should) set a custom `callback_url` or `callback_path` option to override the default value. See [OmniAuth::Strategy#callback_url](https://github.com/intridea/omniauth/blob/master/lib/omniauth/strategy.rb#L411) for more details on the default.
28
+
29
+ ## Auth Hash
30
+
31
+ Here's an example Auth Hash available in `request.env['omniauth.auth']`:
32
+
33
+ ```ruby
34
+ {
35
+ provider: "sportngin",
36
+ uid: 1,
37
+ info: {
38
+ name: "Test test",
39
+ user_name: "admin"
40
+ },
41
+ credentials: {
42
+ access_token: "access-token",
43
+ expires: true,
44
+ expires_at: 1434161779,
45
+ refresh_token: "refresh-token",
46
+ token="access-token"
47
+ },
48
+ extra: {
49
+ raw_info: {
50
+ metadata: {
51
+ current_user: {
52
+ id: 1,
53
+ first_name: "Test",
54
+ last_name: "test",
55
+ user_name: "admin"
56
+ }
57
+ },
58
+ result: {
59
+ client: {
60
+ id: 17,
61
+ name: "your-app"
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ ```
68
+
69
+ The precise information available may depend on the permissions which you request and are granted
70
+ as a Client Application.
71
+
72
+ ## Token Expiry
73
+ ### Server-Side Flow
74
+
75
+ Access Tokens last 30 minutes. Refresh Tokens last one month.
76
+
77
+ ## TODO
78
+
79
+ *Still needs implemented for SportNgin-Omniauth, though this is how Facebook does it*
80
+
81
+ You can configure several options, which you pass in to the `provider` method via a `Hash`:
82
+
83
+ * `scope`: A comma-separated list of permissions you want to request from the user. See the Facebook docs for a full list of available permissions: http://developers.facebook.com/docs/reference/api/permissions. Default: `email`
84
+ * `display`: The display context to show the authentication page. Options are: `page`, `popup` and `touch`. Read the Facebook docs for more details: https://developers.facebook.com/docs/reference/dialogs/oauth/. Default: `page`
85
+ * `auth_type`: Optionally specifies the requested authentication features as a comma-separated list, as per https://developers.facebook.com/docs/authentication/reauthentication/.
86
+ Valid values are `https` (checks for the presence of the secure cookie and asks for re-authentication if it is not present), and `reauthenticate` (asks the user to re-authenticate unconditionally). Default is `nil`.
87
+ * `secure_image_url`: Set to `true` to use https for the avatar image url returned in the auth hash. Default is `false`.
88
+ * `image_size`: Set the size for the returned image url in the auth hash. Valid options are `square` (50x50), `small` (50 pixels wide, variable height), `normal` (100 pixels wide, variable height), or `large` (about 200 pixels wide, variable height). Default is `square` (50x50).
89
+
90
+ For example, to request `email`, `user_birthday` and `read_stream` permissions and display the authentication page in a popup window:
91
+
92
+ ```ruby
93
+ Rails.application.config.middleware.use OmniAuth::Builder do
94
+ provider :sportngin, ENV['KEY'], ENV['SECRET'],
95
+ :scope => 'email,user_birthday,read_stream', :display => 'popup'
96
+ end
97
+ ```
98
+
99
+ ## License
100
+
101
+ Copyright (c) 2012 by Sport Ngin
102
+
103
+ 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:
104
+
105
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
106
+
107
+ 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,13 @@
1
+ #!/usr/bin/env rake
2
+ require "rspec/core/rake_task"
3
+ require "bundler/gem_tasks"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ namespace :spec do
8
+ RSpec::Core::RakeTask.new(:docs) do |t|
9
+ t.rspec_opts = ["--format doc"]
10
+ end
11
+ end
12
+
13
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require 'omniauth/strategies/sportngin'
2
+ require 'omniauth-sportngin/version'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module SportNgin
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,39 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class SportNgin < OAuth2
7
+ option :name, "sportngin"
8
+
9
+ option :client_options, {
10
+ site: 'https://api.sportngin.com',
11
+ authorize_url: 'https://user.sportngin.com/oauth/authorize',
12
+ token_url: 'https://api.sportngin.com/oauth/token',
13
+ me_url: 'https://api.sportngin.com/oauth/me'
14
+ }
15
+
16
+ uid { user['id'] }
17
+
18
+ info do
19
+ {
20
+ 'user_name' => user['user_name'],
21
+ 'name' => "#{user['first_name']} #{user['last_name']}"
22
+ }
23
+ end
24
+
25
+ extra do
26
+ { :raw_info => raw_info }
27
+ end
28
+
29
+ def raw_info
30
+ access_token.options[:parse] = :json
31
+ @raw_info ||= access_token.get(options.client_options.me_url).parsed
32
+ end
33
+
34
+ def user
35
+ raw_info["result"]["user"]
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'omniauth-sportngin/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'omniauth-sportngin'
7
+ s.version = OmniAuth::SportNgin::VERSION
8
+ s.authors = ['Jon Phenow']
9
+ s.email = ['jon.phenow@sportngin.com']
10
+ s.summary = 'Sport Ngin strategy for OmniAuth'
11
+ s.homepage = 'https://github.com/sportngin/omniauth-sportngin'
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
16
+ s.require_paths = ['lib']
17
+
18
+ s.add_dependency 'omniauth', '~> 1.0'
19
+ s.add_dependency 'omniauth-oauth2', '~> 1.0'
20
+
21
+ s.add_development_dependency 'rack-test'
22
+ s.add_development_dependency 'simplecov'
23
+ s.add_development_dependency 'webmock'
24
+ s.add_development_dependency 'rspec'
25
+ s.add_development_dependency 'rake'
26
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::SportNgin do
4
+ subject { described_class.new({}) }
5
+
6
+ context "client options" do
7
+ it 'should have correct site' do
8
+ expect(subject.options.client_options.site).to eq("https://api.sportngin.com")
9
+ end
10
+
11
+ it 'should have correct authorize url' do
12
+ expect(subject.options.client_options.authorize_url).to eq('https://user.sportngin.com/oauth/authorize')
13
+ end
14
+
15
+ it 'should have correct token url' do
16
+ expect(subject.options.client_options.token_url).to eq('https://api.sportngin.com/oauth/token')
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-sportngin'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, type: :strategy
15
+ end
16
+
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-sportngin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jon Phenow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-18 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
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description:
112
+ email:
113
+ - jon.phenow@sportngin.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".octopolo.yml"
120
+ - ".ruby-gemset"
121
+ - ".ruby-version"
122
+ - ".travis.yml"
123
+ - Gemfile
124
+ - README.md
125
+ - Rakefile
126
+ - lib/omniauth-sportngin.rb
127
+ - lib/omniauth-sportngin/version.rb
128
+ - lib/omniauth/strategies/sportngin.rb
129
+ - omniauth-sportngin.gemspec
130
+ - spec/omniauth/strategies/sportngin_spec.rb
131
+ - spec/spec_helper.rb
132
+ homepage: https://github.com/sportngin/omniauth-sportngin
133
+ licenses: []
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.4.7
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Sport Ngin strategy for OmniAuth
155
+ test_files:
156
+ - spec/omniauth/strategies/sportngin_spec.rb
157
+ - spec/spec_helper.rb