rodauth-select-account 0.1.2 → 0.1.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: 90895ef37a108c15a07ad95b7e7e834a792e495dfc6a5b00e95f5cba0e8f5641
4
- data.tar.gz: e9e436f0e30f7a96e296c9ddb6059cfcf23ad4b1ea0a764d9345669cf82633a7
3
+ metadata.gz: 05f7798e665c9094487ad294b51c0f248477c5141eda29e779c97f1b97e20da0
4
+ data.tar.gz: ad8d11bb6eaabbe37560cd1fa986cc8f82194f421a7004999d930d4237321fb0
5
5
  SHA512:
6
- metadata.gz: 6f27e0dec0e492dfb2de6b50edb469d10a913702a86e823428b5db7e37e9bc01884cc7f8c9f36d81158fec1514f8953b74a07ea646c40b727c80f5cdd3b839da
7
- data.tar.gz: 6e79144222edfd09428c7f679036a4306d9ee51a03cd9e40ce2892908066ab60f7f6c59cb06fd9625391bbfd189a68ed0d828bda4b9282f04ee12878be721ea1
6
+ metadata.gz: fc463cbc75d2be5c303d98b903459dd9cf4537d64ceba01626327342b3a1a4913da0ff1cc09ba7f3b6d103ebbce9d0ace1b1c742c078e619ee14aae23d242a9c
7
+ data.tar.gz: 1dc2fc5d70455e4426ec90ca30603605af8c061707c2a977c313264ce984dc4ce4f78535b2973c93f36a6570ef0d080333dfa0203ead39fc272d3e084d8fb0a3
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.1.4
6
+
7
+ * Fixes compatibility with security-focused changes introduced in rodauth 2.46.
8
+
9
+ ## 0.1.3
10
+
11
+ * allow setting `require_selected_account_cookie_interval` and `accounts_cookie_interval` to `nil` in order to set the managed cookies as "Session Cookies" (i.e. getting wiped out on browser close).
12
+
5
13
  ## 0.1.2
6
14
 
7
15
  point release to update project links in rubygems.
@@ -0,0 +1,47 @@
1
+ = Documentation for Select Account
2
+
3
+ The +select_account+ feature allows for maintaining and switching across multiple accounts in the same session.
4
+
5
+ == Auth Value Methods
6
+
7
+ selected_account_key :: session key where the selected account state is stored.
8
+ accounts_key :: session key where the logged-in accounts state is stored.
9
+ add_account_redirect_session_key :: session key where the url to redirect to after adding an account is stored.
10
+ select_account_redirect_session_key :: session key where the url to redirect to after selecting an account is stored.
11
+ require_selected_account_cookie_key :: cookie key storing whether a selected account is required.
12
+ require_selected_account_cookie_interval :: duration for the require selected account cookie (5 minutes by default); can be set to <tt>nil</tt> in order not to set cookie "Expires".
13
+ accounts_cookie_key :: cookie key where the selected accounts are stored.
14
+ accounts_cookie_options :: cookie options for the selected accounts cookie
15
+ accounts_cookie_interval :: duration for the selected accounts cookie (14 days by default); can be set to <tt>nil</tt> in order not to set cookie "Expires".
16
+ no_account_error_status :: http status code for the response when the account to switch to does not exist anymore.
17
+ select_account_required_error_status :: http status code for the response when a selected account is required.
18
+ add_account_required_error_status :: http status code for the response when addig an account is required.
19
+ no_account_message :: error description when no account was found, <tt>"could not select account"</tt> by default.
20
+
21
+
22
+ add_account_button :: Label of add account button.
23
+ add_account_error_flash :: The flash error message to display when there was an error adding an account.
24
+ add_account_notice_flash :: The flash success message to display after adding an account.
25
+ require_add_account_error_flash :: he flash error message to display when adding an account is required.
26
+ add_account_page_title :: Title for the Add Account form.
27
+ add_account_redirect :: URL to redirect to after adding an account.
28
+ add_account_route :: the route for adding an account, +add-account+ by default.
29
+
30
+ select_account_error_flash :: The flash error message to display when there was an error selecting an account.
31
+ select_account_notice_flash :: The flash success message to display after selecting an account.
32
+ require_select_account_error_flash :: he flash error message to display when selecting an account is required.
33
+ select_account_page_title :: Title for the Select Account form.
34
+ select_account_redirect :: URL to redirect to after selecting an account.
35
+ select_account_route :: the route for selecting an account, +select-account+ by default.
36
+
37
+
38
+ == Auth Methods
39
+
40
+ add_account_view :: The HTML template of the Add Account form.
41
+ before_add_account_route :: Run arbitrary code before the add account route.
42
+ before_add_account :: Run arbitrary code before adding an account.
43
+ after_add_account :: Run arbitrary code after adding an account.
44
+ select_account_view :: The HTML template of the Select Account form.
45
+ before_select_account_route :: Run arbitrary code before the add account route.
46
+ before_select_account :: Run arbitrary code before selecting an account.
47
+ after_select_account :: Run arbitrary code after selecting an account.
@@ -37,6 +37,13 @@ module Rodauth
37
37
  auth_value_method :add_account_required_error_status, 403
