omniauth-zotero 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
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
+ *.swp
19
+ *.swo
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-zotero.gemspec
4
+ gemspec
5
+
6
+ gem 'omniauth-oauth'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jason Morrison
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,67 @@
1
+ # OmniAuth Zotero
2
+
3
+ This is the unofficial OmniAuth strategy for authenticating to Zotero. To
4
+ use it, you'll need to sign up for an OAuth Client Key and Secret
5
+ on the [Zotero Applications Page](https://www.zotero.org/oauth/apps).
6
+
7
+ You can then use the API key provided by this strategy to authenticate
8
+ against and use the
9
+ [Zotero Server API](https://www.zotero.org/support/dev/server_api/oauth).
10
+
11
+ Heavily inspired by Logan Lowell's
12
+ [OmniAuth-Mendeley](https://github.com/fractaloop/omniauth-mendeley) gem.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'omniauth-zotero'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install omniauth-zotero
27
+
28
+ ## Usage
29
+
30
+ First, use the OmniAuth Zotero middleware:
31
+
32
+ ```ruby
33
+ # For Rack apps, in your config.ru
34
+ use OmniAuth::Builder do
35
+ provider :zotero, ENV['ZOTERO_KEY'], ENV['ZOTERO_SECRET']
36
+ end
37
+
38
+ # For Rails apps, in config/initializers/omniauth.rb
39
+ Rails.application.config.middleware.use OmniAuth::Builder do
40
+ provider :zotero, ENV['ZOTERO_KEY'], ENV['ZOTERO_SECRET']
41
+ end
42
+ ```
43
+
44
+ Then, read the OmniAuth documentation on
45
+ [Integrating OmniAuth Into Your Application](https://github.com/intridea/omniauth#integrating-omniauth-into-your-application).
46
+
47
+ ## Example
48
+
49
+ In the `example/` directory, run the provided Rack application for a demo:
50
+
51
+ $ cd example/
52
+ $ bundle
53
+ $ ZOTERO_KEY=abc123 ZOTERO_SECRET=def456 rackup
54
+
55
+ Then visit [localhost:9292](http://localhost:9292) to try it out.
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create new Pull Request
64
+
65
+ ## License
66
+
67
+ See accompanying LICENSE file.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ gem 'sinatra'
4
+ gem 'multi_json'
5
+ gem 'omniauth-oauth'
6
+ gem 'omniauth-zotero', :path => '../'
@@ -0,0 +1,27 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra/base'
3
+ require 'omniauth-zotero'
4
+
5
+ class App < Sinatra::Base
6
+ get '/' do
7
+ redirect '/auth/zotero'
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 :zotero, ENV['ZOTERO_KEY'], ENV['ZOTERO_SECRET']
25
+ end
26
+
27
+ run App.new
@@ -0,0 +1,2 @@
1
+ require "omniauth/zotero/version"
2
+ require "omniauth/strategies/zotero"
@@ -0,0 +1,51 @@
1
+ require 'omniauth-oauth'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Zotero < OmniAuth::Strategies::OAuth
6
+ option :name, 'zotero'
7
+
8
+ option :client_options, {
9
+ :site => 'https://www.zotero.org',
10
+ :request_token_path => '/oauth/request',
11
+ :access_token_path => '/oauth/access',
12
+ :authorize_path => '/oauth/authorize',
13
+ :scheme => :query_string
14
+ }
15
+
16
+ uid do
17
+ raw_info['userID'].to_i
18
+ end
19
+
20
+ info do
21
+ {
22
+ 'name' => raw_info['username']
23
+ }
24
+ end
25
+
26
+ credentials do
27
+ {
28
+ 'token' => raw_info['oauth_token'],
29
+ 'secret' => raw_info['oauth_token_secret']
30
+ }
31
+ end
32
+
33
+ extra do
34
+ {
35
+ 'raw_info' => raw_info
36
+ }
37
+ end
38
+
39
+ private
40
+
41
+ def raw_info
42
+ access_token.params
43
+ end
44
+
45
+ def callback_phase
46
+ session['oauth'][name.to_s]['callback_confirmed'] = true
47
+ super
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Zotero
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth/zotero/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jason Morrison"]
6
+ gem.email = ["jason.p.morrison@gmail.com"]
7
+ gem.summary = %q{Zotero strategy of OmniAuth}
8
+ gem.homepage = "https://github.com/jasonm/omniauth-zotero"
9
+
10
+ gem.files = `git ls-files`.split($\)
11
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.name = "omniauth-zotero"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Omniauth::Zotero::VERSION
16
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-zotero
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Morrison
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-05 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description:
15
+ email:
16
+ - jason.p.morrison@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - example/Gemfile
27
+ - example/config.ru
28
+ - lib/omniauth-zotero.rb
29
+ - lib/omniauth/strategies/zotero.rb
30
+ - lib/omniauth/zotero/version.rb
31
+ - omniauth-zotero.gemspec
32
+ homepage: https://github.com/jasonm/omniauth-zotero
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.8.24
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Zotero strategy of OmniAuth
56
+ test_files: []