oauth_im 0.9.1 → 0.9.4

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: 4c516706747b55e09365f8803351f8a282fa15fc47c7c5dfb0eb8fbd20cea0b5
4
- data.tar.gz: dfe17e0f5b654cc518d813ec9c645edcb951b9b8a8111f8360dba5c078639934
3
+ metadata.gz: 3de11fe5ca4fd11cd2d762e7cde0501b1d2f05310991efe187d20b9f035834e1
4
+ data.tar.gz: c80dd50d7c7c7f0c1b32f0aab6f9fad43f4a42e0d841d7efd3523786b7710cb9
5
5
  SHA512:
6
- metadata.gz: 19bbc2692b590850e2b73de9d8c082c200da8b667083715156bbcf80004d43ada5876038c79f2fee12dc0bd2c40b1cae49c5df80074abd75f01fb1d6f1f075e0
7
- data.tar.gz: da2dd4a76af69919b00a57e2db4f75ef1ba2b6bf18c4631b71472c3d88eb1729affd4e8d6d7d5facb397cabbde6b395a7093b6b3f59c3cbb739cf130dfd924d2
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
- :user_privileges,
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 user_jwt.present?
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
@@ -19,8 +19,8 @@ module OauthIm
19
19
  email.present?
20
20
  end
21
21
 
22
- def user_privileges
23
- @user_privileges ||= data[:privileges] || []
22
+ def user_is_sponsor?
23
+ data[:sponsor].eql?('true')
24
24
  end
25
25
 
26
26
  private
@@ -1,36 +1,57 @@
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_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 self.spec_user
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 self.authenticated_for_specs?
13
- @authenticated_for_specs if override_for_specs?
24
+ def spec_user_is_sponsor?
25
+ @spec_user_is_sponsor && override_for_specs?
14
26
  end
15
27
 
16
- def self.spec_user_data
17
- override_for_specs? ? (@spec_user_data.presence || {}) : {}
28
+ def authenticated_for_specs?
29
+ @authenticated_for_specs && override_for_specs?
18
30
  end
19
31
 
20
- def self.override_for_specs?
21
- Rails.env.test? && provide_authentication?
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 self.authenticate_for_specs(spec_user: nil, spec_user_data: {})
25
- return unless provide_authentication?
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
- @authenticated_for_specs = true
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
- @privileged_for_specs = false
33
- @spec_user_data = {}
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OauthIm
4
- VERSION = '0.9.1'
4
+ VERSION = '0.9.4'
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.1
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-14 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fusionauth_client