omniauth-unipass 0.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,32 @@
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
+
19
+ yardoc/
20
+ .rvmrc
21
+
22
+ # System/IDE files
23
+ Desktop.ini
24
+ Thumbs.db
25
+ nbproject
26
+ .DS_Store
27
+ .idea
28
+ .redcar
29
+ \#*#
30
+ *.swp
31
+ *.swo
32
+ *~
data/README ADDED
File without changes
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # OmniAuth GitHub
2
+
3
+ This is the official OmniAuth strategy for authenticating to Unipass.
4
+
5
+ ## Basic Usage
6
+
7
+ use OmniAuth::Builder do
8
+ provider :unipas, ENV['CLIENT_ID'], ENV['CLIENT_SECRET']
9
+ end
10
+
11
+ ## Advanced Usage
12
+
13
+ use OmniAuth::Builder do
14
+ provider :unipas, ENV['CLIENT_ID'], ENV['CLIENT_SECRET'],
15
+ :site => ENV['SITE'],
16
+ :api_site => ENV['API_SITE'],
17
+ :setup => true
18
+ end
19
+
20
+ ## License
21
+
22
+ Copyright (c) 2011 Connectmedica.com.
23
+
24
+ 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:
25
+
26
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
27
+
28
+ 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,50 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Unipass < OmniAuth::Strategies::OAuth2
7
+
8
+ def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
9
+ options = options.dup
10
+ name = options.delete(:name) || 'unipass'
11
+ @site = options.delete(:site) || 'http://test.stworzonedlazdrowia.pl/'
12
+ @api_site = options.delete(:api_site) || 'http://test.stworzonedlazdrowia.pl/api/1'
13
+
14
+ client_options = {
15
+ :site => @site,
16
+ :authorize_url => '/oauth2/authorize',
17
+ :token_url => '/oauth2/token'
18
+ }.merge(options[:client_options] || {})
19
+
20
+ super(app, name, client_id, client_secret, client_options, options, &block)
21
+ end
22
+
23
+ protected
24
+
25
+ def auth_hash
26
+ OmniAuth::Utils.deep_merge(super, {
27
+ 'uid' => user_data['id'],
28
+ 'user_info' => user_info,
29
+ 'extra' => {'user_hash' => user_data}
30
+ })
31
+ end
32
+
33
+ def user_info
34
+ {
35
+ 'first_name' => user_data['first_name'],
36
+ 'last_name' => user_data['last_name']
37
+ }
38
+ end
39
+
40
+ def user_data
41
+ session[:access_token] = @access_token.token
42
+ session[:access_token_expires_at] = @access_token.expires_at
43
+ session[:refresh_token] = @access_token.refresh_token
44
+
45
+ @data ||= MultiJson.decode(@access_token.get("#{@api_site}/me").response.env[:body])
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Unipass
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-unipass/version"
2
+ require 'omniauth/strategies/unipass'
@@ -0,0 +1,19 @@
1
+ require File.expand_path('../lib/omniauth-unipass/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ['Aleksadner Dąbrowski', 'Karol Sarnacki']
5
+ gem.email = ['aleksander.dabrowski@connectmedica.com', 'karol.sarnacki@connectmedica.pl']
6
+ gem.description = 'OmniAuth strategy for Unipass'
7
+ gem.summary = 'OmniAuth strategy for Unipass'
8
+ gem.homepage = 'https://github.com/tjeden/omniauth-unipass'
9
+
10
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ gem.name = 'omniauth-unipass'
14
+ gem.require_paths = ['lib']
15
+ gem.version = OmniAuth::Unipass::VERSION
16
+
17
+ gem.add_dependency 'omniauth', '0.3.0'
18
+ gem.add_dependency 'multi_json'
19
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-unipass
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aleksadner Dąbrowski
9
+ - Karol Sarnacki
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2011-11-03 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: omniauth
17
+ requirement: &9256760 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - =
21
+ - !ruby/object:Gem::Version
22
+ version: 0.3.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *9256760
26
+ - !ruby/object:Gem::Dependency
27
+ name: multi_json
28
+ requirement: &9256340 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *9256340
37
+ description: OmniAuth strategy for Unipass
38
+ email:
39
+ - aleksander.dabrowski@connectmedica.com
40
+ - karol.sarnacki@connectmedica.pl
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - .gitignore
46
+ - README
47
+ - README.md
48
+ - lib/omniauth-unipass.rb
49
+ - lib/omniauth-unipass/version.rb
50
+ - lib/omniauth/strategies/unipass.rb
51
+ - omniauth-unipass.gemspec
52
+ homepage: https://github.com/tjeden/omniauth-unipass
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 1.8.10
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: OmniAuth strategy for Unipass
76
+ test_files: []
77
+ has_rdoc: