omniauth-beam 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: a93616647610037f3519d2324275b7bb6165aeb4
4
+ data.tar.gz: 5dd4b43b19ab16d033cee38620ad2738ce8f6300
5
+ SHA512:
6
+ metadata.gz: 7e46738397034a9a39fd00ebdee8fa63130fe504a3287bef1e83f3af4f12b979a360373fc8d06917b63a3b73e1ab8a0f0da0c5f04448718b11b1305c7537717f
7
+ data.tar.gz: e54e154171794259a48498abcf2675c9bc73e0d9b3219d757c25e0647abb63858d2e8cb44c2e8792fc058802a9646676167264e6d876a2ac5b7c53ef23f6fcf2
data/.gitignore ADDED
@@ -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
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-beam (0.1.0)
5
+ omniauth-oauth2 (~> 1.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ faraday (0.9.2)
11
+ multipart-post (>= 1.2, < 3)
12
+ hashie (3.4.6)
13
+ jwt (1.5.6)
14
+ multi_json (1.12.1)
15
+ multi_xml (0.5.5)
16
+ multipart-post (2.0.0)
17
+ oauth2 (1.2.0)
18
+ faraday (>= 0.8, < 0.10)
19
+ jwt (~> 1.0)
20
+ multi_json (~> 1.3)
21
+ multi_xml (~> 0.5)
22
+ rack (>= 1.2, < 3)
23
+ omniauth (1.3.1)
24
+ hashie (>= 1.2, < 4)
25
+ rack (>= 1.0, < 3)
26
+ omniauth-oauth2 (1.4.0)
27
+ oauth2 (~> 1.0)
28
+ omniauth (~> 1.2)
29
+ rack (2.0.1)
30
+ rake (11.3.0)
31
+
32
+ PLATFORMS
33
+ ruby
34
+
35
+ DEPENDENCIES
36
+ bundler (~> 1.5)
37
+ omniauth-beam!
38
+ rake
39
+
40
+ BUNDLED WITH
41
+ 1.13.1
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.
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # omniauth-beam
2
+ OmniAuth strategy for Beam.pro
@@ -0,0 +1,2 @@
1
+ require 'omniauth/beam/version'
2
+ require 'omniauth/strategies/beam'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Beam
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
@@ -0,0 +1,68 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ #
6
+ class Beam < 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
+
11
+ option :name, 'beam'
12
+
13
+ option :client_options,
14
+ site: 'https://beam.pro',
15
+ authorize_url: '/oauth/authorize',
16
+ token_url: '/api/v1/oauth/token'
17
+
18
+ option :access_token_options,
19
+ header_format: 'OAuth %s',
20
+ param_name: 'access_token'
21
+
22
+ option :authorize_options, [:scope]
23
+
24
+ uid { raw_info['id'] }
25
+
26
+ info do
27
+ {
28
+ name: raw_info['username'],
29
+ email: raw_info['email'],
30
+ description: raw_info['bio'],
31
+ image: raw_info['avatarUrl'],
32
+ urls: { Beam: "http://beam.pro/#{raw_info['name']}" }
33
+ }
34
+ end
35
+
36
+ def access_token_options
37
+ options.access_token_options.each_with_object({}) do |(key, val), hsh|
38
+ hsh[key.to_sym] = val
39
+ hsh
40
+ end
41
+ end
42
+
43
+ def authorize_params
44
+ super.tap do |params|
45
+ options[:authorize_options].each do |key|
46
+ val = request.params[key.to_s]
47
+ params[key] = val unless BLANK_PARAMS.include? val
48
+ end
49
+ end
50
+ end
51
+
52
+ def build_access_token
53
+ super.tap do |token|
54
+ token.options.merge! access_token_options
55
+ end
56
+ end
57
+
58
+ def callback_url
59
+ return options[:redirect_url] if options.key? :redirect_url
60
+ full_host + script_name + callback_path
61
+ end
62
+
63
+ def raw_info
64
+ @raw_info ||= access_token.get(RAW_INFO_URL).parsed
65
+ end
66
+ end # Beam
67
+ end # Strategies
68
+ 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/beam/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'omniauth-beam'
8
+ spec.version = OmniAuth::Beam::VERSION
9
+ spec.authors = ['Christopher Nicholson-Sauls "charmquark"']
10
+ spec.email = ['ibisbasenji@gmail.com']
11
+ spec.summary = 'Beam.pro OAuth2 Strategy for OmniAuth'
12
+ spec.homepage = 'https://github.com/csauls/omniauth-beam'
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
data/omniauth-beam.rb ADDED
@@ -0,0 +1 @@
1
+ require 'omniauth/beam'
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-beam
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Nicholson-Sauls "charmquark"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-27 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
+ - ibisbasenji@gmail.com
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/beam.rb
68
+ - lib/omniauth/beam/version.rb
69
+ - lib/omniauth/strategies/beam.rb
70
+ - omniauth-beam.gemspec
71
+ - omniauth-beam.rb
72
+ homepage: https://github.com/csauls/omniauth-beam
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: Beam.pro OAuth2 Strategy for OmniAuth
96
+ test_files: []