oauth_im 0.9.1 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/app/controllers/concerns/oauth_im/authenticable.rb +6 -4
- data/app/services/oauth_im/request_client.rb +1 -3
- data/app/services/oauth_im/user_client.rb +2 -2
- data/config/initializers/app_context.rb +37 -16
- data/lib/oauth_im/version.rb +1 -1
- data/lib/oauth_im.rb +3 -6
- 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: 3de11fe5ca4fd11cd2d762e7cde0501b1d2f05310991efe187d20b9f035834e1
|
4
|
+
data.tar.gz: c80dd50d7c7c7f0c1b32f0aab6f9fad43f4a42e0d841d7efd3523786b7710cb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9a6298a624e5c4cc51dfda4bd79920d8d729c8cbbdd9f8a7723e95f2e3aac5c69f36fa4d733e18b9b503e65ba9185a37d88362705d8663572f3e5fb60bf02ad
|
7
|
+
data.tar.gz: 05b8f611dc5f111eca6865d2115b26b44abc0ccab2b582b7f9ed9fbf3e3f70b8f5e0a1930fb557c70772f128394fd057ca90983f2b7f8c4acaac4ce8de9508d7
|
data/README.md
CHANGED
@@ -139,6 +139,15 @@ After many false starts, this repo includes two (seemingly functional) github wo
|
|
139
139
|
|
140
140
|
## Version History
|
141
141
|
|
142
|
+
### 0.9.3
|
143
|
+
* added specs for AppContext initializer
|
144
|
+
|
145
|
+
### 0.9.2
|
146
|
+
* Fix redirect url
|
147
|
+
* No longer does it take user back to page they were on
|
148
|
+
* This caused problems with FusionAuth which wants all redirect URLs whitelisted
|
149
|
+
* Update initializer defaults
|
150
|
+
|
142
151
|
### 0.9.1
|
143
152
|
* Facilitate specs for privileged users by providing spec_user_data on AppContext
|
144
153
|
|
@@ -12,10 +12,12 @@ module OauthIm
|
|
12
12
|
private
|
13
13
|
|
14
14
|
delegate :email, :email_verified?,
|
15
|
-
:
|
15
|
+
:user_is_sponsor?,
|
16
16
|
to: :user_client,
|
17
17
|
allow_nil: true
|
18
18
|
|
19
|
+
delegate :spec_user, :spec_user_is_sponsor?, to: AppContext
|
20
|
+
|
19
21
|
def authenticated?
|
20
22
|
AppContext.authenticated_for_specs? ||
|
21
23
|
(AppContext.provide_authentication? && logged_in?)
|
@@ -32,10 +34,10 @@ module OauthIm
|
|
32
34
|
|
33
35
|
def current_user
|
34
36
|
@current_user ||=
|
35
|
-
if
|
37
|
+
if Rails.env.test?
|
38
|
+
spec_user
|
39
|
+
elsif user_jwt.present?
|
36
40
|
email if email_verified?
|
37
|
-
elsif Rails.env.test?
|
38
|
-
AppContext.spec_user
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
@@ -13,9 +13,7 @@ module OauthIm
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def logout_url
|
16
|
-
@logout_url ||= "#{idp_url}/oauth2/logout"
|
17
|
-
"?post_logout_redirect_uri=#{return_to_url}" \
|
18
|
-
"&client_id=#{client_id}"
|
16
|
+
@logout_url ||= "#{idp_url}/oauth2/logout?client_id=#{client_id}"
|
19
17
|
end
|
20
18
|
|
21
19
|
def user_jwt
|
@@ -1,36 +1,57 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module AppContext
|
4
|
-
|
4
|
+
module_function
|
5
|
+
|
6
|
+
TEST_ENV_ERROR_MESSAGE = 'Use only in test environment!'
|
7
|
+
|
8
|
+
def override_for_specs?
|
9
|
+
Rails.env.test? && provide_authentication?
|
10
|
+
end
|
11
|
+
|
12
|
+
def provide_authentication?
|
5
13
|
true
|
6
14
|
end
|
7
15
|
|
8
|
-
def
|
16
|
+
def provide_auth_routes?
|
17
|
+
provide_authentication?
|
18
|
+
end
|
19
|
+
|
20
|
+
def spec_user
|
9
21
|
@spec_user if override_for_specs?
|
10
22
|
end
|
11
23
|
|
12
|
-
def
|
13
|
-
@
|
24
|
+
def spec_user_is_sponsor?
|
25
|
+
@spec_user_is_sponsor && override_for_specs?
|
14
26
|
end
|
15
27
|
|
16
|
-
def
|
17
|
-
|
28
|
+
def authenticated_for_specs?
|
29
|
+
@authenticated_for_specs && override_for_specs?
|
18
30
|
end
|
19
31
|
|
20
|
-
def
|
21
|
-
Rails.env.test?
|
32
|
+
def authenticate_for_specs?
|
33
|
+
raise TEST_ENV_ERROR_MESSAGE unless Rails.env.test?
|
34
|
+
|
35
|
+
provide_authentication?
|
22
36
|
end
|
23
37
|
|
24
|
-
def
|
25
|
-
return unless
|
26
|
-
raise 'Use only in test environment!!' unless Rails.env.test?
|
38
|
+
def authenticate_for_specs(spec_user: nil, sponsor: false)
|
39
|
+
return unless authenticate_for_specs?
|
27
40
|
|
28
|
-
|
29
|
-
@spec_user = spec_user
|
30
|
-
@spec_user_data = spec_user_data
|
41
|
+
initialize_spec_user spec_user: spec_user, sponsor: sponsor
|
31
42
|
yield
|
32
|
-
|
33
|
-
|
43
|
+
reset_spec_user
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize_spec_user(spec_user:, sponsor:)
|
47
|
+
@spec_user = spec_user
|
48
|
+
@spec_user_is_sponsor = sponsor
|
49
|
+
@authenticated_for_specs = true
|
50
|
+
end
|
51
|
+
|
52
|
+
def reset_spec_user
|
34
53
|
@authenticated_for_specs = false
|
54
|
+
@spec_user = nil
|
55
|
+
@spec_user_is_sponsor = false
|
35
56
|
end
|
36
57
|
end
|
data/lib/oauth_im/version.rb
CHANGED
data/lib/oauth_im.rb
CHANGED
@@ -12,13 +12,10 @@ module OauthIm
|
|
12
12
|
DEFAULT_AUTH_AUTHORIZE_URL = '/oauth2/authorize'
|
13
13
|
DEFAULT_AUTH_CALLBACK_ROUTE = 'callback'
|
14
14
|
DEFAULT_AUTH_TOKEN_URL = '/oauth2/token'
|
15
|
-
DEFAULT_AUTH_IDP_URL = 'https://illustrativemath-dev.fusionauth.io'
|
16
15
|
DEFAULT_AUTH_ISS_DOMAIN = 'illustrativemathematics.org'
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
DEFAULT_AUTH_HMAC = nil
|
21
|
-
DEFAULT_AUTH_RSA_PUBLIC = nil
|
16
|
+
DEFAULT_AUTH_IDP_URL_LIVE = 'https://login.illustrativemathics.org'
|
17
|
+
DEFAULT_AUTH_IDP_URL_TEST = 'https://illustrativemath-dev.fusionauth.io'
|
18
|
+
DEFAULT_AUTH_IDP_URL = DEFAULT_AUTH_IDP_URL_TEST
|
22
19
|
|
23
20
|
class << self
|
24
21
|
attr_reader :configuration
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oauth_im
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Connally
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06
|
11
|
+
date: 2022-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fusionauth_client
|