omniauth-twitch-forceverify 1.0.2
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +69 -0
- data/Rakefile +1 -0
- data/lib/omniauth-twitch-forceverify.rb +1 -0
- data/lib/omniauth/strategies/twitch.rb +89 -0
- data/lib/omniauth/twitch.rb +2 -0
- data/lib/omniauth/twitch/version.rb +5 -0
- data/omniauth-twitch-forceverify.gemspec +24 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4fc18a2a553a19cf41c35038627149c239df76baaa87764f5ea3b0eeffbccef2
|
4
|
+
data.tar.gz: eb5806535c0f60cfc471df52962514524c3fa957b1dce85aa6983442eaff0b1a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 472dafe1cbf983e06894600257546930b46595c7f36b477e02affb146aac2b6f53ab3801cad70194c42d678cb4547659c80b1352e516a78ac1851c584fa88b9e
|
7
|
+
data.tar.gz: ff591b1c3c55ddea8cec092f94c9f2da85338fdbffe53925be98059ca3c8003091caa4a94beb15e5189292d967c0f03fab893afda5f0d9aea1ae9ba2642f3fac
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 Jonathan Gertig
|
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,69 @@
|
|
1
|
+
[](http://badge.fury.io/rb/omniauth-twitch)
|
2
|
+
|
3
|
+
# OmniAuth::Twitch
|
4
|
+
|
5
|
+
A OmniAuth strategy for Twitch recently updated to helix api
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'omniauth-twitch'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install omniauth-twitch
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Here's an example for 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 :twitch, ENV["TWITCH_CLIENT_ID"], ENV["TWITCH_CLIENT_SECRET"]
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
## Auth Hash
|
32
|
+
|
33
|
+
Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
{
|
37
|
+
provider: 'twitch',
|
38
|
+
uid: '12345678',
|
39
|
+
info: {
|
40
|
+
name: 'JohnDoe',
|
41
|
+
email: 'johndoe@gmail.com',
|
42
|
+
nickname: 'johndoe',
|
43
|
+
description: 'My channel.',
|
44
|
+
image: 'http://static-cdn.jtvnw.net/jtv-static/404_preview-300x300.png',
|
45
|
+
urls: {
|
46
|
+
Twitch: 'http://www.twitch.tv/johndoe'
|
47
|
+
}
|
48
|
+
},
|
49
|
+
credentials: {
|
50
|
+
token: 'asdfghjklasdfghjklasdfghjkl', # OAuth 2.0 access_token, which you may wish to store
|
51
|
+
expires: false # this will always be false,
|
52
|
+
refresh_token: 'asdschbjh24h23yfsjfhbsjdc3a' # OAuth 2.0 refresh token, to renew the access token when it expires
|
53
|
+
},
|
54
|
+
extra: {
|
55
|
+
raw_info: {
|
56
|
+
display_name: 'JohnDoe',
|
57
|
+
id: '12345678',
|
58
|
+
login: 'johndoe',
|
59
|
+
type: '',
|
60
|
+
broadcaster_type: '',
|
61
|
+
description: 'My channel.',
|
62
|
+
profile_image_url: 'https://static-cdn.jtvnw.net/user-default-pictures/0ecbb6c3-fecb-4016-8115-aa467b7c36ed-profile_image-300x300.jpg',
|
63
|
+
offline_image_url: '',
|
64
|
+
view_count: 100500,
|
65
|
+
email: 'johdoe@gmail.com'
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/twitch'
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Twitch < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_SCOPE = "user:read:email".freeze
|
7
|
+
|
8
|
+
option :name, "twitch"
|
9
|
+
|
10
|
+
option :client_options, {
|
11
|
+
site: "https://id.twitch.tv",
|
12
|
+
authorize_url: "/oauth2/authorize",
|
13
|
+
token_url: "/oauth2/token"
|
14
|
+
}
|
15
|
+
|
16
|
+
option :access_token_options, {
|
17
|
+
header_format: "Bearer %s",
|
18
|
+
param_name: "access_token"
|
19
|
+
}
|
20
|
+
|
21
|
+
option :authorize_options, [:scope]
|
22
|
+
|
23
|
+
credentials do
|
24
|
+
hash = { "token" => access_token.token }
|
25
|
+
if access_token.refresh_token
|
26
|
+
hash["refresh_token"] = access_token.refresh_token
|
27
|
+
end
|
28
|
+
hash["expires_at"] = access_token.expires_at if access_token.expires?
|
29
|
+
hash["expires"] = access_token.expires?
|
30
|
+
hash
|
31
|
+
end
|
32
|
+
|
33
|
+
uid { raw_info["id"] }
|
34
|
+
|
35
|
+
info do
|
36
|
+
{
|
37
|
+
name: raw_info["display_name"],
|
38
|
+
email: raw_info["email"],
|
39
|
+
nickname: raw_info["login"],
|
40
|
+
description: raw_info["description"],
|
41
|
+
image: raw_info["profile_image_url"],
|
42
|
+
urls: { Twitch: "http://www.twitch.tv/#{raw_info['login']}" }
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
extra do
|
47
|
+
{
|
48
|
+
raw_info: raw_info
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def raw_info
|
53
|
+
@raw_info ||=
|
54
|
+
access_token.get("https://api.twitch.tv/helix/users").parsed.
|
55
|
+
fetch("data").fetch(0)
|
56
|
+
end
|
57
|
+
|
58
|
+
def build_access_token
|
59
|
+
super.tap do |token|
|
60
|
+
token.options.merge!(access_token_options)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def access_token_options
|
65
|
+
options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
|
66
|
+
end
|
67
|
+
|
68
|
+
def callback_url
|
69
|
+
return options[:redirect_uri] unless options[:redirect_uri].nil?
|
70
|
+
full_host + script_name + callback_path
|
71
|
+
end
|
72
|
+
|
73
|
+
def authorize_params
|
74
|
+
super.tap do |params|
|
75
|
+
options[:authorize_options].each do |k|
|
76
|
+
params[k] = request.params[k.to_s] unless [nil, ''].include?(request.params[k.to_s])
|
77
|
+
end
|
78
|
+
params[:scope] = params[:scope] || DEFAULT_SCOPE
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
alias :old_request_phase :request_phase
|
83
|
+
def request_phase
|
84
|
+
options[:authorize_params].merge!(:force_verify => 'true')
|
85
|
+
old_request_phase
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth/twitch/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omniauth-twitch-forceverify"
|
8
|
+
spec.version = OmniAuth::Twitch::VERSION
|
9
|
+
spec.authors = ["Orig Jonathan Gertig (Webtheory) and William Holt (Webtheory) - moded Crosseye Jack"]
|
10
|
+
spec.email = ["dan@crosseyejack.com Orig jcgertig@gmail.com or sithtoast@gmail.com"]
|
11
|
+
spec.summary = 'Twitch OAuth2 Strategy for OmniAuth with force verify bolted onto it'
|
12
|
+
spec.homepage = "https://github.com/CrosseyeJack/omniauth-twitch"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-twitch-forceverify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Orig Jonathan Gertig (Webtheory) and William Holt (Webtheory) - moded Crosseye Jack
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-09-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth-oauth2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
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
|
+
description:
|
56
|
+
email:
|
57
|
+
- dan@crosseyejack.com Orig jcgertig@gmail.com or sithtoast@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/omniauth-twitch-forceverify.rb
|
68
|
+
- lib/omniauth/strategies/twitch.rb
|
69
|
+
- lib/omniauth/twitch.rb
|
70
|
+
- lib/omniauth/twitch/version.rb
|
71
|
+
- omniauth-twitch-forceverify.gemspec
|
72
|
+
homepage: https://github.com/CrosseyeJack/omniauth-twitch
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.7.6
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Twitch OAuth2 Strategy for OmniAuth with force verify bolted onto it
|
96
|
+
test_files: []
|