omniauth-afterclassroom 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ # Specify your gem's dependencies in omniauth-afterclassroom.gemspec
5
+ gemspec
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # OmniAuth afterclassroom
2
+
3
+ This gem contains the afterclassroom strategy for OmniAuth.
4
+
5
+ afterclassroom uses the OAuth 1.0a flow, you can read about it here: https://dev.afterclassroom.com/docs/auth/oauth
6
+
7
+ ## How To Use It
8
+
9
+ Usage is as per any other OmniAuth 1.0 strategy. So let's say you're using Rails, you need to add the strategy to your `Gemfile`:
10
+
11
+ gem 'omniauth-afterclassroom'
12
+
13
+ You can pull them in directly from github e.g.:
14
+
15
+ gem 'omniauth-afterclassroom', :git => 'https://github.com/arunagw/omniauth-afterclassroom.git'
16
+
17
+ Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
18
+
19
+ Rails.application.config.middleware.use OmniAuth::Builder do
20
+ provider :afterclassroom, "consumer_key", "consumer_secret"
21
+ end
22
+
23
+ You will obviously have to put in your key and secret, which you get when you register your app with afterclassroom (they call them API Key and Secret Key).
24
+
25
+ afterclassroom also optionally supports specifying a username when authenticating. This is handy when your application supports multiple afterclassroom accounts since you can prompt the user to login to the correct account (and not defaulting to the current login).
26
+
27
+ To use this, just add a querystring for screen_name.
28
+
29
+ /auth/afterclassroom?screen_name=scottw
30
+
31
+ You can also specify ```force_login``` without specifying the screen_name to prompt the user to choose the afterclassroom account they wish to use.
32
+
33
+ /auth/afterclassroom?force_login=true
34
+
35
+ afterclassroom also optionally supports specifying a x_auth_access_type when authenticating. This is handy when you need to specify special permission in some cases.
36
+
37
+ To use this, just add a querystring for x_auth_access_type.
38
+
39
+ /auth/afterclassroom?x_auth_access_type=read
40
+
41
+
42
+ Now just follow the README at: https://github.com/intridea/omniauth
43
+
44
+ ## Watch the RailsCast
45
+
46
+ Ryan Bates has put together an excellent RailsCast on OmniAuth:
47
+
48
+ [![RailsCast #241](https://www.evernote.com/shard/s35/sh/479f2503-aefa-4542-a7b4-8f84fd22eafc/0571f5a3795a0be3d0b0814312a8d5b7/res/49b5478a-657c-4aff-ae58-dae08b9a46d5/Screen_Shot_2012-07-15_at_12.41.15_PM-20120715-125424.jpg.jpg "RailsCast #241 - Simple OmniAuth (revised)")](http://railscasts.com/episodes/241-simple-omniauth-revised)
49
+
50
+
51
+ ## Supported Rubies
52
+
53
+ OmniAuth afterclassroom is tested under 1.8.7, 1.9.2, 1.9.3 and Ruby Enterprise Edition.
54
+
55
+ [![CI Build
56
+ Status](https://secure.travis-ci.org/arunagw/omniauth-afterclassroom.png)](http://travis-ci.org/arunagw/omniauth-afterclassroom)
57
+
58
+ ## Note on Patches/Pull Requests
59
+
60
+ - Fork the project.
61
+ - Make your feature addition or bug fix.
62
+ - Add tests for it. This is important so I don’t break it in a future version unintentionally.
63
+ - Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
64
+ - Send me a pull request. Bonus points for topic branches.
65
+
66
+ ## License
67
+
68
+ Copyright (c) 2011 by Arun Agrawal
69
+
70
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
71
+
72
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
73
+
74
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Default: run specs.'
8
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth-afterclassroom/version"
2
+ require 'omniauth/strategies/afterclassroom'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Afterclassroom
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,42 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Afterclassroom < OmniAuth::Strategies::OAuth2
7
+ option :name, 'afterclassroom'
8
+ option :client_options, {
9
+ :authorize_path => '/oauth/authorize',#'/oauth/afterclassroom',
10
+ :site => 'http://localhost:3000',
11
+ :request_token_path => "/oauth/token",
12
+ }#https://afterclassroom.com
13
+
14
+
15
+
16
+ uid { access_token.params[:user_id] }
17
+
18
+ info do
19
+ {
20
+ :name => raw_info['name'],
21
+ }
22
+ end
23
+
24
+ extra do
25
+ { :raw_info => raw_info }
26
+ end
27
+
28
+ def raw_info
29
+ @raw_info ||= access_token.get('/api/users/me').parsed
30
+ # @raw_info ||= MultiJson.load(access_token.get('/api/users/me').parsed)
31
+ end
32
+
33
+ alias :old_request_phase :request_phase
34
+
35
+
36
+
37
+
38
+
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-afterclassroom/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-afterclassroom"
7
+ s.version = OmniAuth::Afterclassroom::VERSION
8
+ s.authors = ["Arun Agrawal"]
9
+ s.email = ["arunagw@gmail.com"]
10
+ s.homepage = "https://github.com/arunagw/omniauth-afterclassroom"
11
+ s.summary = %q{OmniAuth strategy for Afterclassroom}
12
+ s.description = %q{OmniAuth strategy for Afterclassroom}
13
+
14
+ #s.rubyforge_project = "omniauth-afterclassroom"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency 'multi_json', '~> 1.3'
22
+ s.add_runtime_dependency 'omniauth-oauth2'
23
+ s.add_development_dependency 'rspec', '~> 2.7'
24
+ s.add_development_dependency 'rack-test'
25
+ s.add_development_dependency 'simplecov'
26
+ s.add_development_dependency 'webmock'
27
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Afterclassroom do
4
+ subject do
5
+ OmniAuth::Strategies::Afterclassroom.new({})
6
+ end
7
+
8
+ context "client options" do
9
+ it 'should have correct name' do
10
+ subject.options.name.should eq("afterclassroom")
11
+ end
12
+
13
+ it 'should have correct site' do
14
+ subject.options.client_options.site.should eq('https://api.afterclassroom.com')
15
+ end
16
+
17
+ it 'should have correct authorize url' do
18
+ subject.options.client_options.authorize_path.should eq('/oauth/authenticate')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
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-afterclassroom'
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
16
+
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-afterclassroom
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Arun Agrawal
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-07-20 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: multi_json
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "1.3"
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: omniauth-oauth2
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ prerelease: false
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: "2.7"
46
+ type: :development
47
+ version_requirements: *id003
48
+ - !ruby/object:Gem::Dependency
49
+ name: rack-test
50
+ prerelease: false
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ version_requirements: *id004
59
+ - !ruby/object:Gem::Dependency
60
+ name: simplecov
61
+ prerelease: false
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: webmock
72
+ prerelease: false
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ type: :development
80
+ version_requirements: *id006
81
+ description: OmniAuth strategy for Afterclassroom
82
+ email:
83
+ - arunagw@gmail.com
84
+ executables: []
85
+
86
+ extensions: []
87
+
88
+ extra_rdoc_files: []
89
+
90
+ files:
91
+ - Gemfile
92
+ - README.md
93
+ - Rakefile
94
+ - lib/omniauth-afterclassroom.rb
95
+ - lib/omniauth-afterclassroom/version.rb
96
+ - lib/omniauth/strategies/afterclassroom.rb
97
+ - omniauth-afterclassroom.gemspec
98
+ - spec/omniauth/strategies/afterclassroom_spec.rb
99
+ - spec/spec_helper.rb
100
+ homepage: https://github.com/arunagw/omniauth-afterclassroom
101
+ licenses: []
102
+
103
+ post_install_message:
104
+ rdoc_options: []
105
+
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: "0"
120
+ requirements: []
121
+
122
+ rubyforge_project:
123
+ rubygems_version: 1.8.24
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: OmniAuth strategy for Afterclassroom
127
+ test_files: []
128
+