go_sso 0.5.2 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/go_sso/middleware.rb +7 -3
- data/lib/go_sso/version.rb +1 -1
- data/lib/go_sso.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9a6ca1f77fde058361e5c00b1a89754e1c371254141a7cc88f87588ea8de6c6
|
4
|
+
data.tar.gz: d218697ca3603356bb4dad66b300d6f74a32bd7cdfd5809febaa5de177e6a924
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: baf1cd0b51ce1b065cb492d7a488296b8716a1d966ef808ad4e9e0e77b9a028d4fd56c83481bbfc322d04f5354d98fed052cdffc565701cd625de8809183b03e
|
7
|
+
data.tar.gz: 3069bb51bc89b3f9f6fa93a82f3b06d4f070446ca3cff17932bc24f33e35b7fb27abffd4649e0f94f1c112a6a854d7d0d93a2f3e0fbf26e14b98f16f83cdb2ad
|
data/lib/go_sso/middleware.rb
CHANGED
@@ -11,8 +11,8 @@ module GoSso
|
|
11
11
|
|
12
12
|
def call!(env)
|
13
13
|
@env = env
|
14
|
+
GoSso::Current.host = request.env["HTTP_X_FORWARDED_HOST"] || request.env["HTTP_HOST"]
|
14
15
|
|
15
|
-
GoSso::Current.host = request.base_url
|
16
16
|
begin
|
17
17
|
return request_call if on_path?("#{GoSso.routes_prefix}/auth")
|
18
18
|
return logout_call if on_path?("#{GoSso.routes_prefix}/logout") && delete_request?
|
@@ -38,7 +38,7 @@ module GoSso
|
|
38
38
|
if GoSso.test_mode?
|
39
39
|
redirect client_callback_path
|
40
40
|
else
|
41
|
-
redirect GoSso.authorize_url
|
41
|
+
redirect GoSso.authorize_url(url_options)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -48,7 +48,7 @@ module GoSso
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def callback_call
|
51
|
-
token = GoSso.test_mode? ? GoSso.generate_fake_token : GoSso.get_token(request.params["code"])
|
51
|
+
token = GoSso.test_mode? ? GoSso.generate_fake_token : GoSso.get_token(request.params["code"], url_options)
|
52
52
|
set_sso_token(token.token, expires_at: token.expires_at)
|
53
53
|
@app.call(@env)
|
54
54
|
rescue OAuth2::Error => error
|
@@ -98,5 +98,9 @@ module GoSso
|
|
98
98
|
path = request.script_name.to_s.chomp("/")
|
99
99
|
path << _path if _path.present?
|
100
100
|
end
|
101
|
+
|
102
|
+
def url_options
|
103
|
+
{ script_name: request.script_name }
|
104
|
+
end
|
101
105
|
end
|
102
106
|
end
|
data/lib/go_sso/version.rb
CHANGED
data/lib/go_sso.rb
CHANGED
@@ -39,12 +39,12 @@ module GoSso
|
|
39
39
|
@client ||= OAuth2::Client.new(client_id, client_secret, site: site)
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.authorize_url
|
43
|
-
client.auth_code.authorize_url(redirect_uri: Rails.application.routes.url_helpers.go_sso_callback_url(host: current_host))
|
42
|
+
def self.authorize_url(url_options = {})
|
43
|
+
client.auth_code.authorize_url(redirect_uri: Rails.application.routes.url_helpers.go_sso_callback_url(host: current_host, **url_options))
|
44
44
|
end
|
45
45
|
|
46
|
-
def self.get_token(code)
|
47
|
-
client.auth_code.get_token(code, redirect_uri: Rails.application.routes.url_helpers.go_sso_callback_url(host: current_host))
|
46
|
+
def self.get_token(code, url_options = {})
|
47
|
+
client.auth_code.get_token(code, redirect_uri: Rails.application.routes.url_helpers.go_sso_callback_url(host: current_host, **url_options))
|
48
48
|
end
|
49
49
|
|
50
50
|
def self.current_host
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_sso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yi Feng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth2
|