no_password_auth 0.2.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README-ES.md +6 -7
- data/README.md +6 -7
- data/app/controllers/no_password/application_controller.rb +1 -0
- data/app/controllers/no_password/session_confirmations_controller.rb +22 -14
- data/app/controllers/no_password/sessions_controller.rb +1 -1
- data/app/helpers/no_password/no_password_helper.rb +1 -3
- data/config/brakeman.ignore +52 -0
- data/config/locales/en/mailers.en.yml +3 -3
- data/config/locales/es/flash.es.yml +1 -1
- data/db/migrate/20211202211706_create_no_password_sessions.rb +0 -1
- data/lib/no_password/version.rb +1 -1
- metadata +22 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5745ba598e70ea21003c8df138f386b06d011bc0d259832dc92cbebfde29c7d6
|
4
|
+
data.tar.gz: c574de1146ad1b918754f9d1a67fe40db5178128eb3c3e56ec1d22d7426e837a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d30412f3f72b245734accb362d29bf90bb1ae23b35b28cc3557b9422b904cdad195c8508958a00a41ea4790ab42a248b100cb43db3df057496feb15284983c
|
7
|
+
data.tar.gz: b05a590cb97582b831ef817e090ac17e4139c7ccae13f0806569db4d4c565e9cc082f1a203748ace6a5bf6ed1240976cc5a20a8c0cec723152df2dc7ef6fa848
|
data/README-ES.md
CHANGED
@@ -144,16 +144,15 @@ El flujo normal para iniciar sesión consta de dos pasos, una página donde se i
|
|
144
144
|
|
145
145
|
Este callback va a ser llamado en cada intento de iniciar sesión, ya sea con código o con link mágico, independientemente de si el inicio de sesión es exitoso o no.
|
146
146
|
```ruby
|
147
|
-
after_sign_in!(
|
147
|
+
after_sign_in!(current_session, by_url)
|
148
148
|
```
|
149
|
-
El callback recibe
|
150
|
-
- `
|
149
|
+
El callback recibe dos parámetros.
|
150
|
+
- `current_session`: El objecto que representa a la sesión activa.
|
151
151
|
- `by_url`: indica como se inentó iniciar sesión, ya sea por el link mágico o con el código introducido manualmente, su valor es booleano.
|
152
|
-
- `return_url`: Contiene la URL a donde redireccionar al usuario en caso de que el inicio de sesión sea exitoso, su valor es una cadena de texto.
|
153
152
|
|
154
153
|
El controlador `SessionConfirmationsController` espera como respuesta del callback los siguientes posibles valores:
|
155
154
|
- `nil`: con el cual se indica que se ejecutó el callback y que regresa el control del flujo al controlador.
|
156
|
-
- `
|
155
|
+
- `redirect path`: es una ruta en forma de string que indica que el callback se ejecutó y espera una redirección a esa ruta específica.
|
157
156
|
|
158
157
|
Podemos implementar el callback `after_sign_in!` creando el archivo `app/controllers/no_password/session_confirmations_controller.rb` en nuestra aplicación principal,
|
159
158
|
donde cargamos el controlador original desde el engine de NoPassword y con `class_eval` le inyectamos el método.
|
@@ -162,12 +161,12 @@ donde cargamos el controlador original desde el engine de NoPassword y con `clas
|
|
162
161
|
load NoPassword::Engine.root.join("app", "controllers", "no_password", "session_confirmations_controller.rb")
|
163
162
|
|
164
163
|
NoPassword::SessionConfirmationsController.class_eval do
|
165
|
-
def after_sign_in!(
|
164
|
+
def after_sign_in!(current_session, by_url)
|
166
165
|
return do_something_different if signed_in # Do something different if user signed in successfully
|
167
166
|
return nil if !by_url # Return control if failed to sign in with magic link
|
168
167
|
|
169
168
|
flash[:alert] = "Your code is not valid"
|
170
|
-
|
169
|
+
main_app.demo_path # Redirect somewhere else if token is invalid
|
171
170
|
end
|
172
171
|
end
|
173
172
|
```
|
data/README.md
CHANGED
@@ -145,16 +145,15 @@ This is an example of a custom flow that mimics a Single Page flow.
|
|
145
145
|
|
146
146
|
The callback is called on every intent to start a session, whether the sign was successful or not.
|
147
147
|
```ruby
|
148
|
-
after_sign_in!(
|
148
|
+
after_sign_in!(current_session, by_url)
|
149
149
|
```
|
150
|
-
It receives
|
151
|
-
- `
|
150
|
+
It receives two parameters.
|
151
|
+
- `current_session`: An object that represents the active session.
|
152
152
|
- `by_url`: A boolean value that indicates if the login happens with the magic link or entered token manually.
|
153
|
-
- `return_url`: A string value with the return path if the user succeeded in getting a session.
|
154
153
|
|
155
154
|
The `SessionConfirmationsController` controller expects any of the following possible values from the callback.
|
156
155
|
- `nil`: indicates callback was executed but is returning flow control to the controller.
|
157
|
-
- `
|
156
|
+
- `redirect path`: it is a string path that indicates callback was executed and want to redirect to specific path.
|
158
157
|
|
159
158
|
`after_sign_in!` callback is implemented by creating a `app/controllers/no_password/session_confirmations_controller.rb` file in your application. The original controller from NoPassword engine is loaded, and then the callback is added with a `class_eval`.
|
160
159
|
|
@@ -162,12 +161,12 @@ The `SessionConfirmationsController` controller expects any of the following pos
|
|
162
161
|
load NoPassword::Engine.root.join("app", "controllers", "no_password", "session_confirmations_controller.rb")
|
163
162
|
|
164
163
|
NoPassword::SessionConfirmationsController.class_eval do
|
165
|
-
def after_sign_in!(
|
164
|
+
def after_sign_in!(current_session, by_url)
|
166
165
|
return do_something_different if signed_in # Do something different if user signed in successfully
|
167
166
|
return nil if !by_url # Return control if failed to sign in with magic link
|
168
167
|
|
169
168
|
flash[:alert] = "Your code is not valid"
|
170
|
-
|
169
|
+
main_app.demo_path # Redirect somewhere else if token is invalid
|
171
170
|
end
|
172
171
|
end
|
173
172
|
```
|
@@ -6,16 +6,18 @@ module NoPassword
|
|
6
6
|
include NoPassword::WebTokens
|
7
7
|
|
8
8
|
def edit
|
9
|
-
|
10
|
-
token = verify_token(params[:token])
|
9
|
+
return unless params[:token].present?
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
token = verify_token(params[:token])
|
12
|
+
redirect_url = sign_in_session(token, by_url: true)
|
13
|
+
|
14
|
+
redirect_to(redirect_url) if redirect_url.present?
|
14
15
|
end
|
15
16
|
|
16
17
|
def update
|
17
|
-
|
18
|
-
|
18
|
+
redirect_url = sign_in_session(params[:token])
|
19
|
+
|
20
|
+
return redirect_to(redirect_url) if redirect_url.present?
|
19
21
|
|
20
22
|
response.status = :unprocessable_entity
|
21
23
|
render turbo_stream: turbo_stream.update("notifications", partial: "notification")
|
@@ -23,19 +25,25 @@ module NoPassword
|
|
23
25
|
|
24
26
|
private
|
25
27
|
|
26
|
-
def
|
28
|
+
def claim_session(token)
|
27
29
|
current_session = SessionManager.new.claim(token)
|
30
|
+
if current_session.present?
|
31
|
+
save_session_to_cookie(current_session)
|
32
|
+
else
|
33
|
+
flash.now.alert = t("flash.update.invalid_code.alert")
|
34
|
+
end
|
28
35
|
|
29
|
-
|
36
|
+
current_session
|
37
|
+
end
|
38
|
+
|
39
|
+
def sign_in_session(token, by_url: false)
|
40
|
+
current_session = claim_session(token)
|
30
41
|
|
31
|
-
|
32
|
-
after_sign_in!(current_session
|
42
|
+
if respond_to?(:after_sign_in!)
|
43
|
+
after_sign_in!(current_session, by_url)
|
33
44
|
elsif current_session.present?
|
34
|
-
|
35
|
-
redirect_to(current_session.return_url || main_app.root_path)
|
45
|
+
current_session.return_url || main_app.root_path
|
36
46
|
end
|
37
|
-
|
38
|
-
result if result.present?
|
39
47
|
end
|
40
48
|
|
41
49
|
def save_session_to_cookie(current_session, key = nil, data = nil)
|
@@ -36,7 +36,7 @@ module NoPassword
|
|
36
36
|
referrer = CGI.unescape(return_to)
|
37
37
|
return nil if referrer.blank?
|
38
38
|
|
39
|
-
referrer.include?(no_password.new_session_path) || referrer.include?(no_password.edit_session_confirmations_path) ? nil : referrer
|
39
|
+
(referrer.include?(no_password.new_session_path) || referrer.include?(no_password.edit_session_confirmations_path)) ? nil : referrer
|
40
40
|
end
|
41
41
|
|
42
42
|
def sign_out(key = nil)
|
@@ -1,11 +1,9 @@
|
|
1
1
|
module NoPassword
|
2
2
|
module NoPasswordHelper
|
3
|
-
def no_password_importmap_tags(entry_point = "application"
|
3
|
+
def no_password_importmap_tags(entry_point = "application")
|
4
4
|
safe_join [
|
5
5
|
javascript_inline_importmap_tag(NoPassword.configuration.importmap.to_json(resolver: self)),
|
6
6
|
javascript_importmap_module_preload_tags(NoPassword.configuration.importmap),
|
7
|
-
(javascript_importmap_shim_nonce_configuration_tag if shim),
|
8
|
-
(javascript_importmap_shim_tag if shim),
|
9
7
|
javascript_import_module_tag(entry_point)
|
10
8
|
].compact, "\n"
|
11
9
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
{
|
2
|
+
"ignored_warnings": [
|
3
|
+
{
|
4
|
+
"warning_type": "Redirect",
|
5
|
+
"warning_code": 18,
|
6
|
+
"fingerprint": "310eb4d856343cbe3a4b5357ce331265a65360c7c51cef559f077eaa96015e95",
|
7
|
+
"check_name": "Redirect",
|
8
|
+
"message": "Possible unprotected redirect",
|
9
|
+
"file": "app/controllers/no_password/session_confirmations_controller.rb",
|
10
|
+
"line": 14,
|
11
|
+
"link": "https://brakemanscanner.org/docs/warning_types/redirect/",
|
12
|
+
"code": "redirect_to(sign_in_session(verify_token(params[:token]), :by_url => true))",
|
13
|
+
"render_path": null,
|
14
|
+
"location": {
|
15
|
+
"type": "method",
|
16
|
+
"class": "NoPassword::SessionConfirmationsController",
|
17
|
+
"method": "edit"
|
18
|
+
},
|
19
|
+
"user_input": "params[:token]",
|
20
|
+
"confidence": "Weak",
|
21
|
+
"cwe_id": [
|
22
|
+
601
|
23
|
+
],
|
24
|
+
"note": "It is ok,redirect is calculated."
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"warning_type": "Redirect",
|
28
|
+
"warning_code": 18,
|
29
|
+
"fingerprint": "6a097716f95b29bd0948be5684aa38582be64c76f258032743ff949a8abdc064",
|
30
|
+
"check_name": "Redirect",
|
31
|
+
"message": "Possible unprotected redirect",
|
32
|
+
"file": "app/controllers/no_password/session_confirmations_controller.rb",
|
33
|
+
"line": 20,
|
34
|
+
"link": "https://brakemanscanner.org/docs/warning_types/redirect/",
|
35
|
+
"code": "redirect_to(sign_in_session(params[:token]))",
|
36
|
+
"render_path": null,
|
37
|
+
"location": {
|
38
|
+
"type": "method",
|
39
|
+
"class": "NoPassword::SessionConfirmationsController",
|
40
|
+
"method": "update"
|
41
|
+
},
|
42
|
+
"user_input": "params[:token]",
|
43
|
+
"confidence": "Weak",
|
44
|
+
"cwe_id": [
|
45
|
+
601
|
46
|
+
],
|
47
|
+
"note": "It is ok, redirect is calculated."
|
48
|
+
}
|
49
|
+
],
|
50
|
+
"updated": "2023-08-10 11:37:09 -0600",
|
51
|
+
"brakeman_version": "6.0.1"
|
52
|
+
}
|
@@ -12,10 +12,10 @@ en:
|
|
12
12
|
default_from: no-reply@aoorora.com
|
13
13
|
|
14
14
|
send_token:
|
15
|
-
subject:
|
15
|
+
subject: "Aoorora: Your temporary session code is here"
|
16
16
|
greetings: Hello!
|
17
|
-
instructions_1: You
|
18
|
-
instructions_2:
|
17
|
+
instructions_1: You are receiving this email because you requested a login code to begin a demo session in Aoorora. Please don't share this code with anyone else.
|
18
|
+
instructions_2: Click this button to start a new session. It will open a new browser window.
|
19
19
|
instructions_2_text: Or use the follwing link to start a new session. Copy and paste it your browser.
|
20
20
|
start_session: Continue to your session
|
21
21
|
instructions_3: If you did not request this email, please ignore and delete it. Do not resend or share it with other people.
|
@@ -4,7 +4,7 @@ es:
|
|
4
4
|
invalid_code:
|
5
5
|
alert:
|
6
6
|
title: Código inválido
|
7
|
-
description: Revise su código
|
7
|
+
description: Revise su código, es válido o ya expiró. Puede solicitar uno nuevo.
|
8
8
|
session:
|
9
9
|
alert:
|
10
10
|
title: No existe sesión activa
|
data/lib/no_password/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: no_password_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Alberto Chávez
|
@@ -10,78 +10,84 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2024-05-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 7.1.0
|
22
|
+
- - "<="
|
20
23
|
- !ruby/object:Gem::Version
|
21
|
-
version: 7.
|
24
|
+
version: 7.2.0
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
25
28
|
requirements:
|
26
|
-
- - "
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 7.1.0
|
32
|
+
- - "<="
|
27
33
|
- !ruby/object:Gem::Version
|
28
|
-
version: 7.
|
34
|
+
version: 7.2.0
|
29
35
|
- !ruby/object:Gem::Dependency
|
30
36
|
name: turbo-rails
|
31
37
|
requirement: !ruby/object:Gem::Requirement
|
32
38
|
requirements:
|
33
39
|
- - "~>"
|
34
40
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
41
|
+
version: 2.0.0
|
36
42
|
type: :runtime
|
37
43
|
prerelease: false
|
38
44
|
version_requirements: !ruby/object:Gem::Requirement
|
39
45
|
requirements:
|
40
46
|
- - "~>"
|
41
47
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
48
|
+
version: 2.0.0
|
43
49
|
- !ruby/object:Gem::Dependency
|
44
50
|
name: stimulus-rails
|
45
51
|
requirement: !ruby/object:Gem::Requirement
|
46
52
|
requirements:
|
47
53
|
- - "~>"
|
48
54
|
- !ruby/object:Gem::Version
|
49
|
-
version: 1.
|
55
|
+
version: 1.3.0
|
50
56
|
type: :runtime
|
51
57
|
prerelease: false
|
52
58
|
version_requirements: !ruby/object:Gem::Requirement
|
53
59
|
requirements:
|
54
60
|
- - "~>"
|
55
61
|
- !ruby/object:Gem::Version
|
56
|
-
version: 1.
|
62
|
+
version: 1.3.0
|
57
63
|
- !ruby/object:Gem::Dependency
|
58
64
|
name: importmap-rails
|
59
65
|
requirement: !ruby/object:Gem::Requirement
|
60
66
|
requirements:
|
61
67
|
- - "~>"
|
62
68
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
69
|
+
version: 2.0.0
|
64
70
|
type: :runtime
|
65
71
|
prerelease: false
|
66
72
|
version_requirements: !ruby/object:Gem::Requirement
|
67
73
|
requirements:
|
68
74
|
- - "~>"
|
69
75
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
76
|
+
version: 2.0.0
|
71
77
|
- !ruby/object:Gem::Dependency
|
72
78
|
name: tailwindcss-rails
|
73
79
|
requirement: !ruby/object:Gem::Requirement
|
74
80
|
requirements:
|
75
81
|
- - "~>"
|
76
82
|
- !ruby/object:Gem::Version
|
77
|
-
version: 2.0
|
83
|
+
version: '2.0'
|
78
84
|
type: :runtime
|
79
85
|
prerelease: false
|
80
86
|
version_requirements: !ruby/object:Gem::Requirement
|
81
87
|
requirements:
|
82
88
|
- - "~>"
|
83
89
|
- !ruby/object:Gem::Version
|
84
|
-
version: 2.0
|
90
|
+
version: '2.0'
|
85
91
|
- !ruby/object:Gem::Dependency
|
86
92
|
name: standard
|
87
93
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,6 +176,7 @@ files:
|
|
170
176
|
- app/views/no_password/sessions/new.html.erb
|
171
177
|
- app/views/no_password/sessions_mailer/send_token.html.erb
|
172
178
|
- app/views/no_password/sessions_mailer/send_token.text.erb
|
179
|
+
- config/brakeman.ignore
|
173
180
|
- config/initializers/importmap.rb
|
174
181
|
- config/locales/en/flash.en.yml
|
175
182
|
- config/locales/en/forms.en.yml
|
@@ -220,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
220
227
|
- !ruby/object:Gem::Version
|
221
228
|
version: '0'
|
222
229
|
requirements: []
|
223
|
-
rubygems_version: 3.
|
230
|
+
rubygems_version: 3.5.6
|
224
231
|
signing_key:
|
225
232
|
specification_version: 4
|
226
233
|
summary: Passwordless Ruby on Rails engine.
|