omniauth-delegated-authentication 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,56 @@
|
|
1
|
+
require 'omniauth'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class DelegatedAuthentication
|
6
|
+
include OmniAuth::Strategy
|
7
|
+
|
8
|
+
args [:app_id, :app_secret]
|
9
|
+
|
10
|
+
option :client_options, {}
|
11
|
+
|
12
|
+
attr_accessor :consent_token
|
13
|
+
|
14
|
+
# AFIK there is no DelegatedAuthentication gem currently available, so this developer
|
15
|
+
# strategy assumes that this class will be overwritten by the provider strategy
|
16
|
+
def client
|
17
|
+
::DelegatedAuthentication.new(options[:app_id], options[:app_secret], nil, nil, options[:privacy_url], callback_url)
|
18
|
+
end
|
19
|
+
|
20
|
+
def callback_url
|
21
|
+
full_host + script_name + callback_path
|
22
|
+
end
|
23
|
+
|
24
|
+
# Assumes that the provider strategy client method includes `getConsentUrl`
|
25
|
+
def request_phase
|
26
|
+
redirect client.getConsentUrl(options[:scope], nil, callback_url, nil)
|
27
|
+
end
|
28
|
+
|
29
|
+
def callback_phase
|
30
|
+
if request.params['error'] || request.params['error_reason']
|
31
|
+
raise CallbackError.new(request.params['error'], request.params['error_description'] || request.params['error_reason'], request.params['error_uri'])
|
32
|
+
end
|
33
|
+
|
34
|
+
self.consent_token = process_consent_token
|
35
|
+
self.consent_token = client.refreshConsentToken(self.consent_token) unless consent_token.isValid?
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def process_consent_token
|
41
|
+
consent_token = request.params['ConsentToken']
|
42
|
+
client.processConsentToken(consent_token)
|
43
|
+
end
|
44
|
+
|
45
|
+
class CallbackError < StandardError
|
46
|
+
attr_accessor :error, :error_reason, :error_uri
|
47
|
+
|
48
|
+
def initialize(error, error_reason=nil, error_uri=nil)
|
49
|
+
self.error = error
|
50
|
+
self.error_reason = error_reason
|
51
|
+
self.error_uri = error_uri
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'omniauth-delegated-authentication'
|
3
|
+
s.version = '0.1'
|
4
|
+
s.date = '2013-01-29'
|
5
|
+
s.summary = "Delegated Authentication protocol developer strategy for Omniauth"
|
6
|
+
s.description = s.summary
|
7
|
+
s.authors = ["Joshua Kelly"]
|
8
|
+
s.email = 'jdjkelly@gmail.com'
|
9
|
+
s.files = `git ls-files`.split("\n")
|
10
|
+
s.homepage = 'http://rubygems.org/gems/omniauth-delegated-authentication'
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-delegated-authentication
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joshua Kelly
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Delegated Authentication protocol developer strategy for Omniauth
|
15
|
+
email: jdjkelly@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/omniauth-delegated-authentication.rb
|
21
|
+
- lib/omniauth-delegated-authentication/version.rb
|
22
|
+
- lib/omniauth/strategies/omniauth-delegated-authentication.rb
|
23
|
+
- omniauth-delegated-authentication-0.1.gem
|
24
|
+
- omniauth-delegated-authentication.gemspec
|
25
|
+
homepage: http://rubygems.org/gems/omniauth-delegated-authentication
|
26
|
+
licenses: []
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
none: false
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ! '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 1.8.23
|
46
|
+
signing_key:
|
47
|
+
specification_version: 3
|
48
|
+
summary: Delegated Authentication protocol developer strategy for Omniauth
|
49
|
+
test_files: []
|