omniauth-mixer 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1399d7405d994dfdaeaa27e34a9bf1ee33cec5e5
4
+ data.tar.gz: 75fbfe33d0828d9cbd31e390005e6d404bf5470e
5
+ SHA512:
6
+ metadata.gz: 8e5dcc46fdc708bf72d7ed0f33105aca7f9bfe33566b87c17e19f801f8f5189291667ba7476d46342585262f8caaf590cbef707698387875de4261f16a4c0538
7
+ data.tar.gz: 886c8f8673ab66695140d46186173b72837cf967f71a5cefcd29b4df98c7816a7ae3170bd1dbba0b3ce00d122e722451df6dca1251be1f8d8e029afd2c83736e
@@ -0,0 +1,53 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
52
+ ## Visual Studio Code
53
+ .vscode
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-mixer (0.1.0)
5
+ omniauth-oauth2 (~> 1.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ faraday (0.12.1)
11
+ multipart-post (>= 1.2, < 3)
12
+ hashie (3.5.6)
13
+ jwt (1.5.6)
14
+ multi_json (1.12.1)
15
+ multi_xml (0.6.0)
16
+ multipart-post (2.0.0)
17
+ oauth2 (1.4.0)
18
+ faraday (>= 0.8, < 0.13)
19
+ jwt (~> 1.0)
20
+ multi_json (~> 1.3)
21
+ multi_xml (~> 0.5)
22
+ rack (>= 1.2, < 3)
23
+ omniauth (1.6.1)
24
+ hashie (>= 3.4.6, < 3.6.0)
25
+ rack (>= 1.6.2, < 3)
26
+ omniauth-oauth2 (1.4.0)
27
+ oauth2 (~> 1.0)
28
+ omniauth (~> 1.2)
29
+ rack (2.0.3)
30
+ rake (0.9.6)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.5)
37
+ omniauth-mixer!
38
+ rake (~> 0)
39
+
40
+ BUNDLED WITH
41
+ 1.11.2
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 csauls
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,81 @@
1
+ [![Gem Version](https://badge.fury.io/rb/omniauth-mixer.svg)](https://badge.fury.io/rb/omniauth-mixer)
2
+
3
+ # OmniAuth::Mixer
4
+ OmniAuth strategy for Mixer
5
+
6
+ ## Installation
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-mixer'
10
+
11
+ Then run `bundle install`
12
+
13
+ Or install it yourself with `gem install omniauth-mixer`
14
+
15
+ ### Using Directly
16
+ ```ruby
17
+ Rails.application.config.middleware.use OmniAuth::Builder do
18
+ provider :mixer, ENV['MIXER_CLIENT_ID'], ENV['MIXER_CLIENT_SECRET']
19
+ end
20
+ ```
21
+
22
+ ### Using With Devise
23
+ Add to `config/initializers/devise.rb`
24
+ ```ruby
25
+ config.omniauth :mixer, ENV['MIXER_CLIENT_ID'], ENV['MIXER_CLIENT_SECRET']
26
+ ```
27
+
28
+ And apply it to your Devise user model:
29
+ ```ruby
30
+ class User < ApplicationRecord
31
+ devise :database_authenticatable, :registerable, :recoverable, :rememberable,
32
+ :trackable, :validatable, :omniauthable,
33
+ omniauth_providers: %i(mixer)
34
+
35
+ def self.from_omniauth(auth)
36
+ user = where(provider: auth.provider, uid: auth.uid).first_or_create do |u|
37
+ u.password = Devise.friendly_token[0, 20]
38
+ u.provider = auth.provider
39
+ u.uid = auth.uid
40
+ end
41
+ user.update avatar_url: auth.info.image,
42
+ email: auth.info.email,
43
+ name: auth.info.name
44
+ user
45
+ end
46
+ end
47
+ ```
48
+
49
+ ## Default Scope
50
+
51
+ The default scope is set to _user:details:self_, making this hash available in `request.env['omniauth.auth']`:
52
+ ```ruby
53
+ {
54
+ provider: 'mixer',
55
+ uid: 123456789,
56
+ info: {
57
+ name: 'JohnDoe',
58
+ email: 'johndoe@example.com',
59
+ description: 'My channel.',
60
+ image: 'https://uploads.mixer.com/avatar/12345678-1234.jpg',
61
+ social: {
62
+ discord: 'johndoe#12345',
63
+ facebook: 'https://facebook.com/John.Doe'
64
+ player: 'https://player.me/johndoe',
65
+ twitter: 'https://twitter.com/johndoe',
66
+ youtube: 'https://youtube.com/user/johndoe'
67
+ },
68
+ urls: { Mixer: 'https://mixer.com/johndoe' }
69
+ },
70
+ credentials: {
71
+ token: 'asdfghjklasdfghjklasdfghjkl',
72
+ refresh_token: 'qwertyuiopqwertyuiopqwertyuiop',
73
+ expires_at: 1477577799,
74
+ expires: true
75
+ }
76
+ }
77
+ ```
78
+
79
+ ## Credits
80
+
81
+ Derived from omniauth-beam: https://github.com/charmquark/omniauth-beam
@@ -0,0 +1,2 @@
1
+ require 'omniauth/mixer/version'
2
+ require 'omniauth/strategies/mixer'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Mixer
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,91 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ #
6
+ class Mixer < OmniAuth::Strategies::OAuth2
7
+ BLANK_PARAMS = [nil, ''].freeze
8
+ DEFAULT_SCOPE = 'user:details:self'.freeze
9
+ RAW_INFO_URL = '/api/v1/users/current'.freeze
10
+ SOCIAL_KEYS = %w(facebook discord player twitter youtube).freeze
11
+
12
+ option :name, 'mixer'
13
+
14
+ option :client_options,
15
+ site: 'https://mixer.com',
16
+ authorize_url: '/oauth/authorize',
17
+ token_url: '/api/v1/oauth/token'
18
+
19
+ option :access_token_options,
20
+ header_format: 'OAuth %s',
21
+ param_name: 'access_token'
22
+
23
+ option :authorize_options, [:scope]
24
+
25
+ uid { raw_info['id'] }
26
+
27
+ info do
28
+ {
29
+ name: raw_info['username'],
30
+ email: raw_info['email'],
31
+ description: raw_info['bio'],
32
+ image: raw_info['avatarUrl'],
33
+ social: social_info,
34
+ urls: urls_info
35
+ }
36
+ end
37
+
38
+ extra do
39
+ {
40
+ raw_info: raw_info
41
+ }
42
+ end
43
+
44
+ def access_token_options
45
+ options.access_token_options.each_with_object({}) do |(key, val), hsh|
46
+ hsh[key.to_sym] = val
47
+ hsh
48
+ end
49
+ end
50
+
51
+ def authorize_params
52
+ super.tap do |params|
53
+ options[:authorize_options].each do |key|
54
+ val = request.params[key.to_s]
55
+ params[key] = val unless BLANK_PARAMS.include? val
56
+ end
57
+ params[:scope] ||= DEFAULT_SCOPE
58
+ end
59
+ end
60
+
61
+ def build_access_token
62
+ super.tap do |token|
63
+ token.options.merge! access_token_options
64
+ end
65
+ end
66
+
67
+ def callback_url
68
+ return options[:redirect_url] if options.key? :redirect_url
69
+ full_host + script_name + callback_path
70
+ end
71
+
72
+ def raw_info
73
+ @raw_info ||= access_token.get(RAW_INFO_URL).parsed
74
+ end
75
+
76
+ def social_info
77
+ raw_social = raw_info['social']
78
+ SOCIAL_KEYS.each_with_object({}) do |key, hsh|
79
+ hsh[key.to_sym] = raw_social[key] if raw_social.key? key
80
+ hsh
81
+ end
82
+ end
83
+
84
+ def urls_info
85
+ {
86
+ Mixer: "http://mixer.com/#{raw_info['channel']['token']}"
87
+ }
88
+ end
89
+ end # Mixer
90
+ end # Strategies
91
+ end # OmniAuth
@@ -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/mixer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'omniauth-mixer'
8
+ spec.version = OmniAuth::Mixer::VERSION
9
+ spec.authors = ['Dave Hartnoll "KeyMailer"']
10
+ spec.email = ['dave.hartnoll@keymailer.co']
11
+ spec.summary = 'Mixer OAuth2 Strategy for OmniAuth'
12
+ spec.homepage = 'https://github.com/KeyMailer/omniauth-mixer'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
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', '~> 0'
24
+ end
@@ -0,0 +1 @@
1
+ require 'omniauth/mixer'
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-mixer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dave Hartnoll "KeyMailer"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-18 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
+ - dave.hartnoll@keymailer.co
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE
66
+ - README.md
67
+ - lib/omniauth/mixer.rb
68
+ - lib/omniauth/mixer/version.rb
69
+ - lib/omniauth/strategies/mixer.rb
70
+ - omniauth-mixer.gemspec
71
+ - omniauth-mixer.rb
72
+ homepage: https://github.com/KeyMailer/omniauth-mixer
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.5.1
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Mixer OAuth2 Strategy for OmniAuth
96
+ test_files: []
97
+ has_rdoc: