oauth_im 0.9.0 → 0.9.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: caff412768b7a6411078d84704899ce468379841ca548fc9271ec5e44a0bbc26
4
- data.tar.gz: ca77658308ba2d2a432a9ed6f8fa23a0b59bce783804bc9298e10cf53fa6a89b
3
+ metadata.gz: 59850b2078fcdc211be2d3a43ca7f7d3e0aaf4a433e1a703e48e3ac0942e8bdc
4
+ data.tar.gz: 228df263b5f216a455ea5cd0365ae97d77ff48e1e0bd527850977e1a7d0fa262
5
5
  SHA512:
6
- metadata.gz: 6efbc2ea50fc30a26166b86c9abc9bb927c82faa70f6a693101b8761d4e10c8e071ca2cc14e726e0e1c3cecd08ae71cb2e2734de67278e383b84ece88401878a
7
- data.tar.gz: afc164c6542ca85cd3206451cead14ebe4fca9293d0d819cd544ed7347ba7ed8eacf4dd9a85045b69a046a44871380871b934aeaeb34e42c14baf24879863c38
6
+ metadata.gz: 37e2f602d2de4058a194d01af1074c6bc2f5231f0fb5a13efe8c77b8b80dc7344cf35f6c7e139310352bef8e07b93796d3088b966245c3db0bb6f15bf5ab87a9
7
+ data.tar.gz: 48e15c481324112a37afb2400938f3d2dc13e8e173adeb86505ab079d5d3b77e2fb66e64fad211057f89e5e5ab31bbbf111de3ee3ad791ce951f0d2b3b250c69
data/README.md CHANGED
@@ -139,7 +139,19 @@ After many false starts, this repo includes two (seemingly functional) github wo
139
139
 
140
140
  ## Version History
141
141
 
142
- ### 0.8.3
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
+
151
+ ### 0.9.1
152
+ * Facilitate specs for privileged users by providing spec_user_data on AppContext
153
+
154
+ ### 0.9.0
143
155
  * Consolidate all OAuth (FusionAuth) functionality
144
156
  * the register app can now include this gem for OAuth to create users
145
157
  * IIAB can include this gem to authenticate users
@@ -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,30 +1,63 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AppContext
4
- def self.provide_authentication?
4
+ module_function
5
+
6
+ TEST_ENV_ERROR_MESSGE = 'Use only in test environment!'
7
+ DEFAULT_SPEC_USER_DATA = {}.freeze
8
+
9
+ def provide_authentication?
5
10
  true
6
11
  end
7
12
 
8
- def self.privileged?
9
- @privileged if provide_authentication?
13
+ def provide_auth_routes?
14
+ provide_authentication?
15
+ end
16
+
17
+ def spec_user
18
+ @spec_user if override_for_specs?
10
19
  end
11
20
 
12
- def self.spec_user
13
- @spec_user if Rails.env.test? && provide_authentication?
21
+ def authenticated_for_specs?
22
+ @authenticated_for_specs if override_for_specs?
14
23
  end
15
24
 
16
- def self.authenticated_for_specs?
17
- @authenticated_for_specs if Rails.env.test? && provide_authentication?
25
+ def spec_user_data
26
+ if override_for_specs?
27
+ @spec_user_data.presence || DEFAULT_SPEC_USER_DATA
28
+ else
29
+ DEFAULT_SPEC_USER_DATA
30
+ end
18
31
  end
19
32
 
20
- def self.authenticate_for_specs(spec_user: nil)
21
- return unless provide_authentication?
22
- raise 'Use only in test environment!!' unless Rails.env.test?
33
+ def override_for_specs?
34
+ Rails.env.test? && provide_authentication?
35
+ end
36
+
37
+ def authenticate_for_specs?
38
+ raise TEST_ENV_ERROR_MESSGE unless Rails.env.test?
39
+
40
+ provide_authentication?
41
+ end
23
42
 
43
+ def authenticate_for_specs(spec_user: nil, spec_user_data: {})
44
+ return unless authenticate_for_specs?
45
+
46
+ set_spec_user spec_user, spec_user_data
47
+ yield
48
+ reset_spec_user
49
+ end
50
+
51
+ def set_spec_user(spec_user, spec_user_data)
24
52
  @authenticated_for_specs = true
25
53
  @spec_user = spec_user
26
- yield
54
+ @spec_user_data = spec_user_data
55
+ end
56
+
57
+ def reset_spec_user
58
+ @spec_user_data = DEFAULT_SPEC_USER_DATA
27
59
  @spec_user = nil
28
60
  @authenticated_for_specs = false
61
+ nil
29
62
  end
30
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OauthIm
4
- VERSION = '0.9.0'
4
+ VERSION = '0.9.3'
5
5
  end
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
- DEFAULT_AUTH_API_KEY = nil
18
- DEFAULT_AUTH_CLIENT_ID = nil
19
- DEFAULT_AUTH_CLIENT_SECRET = nil
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.0
4
+ version: 0.9.3
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-14 00:00:00.000000000 Z
11
+ date: 2022-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fusionauth_client