38
38
  translatable_method :no_account_message, "could not select account"
39
39
 
40
+ if respond_to?(:uses_instance_variables)
41
+ uses_instance_variables(
42
+ :@accounts_in_session,
43
+ :@valid_login_entered
44
+ )
45
+ end
46
+
40
47
  def accounts_in_session
41
48
  @accounts_in_session ||= _get_accounts_in_session
42
49
  end
@@ -62,7 +69,7 @@ module Rodauth
62
69
  end
63
70
 
64
71
  opts[:value] = true
65
- opts[:expires] = Time.now + require_selected_account_cookie_interval
72
+ opts[:expires] = Time.now + require_selected_account_cookie_interval if require_selected_account_cookie_interval
66
73
  opts[:httponly] = true unless opts.key?(:httponly)
67
74
  opts[:secure] = true unless opts.key?(:secure) || !request.ssl?
68
75
 
@@ -177,7 +184,7 @@ module Rodauth
177
184
 
178
185
  opts = Hash[accounts_cookie_options]
179
186
  opts[:value] = accounts_cookie.join(",")
180
- opts[:expires] = Time.now + accounts_cookie_interval
187
+ opts[:expires] = Time.now + accounts_cookie_interval if accounts_cookie_interval
181
188
  opts[:path] = "/" unless opts.key?(:path)
182
189
  opts[:httponly] = true unless opts.key?(:httponly)
183
190
  opts[:secure] = true unless opts.key?(:secure) || !request.ssl?
@@ -244,7 +251,7 @@ module Rodauth
244
251
 
245
252
  catch_error do
246
253
  # this instruction will load the new account
247
- unless account_from_login(param(login_param))
254
+ unless (@account = _account_from_login(param(login_param)))
248
255
  throw_error_status(no_matching_login_error_status, login_param, no_matching_login_message)
249
256
  end
250
257
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rodauth
4
4
  module SelectAccount
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rodauth-select-account
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-11-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rodauth
@@ -30,13 +29,15 @@ email:
30
29
  executables: []
31
30
  extensions: []
32
31
  extra_rdoc_files:
32
+ - CHANGELOG.md
33
33
  - LICENSE.txt
34
34
  - README.md
35
- - CHANGELOG.md
35
+ - doc/select_account.rdoc
36
36
  files:
37
37
  - CHANGELOG.md
38
38
  - LICENSE.txt
39
39
  - README.md
40
+ - doc/select_account.rdoc
40
41
  - lib/rodauth/features/select_account.rb
41
42
  - lib/rodauth/select-account.rb
42
43
  - lib/rodauth/select-account/version.rb
@@ -48,8 +49,10 @@ homepage: https://gitlab.com/os85/rodauth-select-account
48
49
  licenses:
49
50
  - Apache 2.0
50
51
  metadata:
52
+ homepage_uri: https://gitlab.com/os85/rodauth-select-account
53
+ source_code_uri: https://gitlab.com/os85/rodauth-select-account
54
+ changelog_uri: https://gitlab.com/os85/rodauth-select-account/-/blob/master/CHANGELOG.md
51
55
  rubygems_mfa_required: 'true'
52
- post_install_message:
53
56
  rdoc_options: []
54
57
  require_paths:
55
58
  - lib
@@ -64,8 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
67
  - !ruby/object:Gem::Version
65
68
  version: '0'
66
69
  requirements: []
67
- rubygems_version: 3.2.32
68
- signing_key:
70
+ rubygems_version: 4.0.16
69
71
  specification_version: 4
70
72
  summary: Multiple authenticated accounts per session in rodauth.
71
73
  test_files: []