exvo-auth 0.1.0

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,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Jacek Becela
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1 @@
1
+ gem install exvo-auth
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "exvo-auth"
8
+ gem.description = gem.summary = %Q{Sign in with Exvo account}
9
+ gem.email = "jacek.becela@gmail.com"
10
+ gem.homepage = "http://github.com/Exvo/Auth"
11
+ gem.authors = ["Jacek Becela"]
12
+ gem.add_dependency "oa-oauth", "0.0.1"
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/test_*.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "exvo-auth #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,53 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{exvo-auth}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Jacek Becela"]
12
+ s.date = %q{2010-06-23}
13
+ s.description = %q{Sign in with Exvo account}
14
+ s.email = %q{jacek.becela@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "LICENSE",
22
+ "README",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "exvo-auth.gemspec",
26
+ "lib/exvo-auth.rb",
27
+ "test/helper.rb",
28
+ "test/test_exvo_auth.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/Exvo/Auth}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.6}
34
+ s.summary = %q{Sign in with Exvo account}
35
+ s.test_files = [
36
+ "test/helper.rb",
37
+ "test/test_exvo_auth.rb"
38
+ ]
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<oa-oauth>, ["= 0.0.1"])
46
+ else
47
+ s.add_dependency(%q<oa-oauth>, ["= 0.0.1"])
48
+ end
49
+ else
50
+ s.add_dependency(%q<oa-oauth>, ["= 0.0.1"])
51
+ end
52
+ end
53
+
@@ -0,0 +1,85 @@
1
+ require 'omniauth/oauth'
2
+ require 'multi_json'
3
+
4
+ module ExvoAuth
5
+ module Strategies
6
+ class Base < OmniAuth::Strategies::OAuth2
7
+ def initialize(app, name, app_id, app_secret, options = {})
8
+ options[:site] ||= 'https://auth.exvo.com/'
9
+ super(app, name, app_id, app_secret, options)
10
+ end
11
+
12
+ def user_data
13
+ @data ||= MultiJson.decode(@access_token.get('/user.json'))
14
+ end
15
+
16
+ # Depending on requested scope and the fact that client app is trusted or not
17
+ # you can get nil values for some attributes even if they are set.
18
+ def user_info
19
+ {
20
+ 'nickname' => user_data['nickname'],
21
+ 'email' => user_data['email']
22
+ }
23
+ end
24
+
25
+ def auth_hash
26
+ OmniAuth::Utils.deep_merge(super, {
27
+ 'provider' => 'exvo',
28
+ 'uid' => user_data['id'],
29
+ 'user_info' => user_info,
30
+ 'extra' => { 'user_hash' => user_data }
31
+ })
32
+ end
33
+ end
34
+
35
+ class Interactive < Base
36
+ def initialize(app, app_id, app_secret, options = {})
37
+ super(app, :interactive, app_id, app_secret, options)
38
+ end
39
+
40
+ def request_phase(options = {})
41
+ super(:scope => request["scope"])
42
+ end
43
+ end
44
+
45
+ class NonInteractive < Base
46
+ def initialize(app, app_id, app_secret, options = {})
47
+ options[:callback_key] ||= "_callback"
48
+ super(app, :non_interactive, app_id, app_secret, options)
49
+ end
50
+
51
+ def request_phase(options = {})
52
+ redirect @client.non_interactive.authorize_url({:redirect_uri => callback_url, :scope => request["scope"]})
53
+ end
54
+
55
+ def callback_url
56
+ key = options[:callback_key]
57
+ value = request[key]
58
+
59
+ if value
60
+ super + "?" + Rack::Utils.build_query(key => value)
61
+ else
62
+ super
63
+ end
64
+ end
65
+
66
+ def fail!(message_key)
67
+ [200, { "Content-Type" => "application/javascript" }, [MultiJson.encode({ :message => "Not signed in!", :status => 403 })]]
68
+ end
69
+ end
70
+ end
71
+
72
+ module OAuth2
73
+ module Strategy
74
+ class NonInteractive < ::OAuth2::Strategy::WebServer
75
+ def authorize_params(options = {})
76
+ super(options).merge('type' => 'non_interactive')
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ OAuth2::Client.class_eval do
84
+ def non_interactive; ExvoAuth::OAuth2::Strategy::NonInteractive.new(self) end
85
+ end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ require 'exvo-auth'
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestExvoAuth < Test::Unit::TestCase
4
+ def test_something_for_real
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exvo-auth
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Jacek Becela
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-23 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: oa-oauth
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 0
30
+ - 1
31
+ version: 0.0.1
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description: Sign in with Exvo account
35
+ email: jacek.becela@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - LICENSE
42
+ - README
43
+ files:
44
+ - .gitignore
45
+ - LICENSE
46
+ - README
47
+ - Rakefile
48
+ - VERSION
49
+ - exvo-auth.gemspec
50
+ - lib/exvo-auth.rb
51
+ - test/helper.rb
52
+ - test/test_exvo_auth.rb
53
+ has_rdoc: true
54
+ homepage: http://github.com/Exvo/Auth
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options:
59
+ - --charset=UTF-8
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ requirements: []
77
+
78
+ rubyforge_project:
79
+ rubygems_version: 1.3.6
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Sign in with Exvo account
83
+ test_files:
84
+ - test/helper.rb
85
+ - test/test_exvo_auth.rb