omniauth-mendeley 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-mendeley.gemspec
4
+ gemspec
5
+
6
+ gem 'omniauth-oauth'
7
+
8
+ group :development, :test do
9
+ gem 'guard'
10
+ gem 'guard-rspec'
11
+ gem 'guard-bundler'
12
+ gem 'growl'
13
+ gem 'rb-fsevent'
14
+ gem 'multi_json'
15
+ 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(/^.+\.gemspec/)
10
+ end
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # OmniAuth Mendeley
2
+
3
+ This is the unofficial OmniAuth strategy for authenticating to Mendeley. To
4
+ use it, you'll need to sign up for an OAuth Application ID and Secret
5
+ on the [Mendeley Applications Page](https://dev.mendeley.com/applications/register/).
6
+
7
+ ## Basic Usage
8
+
9
+ use OmniAuth::Builder do
10
+ provider :mendeley, ENV['MENDELEY_KEY'], ENV['MENDELEY_SECRET']
11
+ end
12
+
13
+ ## License
14
+
15
+ Copyright (c) 2012 Logan Lowell
16
+
17
+ 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:
18
+
19
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
20
+
21
+ 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,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/example/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ gem 'sinatra'
4
+ gem 'multi_json'
5
+ gem 'omniauth-mendeley', :path => '../'
6
+ #gem 'omniauth-mendeley'
data/example/config.ru ADDED
@@ -0,0 +1,27 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra/base'
3
+ require 'omniauth-mendeley'
4
+
5
+ class App < Sinatra::Base
6
+ get '/' do
7
+ redirect '/auth/mendeley'
8
+ end
9
+
10
+ get '/auth/:provider/callback' do
11
+ content_type 'application/json'
12
+ MultiJson.encode(request.env)
13
+ end
14
+
15
+ get '/auth/failure' do
16
+ content_type 'application/json'
17
+ MultiJson.encode(request.env)
18
+ end
19
+ end
20
+
21
+ use Rack::Session::Cookie
22
+
23
+ use OmniAuth::Builder do
24
+ provider :mendeley, ENV['MENDELEY_CONSUMER_KEY'], ENV['MENDELEY_CONSUMER_SECRET']
25
+ end
26
+
27
+ run App.new
@@ -0,0 +1,2 @@
1
+ require "omniauth/mendeley/version"
2
+ require 'omniauth/strategies/mendeley'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Mendeley
3
+ VERSION = "0.2"
4
+ end
5
+ end
@@ -0,0 +1,41 @@
1
+ require 'omniauth/strategies/oauth'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Mendeley < OmniAuth::Strategies::OAuth
6
+ option :name, "mendeley"
7
+
8
+ option :client_options, {
9
+ :site => 'https://api.mendeley.com',
10
+ :request_token_path => '/oauth/request_token/',
11
+ :access_token_path => '/oauth/access_token/',
12
+ :authorize_path => '/oauth/authorize/',
13
+ :http_method => :get,
14
+ :scheme => :query_string
15
+ }
16
+
17
+ uid do
18
+ user_data['profile_id']
19
+ end
20
+
21
+ info do
22
+ user_data.delete_if { |k, v| v.nil? || v.length == 0 }
23
+ end
24
+
25
+ extra do
26
+ user_data
27
+ end
28
+
29
+ def user_data
30
+ @info ||= MultiJson.decode(@access_token.get('/oapi/profiles/info/me').body)['main']
31
+ end
32
+
33
+ # For callback_confirmed to true so omniauth-oauth will set the
34
+ # :oauth_verifier during callback
35
+ def callback_phase
36
+ session['oauth'][name.to_s]['callback_confirmed'] = true
37
+ super
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'omniauth/mendeley/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'omniauth-mendeley'
7
+ s.version = OmniAuth::Mendeley::VERSION
8
+ s.authors = ['Logan Lowell']
9
+ s.email = ['fractaloop@thefrontside.net']
10
+ s.summary = 'Mendeley strategy for OmniAuth'
11
+ s.homepage = 'https://github.com/fractaloop/omniauth-mendeley'
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
16
+ s.require_paths = ['lib']
17
+
18
+ s.add_runtime_dependency 'omniauth-oauth', '~> 1.0.0'
19
+
20
+ s.add_development_dependency 'rspec', '~> 2.7.0'
21
+ s.add_development_dependency 'rake'
22
+ s.add_development_dependency 'webmock'
23
+ s.add_development_dependency 'rack-test'
24
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe "OmniAuth::Strategies::Mendeley" do
4
+ subject do
5
+ OmniAuth::Strategies::Mendeley.new(nil, @options || {})
6
+ end
7
+
8
+ context 'client options' do
9
+ it 'has correct Mendeley site' do
10
+ subject.options.client_options.site.should eq('https://api.mendeley.com')
11
+ end
12
+
13
+ it 'has correct request token path' do
14
+ subject.options.client_options.request_token_path.should eq('/oauth/request_token/')
15
+ end
16
+
17
+ it 'has correct access token path' do
18
+ subject.options.client_options.access_token_path.should eq('/oauth/access_token/')
19
+ end
20
+
21
+ it 'has correct authorize path' do
22
+ subject.options.client_options.authorize_path.should eq('/oauth/authorize/')
23
+ end
24
+ end
25
+
26
+ context '#uid' do
27
+ before :each do
28
+ subject.stub(:user_data) { { 'profile_id' => '123' } }
29
+ end
30
+
31
+ it 'returns the id from user_data' do
32
+ subject.uid.should eq('123')
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,9 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'rspec'
5
+ require 'omniauth'
6
+ require 'omniauth-mendeley'
7
+
8
+ RSpec.configure do |config|
9
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-mendeley
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Logan Lowell
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: &70351434732140 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70351434732140
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70351440557560 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.7.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70351440557560
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70351440557180 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70351440557180
47
+ - !ruby/object:Gem::Dependency
48
+ name: webmock
49
+ requirement: &70351440556720 !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: *70351440556720
58
+ - !ruby/object:Gem::Dependency
59
+ name: rack-test
60
+ requirement: &70351440556300 !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: *70351440556300
69
+ description:
70
+ email:
71
+ - fractaloop@thefrontside.net
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - Gemfile
79
+ - Guardfile
80
+ - README.md
81
+ - Rakefile
82
+ - example/Gemfile
83
+ - example/config.ru
84
+ - lib/omniauth-mendeley.rb
85
+ - lib/omniauth/mendeley/version.rb
86
+ - lib/omniauth/strategies/mendeley.rb
87
+ - omniauth-mendeley.gemspec
88
+ - spec/omniauth/strategies/mendeley_spec.rb
89
+ - spec/spec_helper.rb
90
+ homepage: https://github.com/fractaloop/omniauth-mendeley
91
+ licenses: []
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 1.8.10
111
+ signing_key:
112
+ specification_version: 3
113
+ summary: Mendeley strategy for OmniAuth
114
+ test_files:
115
+ - spec/omniauth/strategies/mendeley_spec.rb
116
+ - spec/spec_helper.rb