omniauth-ely 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: c701afaca89dae0d711ea3ef0dde79175943468c
4
+ data.tar.gz: 21949368a63ffc52996c490b970495a8f2a638e6
5
+ SHA512:
6
+ metadata.gz: f733b499d9d4a6644a1752f0509d4473d5caf5bb41a532bd9e2defcb6476ef9fad0ebf83106d88e00dafe8ef75658f2648f7eccd3deb76cecfea04b11d659d77
7
+ data.tar.gz: c337c8d06b330c4d4b9a8c193a6943cfcd1ce5b49d314d3006be048d2b41453d882b09a717dab369f5e7b684774c3986a646c3c15f44c0f7091b69dd8cbc7fa0
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ .idea
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ /pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-ely.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
10
+ gem 'rb-fsevent'
11
+ gem 'growl'
12
+ end
data/Guardfile ADDED
@@ -0,0 +1,10 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+ guard 'bundler' do
8
+ watch('Gemfile')
9
+ watch('omniauth-ely.gemspec')
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ # The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Ely.by <team@ely.by>
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
13
+ > all 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
21
+ > THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # OmniAuth Ely.by
2
+
3
+ This is the official OmniAuth strategy for authenticating to Ely.by. To
4
+ use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
+ on the [Ely.by Account Applications Page](#).
6
+
7
+ ## Usage
8
+
9
+ Add the strategy to your `Gemfile` alongside OmniAuth:
10
+
11
+ ```ruby
12
+ gem 'omniauth'
13
+ gem 'omniauth-ely'
14
+ ```
15
+
16
+ Integrate this strategy to your OmniAuth middleware.
17
+
18
+ ```ruby
19
+ use OmniAuth::Builder do
20
+ provider :ely, 'application_id', 'secret'
21
+ end
22
+ ```
23
+
24
+ You need to add your key and secret.
25
+
26
+ For more information check the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Run specs'
8
+ task :default => :spec
@@ -0,0 +1,49 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Ely < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ :site => 'https://account.ely.by',
8
+ :authorize_url => 'https://account.ely.by/oauth2/v1/',
9
+ :token_url => 'https://account.ely.by/api/oauth2/v1/token',
10
+ }
11
+
12
+ uid { raw_info['id'].to_s }
13
+
14
+ info do
15
+ {
16
+ :name => raw_info['username'],
17
+ :email => raw_info['email'],
18
+ :urls => {
19
+ :Ely => profile_url,
20
+ :Skin => skin_url,
21
+ },
22
+ }
23
+ end
24
+
25
+ extra do
26
+ {
27
+ :raw_info => raw_info,
28
+ :uuid => raw_info['uuid'],
29
+ :registered_at => raw_info['registeredAt'],
30
+ :preferred_language => raw_info['preferredLanguage']
31
+ }
32
+ end
33
+
34
+ def raw_info
35
+ @raw_info ||= access_token.get('https://account.ely.by/api/account/v1/info').parsed
36
+ end
37
+
38
+ def skin_url
39
+ 'http://skinsystem.ely.by/skins/' + raw_info['username'] + '.png'
40
+ end
41
+
42
+ def profile_url
43
+ 'http://ely.by/u' + raw_info['id'].to_s
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ OmniAuth.config.add_camelization 'ely', 'Ely'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Ely
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-ely/version'
2
+ require 'omniauth/strategies/ely'
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-ely/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'omniauth-ely'
6
+ gem.version = OmniAuth::Ely::VERSION
7
+ gem.homepage = 'https://github.com/elyby/omniauth-ely'
8
+ gem.license = 'MIT'
9
+
10
+ gem.authors = ['Ely.by team', 'ErickSkrauch']
11
+ gem.email = ['team@ely.by', 'erickskrauch@ely.by']
12
+ gem.description = %q{Official OmniAuth strategy for Ely.by.}
13
+ gem.summary = %q{Official OmniAuth strategy for Ely.by.}
14
+
15
+ gem.add_dependency 'omniauth', '~> 1.0'
16
+ gem.add_dependency 'omniauth-oauth2', '>= 1.1.1', '< 2.0'
17
+ gem.add_development_dependency 'rspec', '~> 2.7'
18
+ gem.add_development_dependency 'rack-test'
19
+ gem.add_development_dependency 'simplecov'
20
+ gem.add_development_dependency 'webmock'
21
+
22
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
+ gem.files = `git ls-files`.split("\n")
24
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
+
26
+ gem.require_paths = ['lib']
27
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Ely do
4
+ let(:access_token) { stub('AccessToken', :options => {}) }
5
+ let(:parsed_response) { stub('ParsedResponse') }
6
+ let(:response) { stub('Response', :parsed => parsed_response) }
7
+
8
+ subject do
9
+ OmniAuth::Strategies::Ely.new({})
10
+ end
11
+
12
+ before(:each) do
13
+ subject.stub!(:access_token).and_return(access_token)
14
+ end
15
+
16
+ context 'client options' do
17
+ it 'should have correct site' do
18
+ subject.options.client_options.site.should eq('https://account.ely.by')
19
+ end
20
+
21
+ it 'should have correct authorize url' do
22
+ subject.options.client_options.authorize_url.should eq('https://account.ely.by/oauth2/v1/')
23
+ end
24
+
25
+ it 'should have correct token url' do
26
+ subject.options.client_options.token_url.should eq('https://account.ely.by/api/oauth2/v1/token')
27
+ end
28
+ end
29
+
30
+ context '#raw_info' do
31
+ it 'should use relative paths' do
32
+ access_token.should_receive(:get).and_return(response)
33
+ subject.raw_info.should eq(parsed_response)
34
+ end
35
+
36
+ it 'should build valid profile link' do
37
+ raw_info = Hash.new
38
+ raw_info['id'] = 1
39
+ subject.stub!(:raw_info).and_return(raw_info)
40
+ subject.profile_url.should eq('http://ely.by/u1')
41
+ end
42
+
43
+ it 'should build valid skin link' do
44
+ raw_info = Hash.new
45
+ raw_info['username'] = 'Steve'
46
+ subject.stub!(:raw_info).and_return(raw_info)
47
+ subject.skin_url.should eq('http://skinsystem.ely.by/skins/Steve.png')
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,15 @@
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-ely'
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
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-ely
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ely.by team
8
+ - ErickSkrauch
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-11-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: omniauth-oauth2
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.1.1
35
+ - - "<"
36
+ - !ruby/object:Gem::Version
37
+ version: '2.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 1.1.1
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rspec
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.7'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-test
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: simplecov
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ - !ruby/object:Gem::Dependency
91
+ name: webmock
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ description: Official OmniAuth strategy for Ely.by.
105
+ email:
106
+ - team@ely.by
107
+ - erickskrauch@ely.by
108
+ executables: []
109
+ extensions: []
110
+ extra_rdoc_files: []
111
+ files:
112
+ - ".gitignore"
113
+ - ".rspec"
114
+ - Gemfile
115
+ - Guardfile
116
+ - LICENSE.txt
117
+ - README.md
118
+ - Rakefile
119
+ - lib/omniauth-ely.rb
120
+ - lib/omniauth-ely/version.rb
121
+ - lib/omniauth/strategies/ely.rb
122
+ - omniauth-ely.gemspec
123
+ - spec/omniauth/strategies/ely_spec.rb
124
+ - spec/spec_helper.rb
125
+ homepage: https://github.com/elyby/omniauth-ely
126
+ licenses:
127
+ - MIT
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.5.1
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Official OmniAuth strategy for Ely.by.
149
+ test_files:
150
+ - spec/omniauth/strategies/ely_spec.rb
151
+ - spec/spec_helper.rb