omniauth-openbibid 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4c1a9efc79373de044706200033465d4c982cc2b
4
+ data.tar.gz: 6f7a1e72f50bf1dfed6fb2b374fded642d1352cf
5
+ SHA512:
6
+ metadata.gz: 9655d3752b050af44c72794bfca35cbf8eb3c1dc379e15aa1dcc9a20a59f5aa9cdeec53fdf30e2c17751f79d754e525c678c6150fc67497d672758a44f2621ea
7
+ data.tar.gz: 43cb70066653e84190a829d423a87d69e14982ef0d5ba4da4ade612b48d238290b0b2d44b0d070c3159b00807c6f5be1eed8ce580142d6ea96b09eba135afe7a
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-openbibid.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Andrew Fecheyr
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,39 @@
1
+ # Omniauth::Openbibid
2
+
3
+ OmniAuth strategy from mijn.bibliotheek.be. API docs at [https://mijn.bibliotheek.be/openbibid-api.html](https://mijn.bibliotheek.be/openbibid-api.html)
4
+
5
+ See [OmniAuth](https://github.com/intridea/omniauth)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-openbibid'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-openbibid
22
+
23
+ ## Usage
24
+
25
+ Usage in Rails:
26
+
27
+ ```ruby
28
+ Rails.application.config.middleware.use OmniAuth::Builder do
29
+ provider :openbibid, ENV['OPENBIBID_KEY'], ENV['OPENBIBID_SECRET']
30
+ end
31
+ ```
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/[my-github-username]/omniauth-openbibid/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,57 @@
1
+ require "omniauth/openbibid/version"
2
+ require 'omniauth-oauth'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Openbibid < OmniAuth::Strategies::OAuth
7
+ # Give your strategy a name.
8
+ option :name, "openbibid"
9
+
10
+ # This is where you pass the options you would pass when
11
+ # initializing your consumer from the OAuth gem.
12
+ option :client_options, { :site => 'https://staging-mijn.bibliotheek.be/openbibid/rest',
13
+ :request_token_path => "/requestToken",
14
+ :access_token_path => "/accessToken",
15
+ :authorize_path => "/auth/authorize"}
16
+
17
+ # These are called after authentication has succeeded. If
18
+ # possible, you should try to set the UID without making
19
+ # additional calls (if the user id is returned with the token
20
+ # or as a URI parameter). This may not be possible with all
21
+ # providers.
22
+ uid { access_token.params[:userId] }
23
+
24
+ info do
25
+ {
26
+ :name => raw_info['name'],
27
+ :location => raw_info['city']
28
+ }
29
+ end
30
+
31
+ extra do
32
+ {
33
+ 'raw_info' => raw_info
34
+ }
35
+ end
36
+
37
+ def raw_info
38
+ user_id = access_token.params[:userId]
39
+ body = access_token.get("/user/#{user_id}").body
40
+ xml_doc = Nokogiri::XML(body) do |config|
41
+ config.strict.noblanks
42
+ end
43
+ info = {}
44
+ info[:uid] = user_id
45
+ info[:email] = xml_doc.xpath('user/mbox').children.text
46
+ info[:username] = xml_doc.xpath('user/nick').children.text
47
+ info[:city] = xml_doc.xpath('user/city').children.text
48
+ info[:created_on] = xml_doc.xpath('user/createdOn').children.text
49
+ info[:gender] = xml_doc.xpath('user/gender').children.text
50
+ info[:lastLogin] = xml_doc.xpath('user/lastLogin').children.text
51
+ info[:status] = xml_doc.xpath('user/status').children.text
52
+ info[:birthdate] = xml_doc.xpath('user/dob').children.text
53
+ info
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Openbibid
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/openbibid/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-openbibid"
8
+ spec.version = Omniauth::Openbibid::VERSION
9
+ spec.authors = ["Andrew Fecheyr"]
10
+ spec.email = ["andrew@bedesign.be"]
11
+ spec.summary = "OmniAuth strategy for mijn.bibliotheek.be"
12
+ spec.description = "OmniAuth strategy for mijn.bibliotheek.be"
13
+ spec.homepage = "https://github.com/andruby/omniauth-openbibid"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-openbibid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Fecheyr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: OmniAuth strategy for mijn.bibliotheek.be
42
+ email:
43
+ - andrew@bedesign.be
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/omniauth/openbibid.rb
54
+ - lib/omniauth/openbibid/version.rb
55
+ - omniauth-openbibid.gemspec
56
+ homepage: https://github.com/andruby/omniauth-openbibid
57
+ licenses:
58
+ - MIT
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.4.5
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: OmniAuth strategy for mijn.bibliotheek.be
80
+ test_files: []