sq_auth 0.0.25 → 0.0.26
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.
data/examples/client.rb
CHANGED
@@ -92,6 +92,10 @@ module SqAuth
|
|
92
92
|
@session_provider.create_session_for_current_user sqauthsession
|
93
93
|
end
|
94
94
|
|
95
|
+
def save_username_for_current_user username
|
96
|
+
@session_provider.username = username
|
97
|
+
end
|
98
|
+
|
95
99
|
def current_user_ip= ip
|
96
100
|
if @gateway_ip
|
97
101
|
@session_provider.user.user_ip = @gateway_ip
|
@@ -100,6 +104,10 @@ module SqAuth
|
|
100
104
|
end
|
101
105
|
end
|
102
106
|
|
107
|
+
def current_user_name= name
|
108
|
+
@session_provider.user.user_name = name
|
109
|
+
end
|
110
|
+
|
103
111
|
def login_to
|
104
112
|
uri = @session_provider.auth_server_uri
|
105
113
|
uri.path = "#@login_path"
|
@@ -6,10 +6,19 @@ module SqAuth
|
|
6
6
|
end
|
7
7
|
def self.alter_environment options={}
|
8
8
|
if defined?(Rails)
|
9
|
-
Rails
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
# Rails::Engine?
|
10
|
+
if (Rails.application.nil?)
|
11
|
+
options[:engine].instance_eval do
|
12
|
+
initializer "Rails::Engine.add_sq_auth" do |app|
|
13
|
+
app.middleware.use SqAuth::SqAuthIntegration::SqAuthRack::Middleware
|
14
|
+
end
|
15
|
+
end
|
16
|
+
else
|
17
|
+
Rails.application.class.instance_eval do
|
18
|
+
# cookie in rails enabled by default
|
19
|
+
# config.middleware.use Rack::Session::Cookie, :expire_after => 2592000
|
20
|
+
config.middleware.use SqAuth::SqAuthIntegration::SqAuthRack::Middleware
|
21
|
+
end
|
13
22
|
end
|
14
23
|
elsif defined?(Sinatra)
|
15
24
|
if options[:klass].respond_to?(:use)
|
@@ -22,6 +31,7 @@ module SqAuth
|
|
22
31
|
end
|
23
32
|
end
|
24
33
|
|
34
|
+
|
25
35
|
class Middleware
|
26
36
|
attr_accessor :app, :env
|
27
37
|
def call(env)
|
@@ -44,9 +54,11 @@ module SqAuth
|
|
44
54
|
def redirect_to_callback env, form_hash
|
45
55
|
env["rack.session"][:sqauthsession] = form_hash["sqauthsession"] if env["rack.session"]
|
46
56
|
env["rack.session"][:current_user] = form_hash["current_user"] if env["rack.session"]
|
57
|
+
SqAuth.access.current_user_name = form_hash["current_user"]
|
47
58
|
SqAuth.access.save_session_for_current_user form_hash["sqauthsession"]
|
59
|
+
SqAuth.access.save_username_for_current_user form_hash["current_user"]
|
48
60
|
|
49
|
-
[302, {'Location' => form_hash["callback"]}, ['Authenticated']]
|
61
|
+
[302, {'Content-Type'=>'text/plain', 'Location' => form_hash["callback"]}, ['Authenticated']]
|
50
62
|
end
|
51
63
|
|
52
64
|
def callback_uri env
|
data/lib/sq_auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sq_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.26
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-04 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70316757184520 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,15 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
24
|
+
version_requirements: *70316757184520
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: rspec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70316757183580 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
30
|
- - ! '>='
|
@@ -37,15 +32,10 @@ dependencies:
|
|
37
32
|
version: '0'
|
38
33
|
type: :development
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ! '>='
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '0'
|
35
|
+
version_requirements: *70316757183580
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: sinatra
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &70316757181920 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
41
|
- - ! '>='
|
@@ -53,12 +43,7 @@ dependencies:
|
|
53
43
|
version: '0'
|
54
44
|
type: :development
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
46
|
+
version_requirements: *70316757181920
|
62
47
|
description: SQ sevices authentication gem
|
63
48
|
email:
|
64
49
|
- leonidkrn@gmail.com
|
@@ -119,8 +104,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
104
|
version: '0'
|
120
105
|
requirements: []
|
121
106
|
rubyforge_project: sq_auth
|
122
|
-
rubygems_version: 1.8.
|
107
|
+
rubygems_version: 1.8.17
|
123
108
|
signing_key:
|
124
109
|
specification_version: 3
|
125
110
|
summary: SQ sevices authentication gem
|
126
|
-
test_files:
|
111
|
+
test_files:
|
112
|
+
- spec/lib/sq_auth/sq_auth_client_spec.rb
|
113
|
+
- spec/lib/sq_auth/sq_auth_request_spec.rb
|
114
|
+
- spec/lib/sq_auth/sq_auth_server_interface/basic_server_spec.rb
|
115
|
+
- spec/lib/sq_auth/sq_auth_sessions_spec.rb
|
116
|
+
- spec/lib/sq_auth/sq_auth_user/basic_user_spec.rb
|
117
|
+
- spec/lib/sq_auth_spec.rb
|
118
|
+
- spec/spec_helper.rb
|