omniauth-xauth 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/omniauth/strategies/xauth.rb +60 -0
- data/lib/omniauth-xauth/version.rb +5 -0
- data/lib/omniauth-xauth.rb +2 -0
- data/omniauth-xauth.gemspec +24 -0
- metadata +85 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'omniauth/oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
|
7
|
+
# This code is originally from oa-omniauth.gem and applied some fixes for OmniAuth 1.0.
|
8
|
+
class XAuth
|
9
|
+
include OmniAuth::Strategy
|
10
|
+
|
11
|
+
args [:consumer_key, :consumer_secret]
|
12
|
+
|
13
|
+
option :consumer_options, {}
|
14
|
+
|
15
|
+
def request_phase
|
16
|
+
session['oauth'] ||= {}
|
17
|
+
if env['REQUEST_METHOD'] == 'GET'
|
18
|
+
get_credentials
|
19
|
+
else
|
20
|
+
session['omniauth.xauth'] = { 'x_auth_mode' => 'client_auth', 'x_auth_username' => request['username'], 'x_auth_password' => request['password'] }
|
21
|
+
redirect callback_path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_credentials
|
26
|
+
OmniAuth::Form.build(consumer_options[:title] || "xAuth Credentials") do
|
27
|
+
text_field 'Username', 'username'
|
28
|
+
password_field 'Password', 'password'
|
29
|
+
end.to_response
|
30
|
+
end
|
31
|
+
|
32
|
+
def consumer
|
33
|
+
::OAuth::Consumer.new(consumer_key, consumer_secret, consumer_options.merge(options[:client_options] || options[:consumer_options] || {}))
|
34
|
+
end
|
35
|
+
|
36
|
+
def callback_phase
|
37
|
+
@access_token = consumer.get_access_token(nil, {}, session['omniauth.xauth'])
|
38
|
+
super
|
39
|
+
rescue ::Net::HTTPFatalError => e
|
40
|
+
fail!(:service_unavailable, e)
|
41
|
+
rescue ::OAuth::Unauthorized => e
|
42
|
+
fail!(:invalid_credentials, e)
|
43
|
+
rescue ::MultiJson::DecodeError => e
|
44
|
+
fail!(:invalid_response, e)
|
45
|
+
ensure
|
46
|
+
session['omniauth.xauth'] = nil
|
47
|
+
end
|
48
|
+
|
49
|
+
credentials do
|
50
|
+
{'token' => @access_token.token, 'secret' => @access_token.secret}
|
51
|
+
end
|
52
|
+
|
53
|
+
extra do
|
54
|
+
{'access_token' => @access_token}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
OmniAuth.config.add_camelization 'xauth', 'XAuth'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-xauth/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-xauth"
|
7
|
+
s.version = OmniAuth::XAuth::VERSION
|
8
|
+
s.authors = ["aereal"]
|
9
|
+
s.email = ["aereal@kerare.org"]
|
10
|
+
s.homepage = "https://github.com/aereal/omniauth-xauth"
|
11
|
+
s.summary = %q{Abstract XAuth strategy for OmniAuth}
|
12
|
+
s.description = %q{Abstract XAuth strategy for OmniAuth}
|
13
|
+
|
14
|
+
s.rubyforge_project = "omniauth-xauth"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_runtime_dependency 'omniauth'
|
22
|
+
s.add_runtime_dependency 'oauth'
|
23
|
+
s.add_runtime_dependency 'multi_json'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-xauth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- aereal
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-12-05 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth
|
16
|
+
requirement: &70139320703060 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70139320703060
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: oauth
|
27
|
+
requirement: &70139320702020 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70139320702020
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: multi_json
|
38
|
+
requirement: &70139320701480 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70139320701480
|
47
|
+
description: Abstract XAuth strategy for OmniAuth
|
48
|
+
email:
|
49
|
+
- aereal@kerare.org
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- Rakefile
|
57
|
+
- lib/omniauth-xauth.rb
|
58
|
+
- lib/omniauth-xauth/version.rb
|
59
|
+
- lib/omniauth/strategies/xauth.rb
|
60
|
+
- omniauth-xauth.gemspec
|
61
|
+
homepage: https://github.com/aereal/omniauth-xauth
|
62
|
+
licenses: []
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project: omniauth-xauth
|
81
|
+
rubygems_version: 1.8.12
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Abstract XAuth strategy for OmniAuth
|
85
|
+
test_files: []
|