omniauth-smartcloud 0.1

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
+ *.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
+ /.idea
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-smartcloud.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
10
+ gem 'rb-inotify', :require => false
11
+ gem 'rb-fsevent', :require => false
12
+ gem 'rb-fchange', :require => false
13
+ 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-smartcloud.gemspec')
10
+ end
data/README.md ADDED
@@ -0,0 +1,18 @@
1
+ # OmniAuth Smartcloud
2
+
3
+ OmniAuth strategy for authenticating to [IBM's Smartcloud for Social Business](http://www.ibm.com/cloud-computing/social/us/en/).
4
+
5
+ ## Basic Usage
6
+
7
+ use OmniAuth::Builder do
8
+ provider :smartcloud, ENV['SMARTCLOUD_KEY'], ENV['SMARTCLOUD_SECRET']
9
+ end
10
+
11
+ ## Dependancy Note
12
+
13
+ For some reason, IBM has chose to make the content type of the token request response to be 'text/plain' even though
14
+ it is a url query string. Until IBM comes to their senses and changes the content type of the response to
15
+ 'application/x-www-form-urlencoded', or my pull request is merged, you must include my fork of the [OAuth2
16
+ gem](https://github.com/tagCincy/oauth2) in the Gemfile of your project.
17
+
18
+ gem 'oauth2', :git => 'git@github.com:tagCincy/oauth2.git'
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,2 @@
1
+ require "omniauth-smartcloud/version"
2
+ require 'omniauth/strategies/smartcloud'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Smartcloud
3
+ VERSION = "0.1"
4
+ end
5
+ end
@@ -0,0 +1,62 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Smartcloud < OmniAuth::Strategies::OAuth2
6
+
7
+ option :client_options, {
8
+ :site => 'https://apps.lotuslive.com',
9
+ :authorize_url => 'https://apps.lotuslive.com/manage/oauth2/authorize',
10
+ :token_url => 'https://apps.lotuslive.com/manage/oauth2/token'
11
+ }
12
+ option :provider_ignores_state, true
13
+
14
+ option :token_options, {
15
+ :grant_type => 'authorization_code'
16
+ }
17
+
18
+ option :access_token_options, {
19
+ :header_format => 'Bearer %s'
20
+ }
21
+
22
+ def request_phase
23
+ redirect client.auth_code.authorize_url({:callback_uri => callback_url}.merge(authorize_params))
24
+ end
25
+
26
+ def authorize_params
27
+ params = options.authorize_params.merge(options.authorize_options.inject({}){|h,k| h[k.to_sym] = options[k] if options[k]; h})
28
+ if OmniAuth.config.test_mode
29
+ @env ||= {}
30
+ @env['rack.session'] ||= {}
31
+ end
32
+ params
33
+ end
34
+
35
+ def build_access_token
36
+ verifier = request.params['code']
37
+ client.auth_code.get_token(verifier, {:callback_uri => callback_url}.merge(token_params.to_hash(:symbolize_keys => true)))
38
+ end
39
+
40
+ uid { raw_info['objectId'].to_s }
41
+
42
+ info do
43
+ {
44
+ 'name' => raw_info['fullName'],
45
+ 'email' => raw_info['emailAddress'],
46
+ 'country' => raw_info['country']
47
+ }
48
+ end
49
+
50
+ extra do
51
+ {:raw_info => raw_info}
52
+ end
53
+
54
+ def raw_info
55
+ @raw_info ||= access_token.get('/lotuslive-shindig-server/social/rest/people/@me/@self?mode=json').parsed['entry']
56
+ raise @raw_info.to_yaml
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ OmniAuth.config.add_camelization 'smartcloud', 'Smartcloud'
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-smartcloud/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Tim Guibord"]
6
+ gem.email = ["timguibord@gmail.com"]
7
+ gem.description = %q{Official OmniAuth strategy for Smartcloud.}
8
+ gem.summary = %q{Official OmniAuth strategy for Smartcloud.}
9
+ gem.homepage = "https://github.com/tagCincy/omniauth-smartcloud"
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-smartcloud"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::Smartcloud::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
20
+ gem.add_development_dependency 'rspec'
21
+ gem.add_development_dependency 'rack-test'
22
+ gem.add_development_dependency 'simplecov'
23
+ gem.add_development_dependency 'webmock'
24
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Smartcloud do
4
+ subject do
5
+ OmniAuth::Strategies::Smartcloud.new({})
6
+ end
7
+
8
+ context "client options" do
9
+ it 'should have correct site' do
10
+ subject.options.client_options.site.should eq("https://apps.lotuslive.com")
11
+ end
12
+
13
+ it 'should have correct authorize url' do
14
+ subject.options.client_options.authorize_url.should eq('https://apps.lotuslive.com/manage/oauth2/authorize')
15
+ end
16
+
17
+ it 'should have correct token url' do
18
+ subject.options.client_options.token_url.should eq('https://apps.lotuslive.com/manage/oauth2/token')
19
+ end
20
+ end
21
+
22
+
23
+ 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-smartcloud'
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,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-smartcloud
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Tim Guibord
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !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: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: omniauth-oauth2
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.1'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-test
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: simplecov
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: webmock
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Official OmniAuth strategy for Smartcloud.
111
+ email:
112
+ - timguibord@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - .rspec
119
+ - Gemfile
120
+ - Guardfile
121
+ - README.md
122
+ - Rakefile
123
+ - lib/omniauth-smartcloud.rb
124
+ - lib/omniauth-smartcloud/version.rb
125
+ - lib/omniauth/strategies/smartcloud.rb
126
+ - omniauth-smartcloud.gemspec
127
+ - spec/omniauth/strategies/smartcloud_spec.rb
128
+ - spec/spec_helper.rb
129
+ homepage: https://github.com/tagCincy/omniauth-smartcloud
130
+ licenses: []
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 1.8.24
150
+ signing_key:
151
+ specification_version: 3
152
+ summary: Official OmniAuth strategy for Smartcloud.
153
+ test_files: []