omniauth-roomorama 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.rbc
2
+ *.sw?
3
+ *.gem
4
+ .DS_Store
5
+ .bundle
6
+ .rbx
7
+ .rvmrc
8
+ .yardoc
9
+ Gemfile.lock
10
+ bin
11
+ coverage*
12
+ doc
13
+ gemfiles
14
+ pkg
15
+ rdoc
16
+ rerun.txt
17
+ tags
18
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format=nested
2
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - ruby-head
7
+ - ree
8
+ - jruby-18mode # JRuby in 1.8 mode
9
+ - jruby-19mode # JRuby in 1.9 mode
10
+ - rbx-18mode
11
+ - rbx-19mode
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ group :example do
6
+ gem 'sinatra'
7
+ end
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # OmniAuth Roomorama
2
+
3
+ This is an OmniAuth 1.0 strategy for authenticating to Roomorama. To
4
+ use it, you'll need to sign up for an OAuth2 Application ID and Secret
5
+ on the [Roomorama Application's Registration Page](https://roomorama.com/oauth_clients/new).
6
+
7
+ ## Installing
8
+
9
+ Add to your `Gemfile`:
10
+
11
+ ```ruby
12
+ gem 'omniauth-roomorama'
13
+ ```
14
+
15
+ Then `bundle install`.
16
+
17
+ ## Usage
18
+
19
+ `OmniAuth::Strategies::Roomorama` is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.
20
+
21
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :roomorama, ENV['ROOMORAMA_KEY'], ENV['ROOMORAMA_SECRET']
26
+ end
27
+ ```
28
+
29
+ ## Supported Rubies
30
+
31
+ OmniAuth Roomorama is tested under 1.8.7, 1.9.2, 1.9.3, Ruby-head, Ruby Enterprise Edition, JRuby (1.8 and 1.9 mode) and Rubinius (1.8 and 1.9 mode).
32
+
33
+ [![CI Build
34
+ Status](https://secure.travis-ci.org/BookingSync/omniauth-roomorama.png)](http://travis-ci.org/BookingSync/omniauth-roomorama)
35
+
36
+ ## License
37
+
38
+ Copyright (c) 2012 Sébastien Grosjean and [BookingSync.com](http://www.bookingsync.com)
39
+
40
+ 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:
41
+
42
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
43
+
44
+ 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,7 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.setup :default, :development, :example
5
+ require 'sinatra'
6
+ require 'omniauth'
7
+ require 'omniauth-roomorama'
8
+
9
+ use Rack::Session::Cookie
10
+
11
+ use OmniAuth::Builder do
12
+ provider :roomorama, "xhphaTy1kl0Yjqan1ZgHGw", "E9PVZNSWbluCqqSjy9wH8tUb6ttTkaHy6wV38724o"
13
+ end
14
+
15
+ get '/' do
16
+ <<-HTML
17
+ <ul>
18
+ <li><a href='/auth/roomorama'>Sign in with Roomorama</a></li>
19
+ </ul>
20
+ HTML
21
+ end
22
+
23
+ get '/auth/:provider/callback' do
24
+ content_type 'text/plain'
25
+ request.env['omniauth.auth'].to_hash.inspect
26
+ end
27
+
28
+ get '/auth/failure' do
29
+ content_type 'text/plain'
30
+ params[:message]
31
+ end
@@ -0,0 +1,13 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Roomorama < OmniAuth::Strategies::OAuth2
6
+ option :name, 'roomorama'
7
+
8
+ option :client_options, { :site => 'https://roomorama.com' }
9
+ end
10
+ end
11
+ end
12
+
13
+ OmniAuth.config.add_camelization 'roomorama', 'Roomorama'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Roomorama
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-roomorama/version'
2
+ require 'omniauth/strategies/roomorama'
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-roomorama/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Sebastien Grosjean"]
6
+ gem.email = ["dev@bookingsync.com"]
7
+ gem.description = %q{An OmniAuth 1.0 strategy for Roomorama oauth2 identification.}
8
+ gem.summary = %q{An OmniAuth 1.0 strategy for Roomorama oauth2 identification.}
9
+ gem.homepage = "https://github.com/BookingSync/omniauth-roomorama"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "omniauth-roomorama"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::Roomorama::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0'
20
+
21
+ gem.add_development_dependency 'rspec', '~> 2.7'
22
+ gem.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-roomorama'
3
+
4
+ describe OmniAuth::Strategies::Roomorama do
5
+ subject do
6
+ OmniAuth::Strategies::Roomorama.new(nil, @options || {})
7
+ end
8
+
9
+ it_should_behave_like 'an oauth2 strategy'
10
+
11
+ describe '#client' do
12
+ it 'should have the correct site' do
13
+ subject.client.site.should eq("https://roomorama.com")
14
+ end
15
+
16
+ it 'should have the correct authorization url' do
17
+ subject.client.options[:authorize_url].should eq("/oauth/authorize")
18
+ end
19
+
20
+ it 'should have the correct token url' do
21
+ subject.client.options[:token_url].should eq('/oauth/token')
22
+ end
23
+ end
24
+
25
+ describe '#callback_path' do
26
+ it 'should have the correct callback path' do
27
+ subject.callback_path.should eq('/auth/roomorama/callback')
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,6 @@
1
+ require 'bundler/setup'
2
+ require 'rspec'
3
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
4
+
5
+ RSpec.configure do |config|
6
+ end
@@ -0,0 +1,36 @@
1
+ shared_examples 'an oauth2 strategy' do
2
+ describe '#client' do
3
+ it 'should be initialized with symbolized client_options' do
4
+ @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
5
+ subject.client.options[:authorize_url].should == 'https://example.com'
6
+ end
7
+ end
8
+
9
+ describe '#authorize_params' do
10
+ it 'should include any authorize params passed in the :authorize_params option' do
11
+ @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
12
+ subject.authorize_params['foo'].should eq('bar')
13
+ subject.authorize_params['baz'].should eq('zip')
14
+ end
15
+
16
+ it 'should include top-level options that are marked as :authorize_options' do
17
+ @options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
18
+ subject.authorize_params['scope'].should eq('bar')
19
+ subject.authorize_params['foo'].should eq('baz')
20
+ end
21
+ end
22
+
23
+ describe '#token_params' do
24
+ it 'should include any token params passed in the :token_params option' do
25
+ @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
26
+ subject.token_params['foo'].should eq('bar')
27
+ subject.token_params['baz'].should eq('zip')
28
+ end
29
+
30
+ it 'should include top-level options that are marked as :token_options' do
31
+ @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
32
+ subject.token_params['scope'].should eq('bar')
33
+ subject.token_params['foo'].should eq('baz')
34
+ end
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-roomorama
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Sebastien Grosjean
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-07 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &70231885663260 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70231885663260
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth2
27
+ requirement: &70231885661960 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70231885661960
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70231885660480 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '2.7'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70231885660480
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &70231885659280 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70231885659280
58
+ description: An OmniAuth 1.0 strategy for Roomorama oauth2 identification.
59
+ email:
60
+ - dev@bookingsync.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - .rspec
67
+ - .travis.yml
68
+ - Gemfile
69
+ - README.md
70
+ - Rakefile
71
+ - example/sinatra.rb
72
+ - lib/omniauth-roomorama.rb
73
+ - lib/omniauth-roomorama/version.rb
74
+ - lib/omniauth/strategies/roomorama.rb
75
+ - omniauth-roomorama.gemspec
76
+ - spec/omniauth/strategies/roomorama_spec.rb
77
+ - spec/spec_helper.rb
78
+ - spec/support/shared_examples.rb
79
+ homepage: https://github.com/BookingSync/omniauth-roomorama
80
+ licenses: []
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 1.8.17
100
+ signing_key:
101
+ specification_version: 3
102
+ summary: An OmniAuth 1.0 strategy for Roomorama oauth2 identification.
103
+ test_files:
104
+ - spec/omniauth/strategies/roomorama_spec.rb
105
+ - spec/spec_helper.rb
106
+ - spec/support/shared_examples.rb
107
+ has_rdoc: