omniauth-miso 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ coverage
6
+ .project
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ree
6
+ - jruby
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ # Specify your gem's dependencies in omniauth-bitly.gemspec
5
+ gemspec
@@ -0,0 +1,41 @@
1
+ # OmniAuth Miso
2
+
3
+ This gem contains the Miso strategy for OmniAuth.
4
+
5
+ Miso uses the OAuth 1.0 flow, you can read about it here: http://gomiso.com/developers/authentication
6
+
7
+ ## How To Use It
8
+
9
+ Usage is as per any other OmniAuth 1.0 strategy.Add the strategy to your Rails 'Gemfile':
10
+
11
+ gem 'omniauth-miso'
12
+
13
+ You can pull them in directly from github e.g.:
14
+
15
+ gem 'omniauth-miso', :git => 'https://github.com/judearasu/omniauth-miso.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 :miso, "consumer_key", "consumer_secret"
21
+ end
22
+
23
+ Now just follow the README at: https://github.com/intridea/omniauth
24
+
25
+ ## Supported Rubies
26
+
27
+ OmniAuth Miso is tested under 1.8.7, 1.9.2, 1.9.3,ree and JRuby.
28
+
29
+ [![CI Build
30
+ Status](https://secure.travis-ci.org/judearasu/omniauth-miso.png)](http://travis-ci.org/judearasu/omniauth-miso)
31
+
32
+
33
+ ## License
34
+
35
+ Copyright (c) 2012 by Jude Arasu
36
+
37
+ 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:
38
+
39
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
40
+
41
+ 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.
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new
10
+
11
+ desc 'Run specs'
12
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ gem 'sinatra'
4
+ gem 'multi_json'
5
+ gem 'omniauth-miso', :path => '../'
6
+ gem 'rack'
@@ -0,0 +1,42 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra/base'
3
+ require 'omniauth-miso'
4
+
5
+ ENV['CLIENT_ID']='L342xgomRJ4oTCL7D9cQ'
6
+ ENV['CLIENT_SECRET']='xMTTX0vZ25C6FGOmLOn53je9OQaBC8P21iplqqOH'
7
+
8
+
9
+
10
+ use Rack::Session::Cookie
11
+
12
+ use OmniAuth::Builder do
13
+ provider :miso, ENV['CLIENT_ID'], ENV['CLIENT_SECRET']
14
+ end
15
+
16
+ class App < Sinatra::Base
17
+ get '/' do
18
+ <<-HTML
19
+ <ul>
20
+ <li><a href='/auth/miso'>Sign in with Miso</a></li>
21
+ </ul>
22
+ HTML
23
+ end
24
+
25
+ get '/auth/miso/callback' do
26
+ puts "THE RESULT HASH: #{request.env['omniauth.auth']}"
27
+ <<-HTML
28
+ #{:nickname}
29
+ HTML
30
+ end
31
+
32
+ get '/auth/failure' do
33
+ content_type 'text/plain'
34
+ request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
35
+ end
36
+
37
+
38
+ end
39
+
40
+
41
+ run App.new
42
+
@@ -0,0 +1,2 @@
1
+ require "omniauth-miso/version"
2
+ require 'omniauth/strategies/miso'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Miso
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,43 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Miso < OmniAuth::Strategies::OAuth
7
+ option :name, "miso"
8
+ option :client_options,{:site=>'https://gomiso.com',
9
+ :authorize_url => 'https://gomiso.com/oauth/authorize',
10
+ :token_url =>'https://gomiso.com/oauth/access_token'
11
+ }
12
+
13
+
14
+ uid{ raw_info['id'] }
15
+ info do
16
+ {
17
+ :id => raw_info['id'],
18
+ :nickname => raw_info['nickname'],
19
+ :name => raw_info['name'],
20
+ :username => raw_info['username'],
21
+ :full_name => raw_info['full_name'],
22
+ :profile_image_url => raw_info['profile_image_url'],
23
+ :image => raw_info['image'],
24
+ :description => raw_info['description'],
25
+ :location=>raw_info['location'],
26
+ :urls =>{ 'Website' => raw_info['url']},
27
+ :user_id=>raw_info['user_id']
28
+ }
29
+ end
30
+ extra do
31
+ { :raw_info => raw_info }
32
+ end
33
+
34
+ def raw_info
35
+ @raw_info ||= MultiJson.decode(@access_token.get('/api/oauth/v1/users/show.json').body)['user']
36
+ rescue ::Errno::ETIMEDOUT
37
+ raise ::Timeout::Error
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+ OmniAuth.config.add_camelization 'gomiso', 'Miso'
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../lib/omniauth-miso/version', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.authors = ["Jude Arasu"]
5
+ s.email = ["judearasu@genlinux.org"]
6
+ s.description = %q{OmniAuth strategy for Miso.}
7
+ s.summary = %q{OmniAuth strategy for Miso.}
8
+ s.homepage = "https://github.com/judearasu/omniauth-miso"
9
+
10
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
+ s.files = `git ls-files`.split("\n")
12
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ s.name = "omniauth-miso"
14
+ s.require_paths = ["lib"]
15
+ s.version = OmniAuth::Miso::VERSION
16
+
17
+ s.add_dependency 'omniauth', '~> 1.0'
18
+ s.add_dependency 'omniauth-oauth'
19
+ s.add_development_dependency 'rspec', '~> 2.7'
20
+ s.add_development_dependency 'rack-test'
21
+ s.add_development_dependency 'simplecov'
22
+ s.add_development_dependency 'webmock'
23
+ s.add_dependency 'httpauth'
24
+ end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-miso'
3
+ require 'base64'
4
+
5
+ describe OmniAuth::Strategies::Miso do
6
+ before :each do
7
+ @request = double('Request')
8
+ @request.stub(:params) { {} }
9
+ @request.stub(:cookies) { {} }
10
+
11
+ @client_id = '123'
12
+ @client_secret = '53cr3tz'
13
+ @options = {:client_options => {:site => 'https://gomiso.com/',:authorize_url=>'/oauth/authorize'}}
14
+ end
15
+
16
+ subject do
17
+ args = [@client_id, @client_secret, @options].compact
18
+ OmniAuth::Strategies::Miso.new(nil, *args).tap do |strategy|
19
+ strategy.stub(:request) { @request }
20
+ end
21
+ end
22
+ context "client options" do
23
+
24
+ it 'has correct miso name' do
25
+ subject.options.name.should eq('miso')
26
+ end
27
+
28
+ it 'has correct site name' do
29
+ subject.options.client_options.site.should eq('https://gomiso.com/')
30
+ end
31
+
32
+ it 'has correct authorize url' do
33
+ subject.options.client_options[:authorize_url].should eq('/oauth/authorize')
34
+ end
35
+ end
36
+ context '#info' do
37
+ before :each do
38
+ @raw_info = {
39
+ 'id' => '123',
40
+ 'description' => '',
41
+ 'full_name' => 'Jude Arasu',
42
+ 'image' => '',
43
+ 'location' => '',
44
+ 'name' => '',
45
+ 'nickname' => '',
46
+ 'profile_image_url' => 'http://gomiso.com/uploads/BAhbCFsHOgZmIiEyMDEyLzA3LzA3LzA1LzQxLzI5Lzc0OC9maWxlWwc6BmU6CHBuZ1sIOgZwOgp0aHVtYiILODB4ODAj.png',
47
+ 'urls' => {'Website'=> 'http://judearasu.github.com'},'username' => 'judearasu'
48
+ }
49
+ subject.stub(:raw_info) { @raw_info }
50
+ end
51
+
52
+ it 'returns the id from raw_info' do
53
+ subject.info[:id].should eq('123')
54
+ end
55
+ it 'returns the description from raw_info' do
56
+ subject.info[:description].should eq('')
57
+ end
58
+ it 'returns the full name from raw_info' do
59
+ subject.info[:full_name].should eq('Jude Arasu')
60
+ end
61
+ it 'returns the image from raw_info' do
62
+ subject.info[:image].should eq('')
63
+ end
64
+ it 'returns the location from raw_info' do
65
+ subject.info[:location].should eq('')
66
+ end
67
+ it 'returns the name from raw_info' do
68
+ subject.info[:name].should eq('')
69
+ end
70
+ it 'returns the nickname from raw_info' do
71
+ subject.info[:nickname].should eq('')
72
+ end
73
+ it 'returns the profile image url from raw_info' do
74
+ subject.info[:profile_image_url].should eq('http://gomiso.com/uploads/BAhbCFsHOgZmIiEyMDEyLzA3LzA3LzA1LzQxLzI5Lzc0OC9maWxlWwc6BmU6CHBuZ1sIOgZwOgp0aHVtYiILODB4ODAj.png')
75
+ end
76
+ it 'returns the website from raw_info' do
77
+ subject.info[:urls].should be_a(Hash)
78
+
79
+ end
80
+ it 'returns the username from raw_info' do
81
+ subject.info[:username].should eq('judearasu')
82
+ end
83
+
84
+ end
85
+ 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-miso'
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,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-miso
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jude Arasu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &22320640 !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: *22320640
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth
27
+ requirement: &22319020 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *22319020
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &22348820 !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: *22348820
47
+ - !ruby/object:Gem::Dependency
48
+ name: rack-test
49
+ requirement: &22347060 !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: *22347060
58
+ - !ruby/object:Gem::Dependency
59
+ name: simplecov
60
+ requirement: &22345440 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *22345440
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: &22343600 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *22343600
80
+ - !ruby/object:Gem::Dependency
81
+ name: httpauth
82
+ requirement: &22342440 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: *22342440
91
+ description: OmniAuth strategy for Miso.
92
+ email:
93
+ - judearasu@genlinux.org
94
+ executables: []
95
+ extensions: []
96
+ extra_rdoc_files: []
97
+ files:
98
+ - .gitignore
99
+ - .travis.yml
100
+ - Gemfile
101
+ - README.md
102
+ - Rakefile
103
+ - example/Gemfile
104
+ - example/config.ru
105
+ - lib/omniauth-miso.rb
106
+ - lib/omniauth-miso/version.rb
107
+ - lib/omniauth/strategies/miso.rb
108
+ - omniauth-miso.gemspec
109
+ - spec/omniauth/strategies/miso_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: https://github.com/judearasu/omniauth-miso
112
+ licenses: []
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 1.8.17
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: OmniAuth strategy for Miso.
135
+ test_files: []