omniauth-edmodo 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a1e632b24585480c84d4199d2da90a250c45f63a
4
+ data.tar.gz: c1bfc0573b9f3e19eedd83911815e8767c79a37a
5
+ SHA512:
6
+ metadata.gz: d3a932be2d1d00298c5440664ff37bff5db3d0e362bb71d2434bdaf8d881a71762ab1403b13738e76473ad228cfd366721bfb26a7977abbbe82459e05d4bc211
7
+ data.tar.gz: b72e2e97efd938e4c705763f6a70bab4b343e4d6ad22faa782d775bdb6bfa32a25f5739957917e2b3b3a7ded01511052cdb335660779269b1cf2a6b882aad79f
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-edmodo.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jerry Luk
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,31 @@
1
+ # Omniauth Edmodo
2
+
3
+ This is the OmniAuth strategy for authenticating to Edmodo. TO use it, you'll need to obtain an OAuth2 application key and secret from Edmodo.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-edmodo'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-edmodo
18
+
19
+ ## Basic Usage
20
+
21
+ use OmniAuth::Builder do
22
+ provider :edmodo, ENV['EDMODO_KEY'], ENV['EDMODO_SECRET'], scope: "basic,read_user_email"
23
+ end
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/omniauth-edmodo/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ desc 'Run specs'
7
+ task :default => :spec
@@ -0,0 +1,50 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Edmodo < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ :site => 'https://api.edmodo.com',
8
+ :authorize_url => 'https://api.edmodo.com/oauth/authorize',
9
+ :token_url => 'https://api.edmodo.com/oauth/token'
10
+ }
11
+
12
+ def request_phase
13
+ super
14
+ end
15
+
16
+ def authorize_params
17
+ super.tap do |params|
18
+ %w[scope client_options].each do |v|
19
+ if request.params[v]
20
+ params[v.to_sym] = request.params[v]
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ uid { raw_info['id'].to_s }
27
+
28
+ info do
29
+ {
30
+ 'nickname' => raw_info['username'],
31
+ 'email' => raw_info['email'],
32
+ 'first_name' => raw_info['first_name'],
33
+ 'last_name' => raw_info['last_name'],
34
+ 'image' => raw_info['avatars']['large']
35
+ }
36
+ end
37
+
38
+ extra do
39
+ {:raw_info => raw_info}
40
+ end
41
+
42
+ def raw_info
43
+ access_token.options[:mode] = :header
44
+ @raw_info ||= access_token.get('users/me').parsed
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ OmniAuth.config.add_camelization 'edmodo', 'Edmodo'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Edmodo
3
+ VERSION = "0.0.8"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-edmodo/version"
2
+ require 'omniauth/strategies/edmodo'
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-edmodo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-edmodo"
8
+ spec.version = Omniauth::Edmodo::VERSION
9
+ spec.authors = ["Jerry Luk"]
10
+ spec.email = ["jerryluk@gmail.com"]
11
+ spec.summary = %q{OmniAuth strategy for Edmodo}
12
+ spec.description = %q{OmniAuth strategy for Edmodo}
13
+ spec.homepage = "https://github.com/jerryluk/omniauth-edmodo"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'omniauth'
22
+ spec.add_dependency 'omniauth-oauth2'
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "rack-test"
27
+ spec.add_development_dependency "webmock"
28
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Edmodo do
4
+ let(:access_token) { double('AccessToken', :options => {}) }
5
+ let(:parsed_response) { double('ParsedResponse') }
6
+ let(:response) { double('Response', :parsed => parsed_response) }
7
+
8
+ let(:dev_site) { 'https://localhost:3000' }
9
+ let(:dev_authorize_url) { 'https://localhost:3000/oauth/authorize' }
10
+ let(:dev_token_url) { 'https://localhost:3000/oauth/token' }
11
+ let(:dev) do
12
+ OmniAuth::Strategies::Edmodo.new('EDMODO_KEY', 'EDMODO_SECRET', {
13
+ client_options: {
14
+ site: dev_site,
15
+ authorize_url: dev_authorize_url,
16
+ token_url: dev_token_url
17
+ }
18
+ })
19
+ end
20
+
21
+ subject do
22
+ OmniAuth::Strategies::Edmodo.new({})
23
+ end
24
+
25
+ before(:each) do
26
+ allow(subject).to receive(:access_token).and_return(access_token)
27
+ end
28
+
29
+ context "client options" do
30
+ it 'should have correct site' do
31
+ expect(subject.options.client_options.site).to eq("https://api.edmodo.com")
32
+ end
33
+
34
+ it 'should have correct authorize url' do
35
+ expect(subject.options.client_options.authorize_url).to eq('https://api.edmodo.com/oauth/authorize')
36
+ end
37
+
38
+ it 'should have correct token url' do
39
+ expect(subject.options.client_options.token_url).to eq('https://api.edmodo.com/oauth/token')
40
+ end
41
+
42
+ describe "should be overrideable" do
43
+ it "for site" do
44
+ expect(dev.options.client_options.site).to eq(dev_site)
45
+ end
46
+
47
+ it "for authorize url" do
48
+ expect(dev.options.client_options.authorize_url).to eq(dev_authorize_url)
49
+ end
50
+
51
+ it "for token url" do
52
+ expect(dev.options.client_options.token_url).to eq(dev_token_url)
53
+ end
54
+ end
55
+ end
56
+
57
+ context "#raw_info" do
58
+ it "should use relative paths" do
59
+ expect(access_token).to receive(:get).with('users/me').and_return(response)
60
+ expect(subject.raw_info).to eq(parsed_response)
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,13 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'rspec'
4
+ require 'rack/test'
5
+ require 'webmock/rspec'
6
+ require 'omniauth'
7
+ require 'omniauth-edmodo'
8
+
9
+ RSpec.configure do |config|
10
+ config.include WebMock::API
11
+ config.include Rack::Test::Methods
12
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
13
+ end
metadata ADDED
@@ -0,0 +1,156 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-edmodo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
5
+ platform: ruby
6
+ authors:
7
+ - Jerry Luk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-12 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '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: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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: rspec
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: rack-test
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: webmock
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: OmniAuth strategy for Edmodo
112
+ email:
113
+ - jerryluk@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - lib/omniauth-edmodo.rb
125
+ - lib/omniauth-edmodo/version.rb
126
+ - lib/omniauth/strategies/edmodo.rb
127
+ - omniauth-edmodo.gemspec
128
+ - spec/omniauth/strategies/edmodo_spec.rb
129
+ - spec/spec_helper.rb
130
+ homepage: https://github.com/jerryluk/omniauth-edmodo
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.2.2
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: OmniAuth strategy for Edmodo
154
+ test_files:
155
+ - spec/omniauth/strategies/edmodo_spec.rb
156
+ - spec/spec_helper.rb