rails_simple_auth 1.0.0 → 1.0.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 407b27862ed25ee5daa7fff450777ba4cec5f2e91d967df7ecc79f3a8831b285
|
|
4
|
+
data.tar.gz: 2a687ca739d79dcb1e1c1c9d8b8b7a4dd9aa6b9a31558cda56ea7a1fe3084e50
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a0c7a9ae65587337dc327ef68ecd0ae9b2ff84d00a775431f40138e2664fd8ef6c072d18bb7bc5323919adaacc1eeeab76d2960f7d24e8082251f673a020244b
|
|
7
|
+
data.tar.gz: 8f40cb9b06ac207555fad164f7c6428f1ba26101a9737c7401e8c8a5f42ebed50ec9033c64a6923ff3270b50f9bb220e6149c3edf9bac09ff3ca5c7f65d87b4c
|
data/README.md
CHANGED
|
@@ -156,6 +156,7 @@ RailsSimpleAuth.configure do |config|
|
|
|
156
156
|
|
|
157
157
|
# Mailer
|
|
158
158
|
config.mailer_sender = "auth@myapp.com"
|
|
159
|
+
# config.mailer_class = "UserMailer" # Use custom mailer (optional)
|
|
159
160
|
|
|
160
161
|
# Password requirements
|
|
161
162
|
config.password_minimum_length = 12
|
|
@@ -222,6 +223,75 @@ Update routes to use your controller:
|
|
|
222
223
|
rails_simple_auth_routes(sessions_controller: "sessions")
|
|
223
224
|
```
|
|
224
225
|
|
|
226
|
+
## Mailer
|
|
227
|
+
|
|
228
|
+
The gem includes a built-in mailer (`RailsSimpleAuth::AuthMailer`) with email templates that work out of the box. No configuration required.
|
|
229
|
+
|
|
230
|
+
### Included Email Templates
|
|
231
|
+
|
|
232
|
+
| Email | Purpose |
|
|
233
|
+
|-------|---------|
|
|
234
|
+
| `confirmation` | Email confirmation when user signs up |
|
|
235
|
+
| `magic_link` | Passwordless sign-in link |
|
|
236
|
+
| `password_reset` | Password recovery link |
|
|
237
|
+
|
|
238
|
+
### Configuration
|
|
239
|
+
|
|
240
|
+
```ruby
|
|
241
|
+
RailsSimpleAuth.configure do |config|
|
|
242
|
+
# Sender address for all auth emails (required)
|
|
243
|
+
config.mailer_sender = "auth@myapp.com"
|
|
244
|
+
# Or use environment variable
|
|
245
|
+
config.mailer_sender = ENV.fetch("MAILER_FROM", "noreply@example.com")
|
|
246
|
+
end
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Custom Mailer (Optional)
|
|
250
|
+
|
|
251
|
+
For branded emails with your own design, use a custom mailer:
|
|
252
|
+
|
|
253
|
+
```ruby
|
|
254
|
+
# config/initializers/rails_simple_auth.rb
|
|
255
|
+
RailsSimpleAuth.configure do |config|
|
|
256
|
+
config.mailer_class = "UserMailer"
|
|
257
|
+
config.mailer_sender = "hello@myapp.com"
|
|
258
|
+
end
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Your custom mailer must implement these methods:
|
|
262
|
+
|
|
263
|
+
```ruby
|
|
264
|
+
# app/mailers/user_mailer.rb
|
|
265
|
+
class UserMailer < ApplicationMailer
|
|
266
|
+
def confirmation(user, token)
|
|
267
|
+
@user = user
|
|
268
|
+
@confirmation_url = edit_confirmation_url(token: token)
|
|
269
|
+
mail(to: user.email_address, subject: "Confirm your email")
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def magic_link(user, token)
|
|
273
|
+
@user = user
|
|
274
|
+
@magic_link_url = magic_link_login_url(token: token)
|
|
275
|
+
mail(to: user.email_address, subject: "Your sign-in link")
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
def password_reset(user, token)
|
|
279
|
+
@user = user
|
|
280
|
+
@reset_url = edit_password_url(token: token)
|
|
281
|
+
mail(to: user.email_address, subject: "Reset your password")
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Create corresponding views in `app/views/user_mailer/`:
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
app/views/user_mailer/
|
|
290
|
+
├── confirmation.html.erb
|
|
291
|
+
├── magic_link.html.erb
|
|
292
|
+
└── password_reset.html.erb
|
|
293
|
+
```
|
|
294
|
+
|
|
225
295
|
## Helpers
|
|
226
296
|
|
|
227
297
|
Available in controllers and views:
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* RailsSimpleAuth default styles
|
|
3
|
+
* These provide a minimal, clean appearance for auth pages.
|
|
4
|
+
* Override by providing your own layout in the initializer.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.rsa-body {
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0;
|
|
10
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
11
|
+
background-color: #f5f5f5;
|
|
12
|
+
min-height: 100vh;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.rsa-container {
|
|
16
|
+
max-width: 1200px;
|
|
17
|
+
margin: 0 auto;
|
|
18
|
+
padding: 0 1rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.rsa-header {
|
|
22
|
+
padding: 1.5rem 0;
|
|
23
|
+
text-align: center;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.rsa-header__title {
|
|
27
|
+
margin: 0;
|
|
28
|
+
font-size: 1.5rem;
|
|
29
|
+
font-weight: 600;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.rsa-header__title a {
|
|
33
|
+
color: #333;
|
|
34
|
+
text-decoration: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.rsa-header__title a:hover {
|
|
38
|
+
color: #007bff;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.rsa-main {
|
|
42
|
+
padding: 2rem 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.rsa-flash {
|
|
46
|
+
padding: 0.75rem 1rem;
|
|
47
|
+
margin-bottom: 1rem;
|
|
48
|
+
border-radius: 4px;
|
|
49
|
+
max-width: 400px;
|
|
50
|
+
margin-left: auto;
|
|
51
|
+
margin-right: auto;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.rsa-flash--notice,
|
|
55
|
+
.rsa-flash--success {
|
|
56
|
+
background-color: #d4edda;
|
|
57
|
+
color: #155724;
|
|
58
|
+
border: 1px solid #c3e6cb;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.rsa-flash--alert,
|
|
62
|
+
.rsa-flash--error {
|
|
63
|
+
background-color: #f8d7da;
|
|
64
|
+
color: #721c24;
|
|
65
|
+
border: 1px solid #f5c6cb;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.rsa-footer {
|
|
69
|
+
padding: 2rem 0;
|
|
70
|
+
text-align: center;
|
|
71
|
+
color: #666;
|
|
72
|
+
font-size: 0.875rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Auth form styles */
|
|
76
|
+
.rsa-auth-form {
|
|
77
|
+
max-width: 400px;
|
|
78
|
+
margin: 0 auto;
|
|
79
|
+
padding: 2rem;
|
|
80
|
+
background: #fff;
|
|
81
|
+
border-radius: 8px;
|
|
82
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.rsa-auth-form__title {
|
|
86
|
+
margin: 0 0 1.5rem;
|
|
87
|
+
font-size: 1.5rem;
|
|
88
|
+
font-weight: 600;
|
|
89
|
+
text-align: center;
|
|
90
|
+
color: #333;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.rsa-auth-form__form {
|
|
94
|
+
display: flex;
|
|
95
|
+
flex-direction: column;
|
|
96
|
+
gap: 1rem;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.rsa-auth-form__group {
|
|
100
|
+
display: flex;
|
|
101
|
+
flex-direction: column;
|
|
102
|
+
gap: 0.25rem;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.rsa-auth-form__label {
|
|
106
|
+
font-size: 0.875rem;
|
|
107
|
+
font-weight: 500;
|
|
108
|
+
color: #333;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.rsa-auth-form__input {
|
|
112
|
+
padding: 0.75rem;
|
|
113
|
+
border: 1px solid #ddd;
|
|
114
|
+
border-radius: 4px;
|
|
115
|
+
font-size: 1rem;
|
|
116
|
+
transition: border-color 0.2s;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.rsa-auth-form__input:focus {
|
|
120
|
+
outline: none;
|
|
121
|
+
border-color: #007bff;
|
|
122
|
+
box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.rsa-auth-form__submit {
|
|
126
|
+
padding: 0.75rem 1.5rem;
|
|
127
|
+
background-color: #007bff;
|
|
128
|
+
color: #fff;
|
|
129
|
+
border: none;
|
|
130
|
+
border-radius: 4px;
|
|
131
|
+
font-size: 1rem;
|
|
132
|
+
font-weight: 500;
|
|
133
|
+
cursor: pointer;
|
|
134
|
+
transition: background-color 0.2s;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.rsa-auth-form__submit:hover {
|
|
138
|
+
background-color: #0056b3;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.rsa-auth-form__submit:disabled {
|
|
142
|
+
background-color: #6c757d;
|
|
143
|
+
cursor: not-allowed;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.rsa-auth-form__divider {
|
|
147
|
+
text-align: center;
|
|
148
|
+
color: #666;
|
|
149
|
+
font-size: 0.875rem;
|
|
150
|
+
margin: 1rem 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.rsa-auth-form__magic-link-button {
|
|
154
|
+
display: flex;
|
|
155
|
+
align-items: center;
|
|
156
|
+
justify-content: center;
|
|
157
|
+
gap: 0.5rem;
|
|
158
|
+
padding: 0.75rem 1.5rem;
|
|
159
|
+
background-color: #6c757d;
|
|
160
|
+
color: #fff;
|
|
161
|
+
border: none;
|
|
162
|
+
border-radius: 4px;
|
|
163
|
+
font-size: 1rem;
|
|
164
|
+
text-decoration: none;
|
|
165
|
+
transition: background-color 0.2s;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.rsa-auth-form__magic-link-button:hover {
|
|
169
|
+
background-color: #5a6268;
|
|
170
|
+
color: #fff;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.rsa-auth-form__oauth {
|
|
174
|
+
display: flex;
|
|
175
|
+
flex-direction: column;
|
|
176
|
+
gap: 0.5rem;
|
|
177
|
+
margin-top: 1rem;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.rsa-auth-form__oauth-button {
|
|
181
|
+
display: flex;
|
|
182
|
+
align-items: center;
|
|
183
|
+
justify-content: center;
|
|
184
|
+
gap: 0.5rem;
|
|
185
|
+
padding: 0.75rem 1.5rem;
|
|
186
|
+
background-color: #fff;
|
|
187
|
+
color: #333;
|
|
188
|
+
border: 1px solid #ddd;
|
|
189
|
+
border-radius: 4px;
|
|
190
|
+
font-size: 1rem;
|
|
191
|
+
text-decoration: none;
|
|
192
|
+
transition: background-color 0.2s, border-color 0.2s;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.rsa-auth-form__oauth-button:hover {
|
|
196
|
+
background-color: #f8f9fa;
|
|
197
|
+
border-color: #ccc;
|
|
198
|
+
color: #333;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.rsa-auth-form__oauth-button img {
|
|
202
|
+
width: 20px;
|
|
203
|
+
height: 20px;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.rsa-auth-form__links {
|
|
207
|
+
display: flex;
|
|
208
|
+
justify-content: space-between;
|
|
209
|
+
margin-top: 1.5rem;
|
|
210
|
+
font-size: 0.875rem;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.rsa-auth-form__link {
|
|
214
|
+
color: #007bff;
|
|
215
|
+
text-decoration: none;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.rsa-auth-form__link:hover {
|
|
219
|
+
text-decoration: underline;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.rsa-auth-form__error {
|
|
223
|
+
padding: 0.75rem;
|
|
224
|
+
background-color: #f8d7da;
|
|
225
|
+
color: #721c24;
|
|
226
|
+
border: 1px solid #f5c6cb;
|
|
227
|
+
border-radius: 4px;
|
|
228
|
+
margin-bottom: 1rem;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.rsa-auth-form__error ul {
|
|
232
|
+
margin: 0;
|
|
233
|
+
padding-left: 1.25rem;
|
|
234
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title><%= content_for(:title) || "Authentication" %></title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<%= csrf_meta_tags %>
|
|
7
|
+
<%= csp_meta_tag %>
|
|
8
|
+
|
|
9
|
+
<%= yield :head %>
|
|
10
|
+
|
|
11
|
+
<%= stylesheet_link_tag "rails_simple_auth/application", media: "all" %>
|
|
12
|
+
</head>
|
|
13
|
+
|
|
14
|
+
<body class="rsa-body">
|
|
15
|
+
<div class="rsa-container">
|
|
16
|
+
<div class="rsa-header">
|
|
17
|
+
<h1 class="rsa-header__title">
|
|
18
|
+
<%= link_to RailsSimpleAuth.configuration.app_name || "App", main_app.root_path %>
|
|
19
|
+
</h1>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<% flash.each do |type, message| %>
|
|
23
|
+
<div class="rsa-flash rsa-flash--<%= type %>">
|
|
24
|
+
<%= message %>
|
|
25
|
+
</div>
|
|
26
|
+
<% end %>
|
|
27
|
+
|
|
28
|
+
<main class="rsa-main">
|
|
29
|
+
<%= yield %>
|
|
30
|
+
</main>
|
|
31
|
+
|
|
32
|
+
<footer class="rsa-footer">
|
|
33
|
+
<span class="rsa-footer__copyright">© <%= Date.current.year %></span>
|
|
34
|
+
</footer>
|
|
35
|
+
</div>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
@@ -6,7 +6,7 @@ module RailsSimpleAuth
|
|
|
6
6
|
:magic_link_expiry, :password_reset_expiry, :confirmation_expiry, :session_expiry,
|
|
7
7
|
:rate_limits,
|
|
8
8
|
:after_sign_in_path, :after_sign_out_path, :after_sign_up_path, :after_confirmation_path,
|
|
9
|
-
:layout,
|
|
9
|
+
:layout, :app_name,
|
|
10
10
|
:mailer_sender, :mailer_class,
|
|
11
11
|
:user_class_name, :session_class_name,
|
|
12
12
|
:password_minimum_length,
|
|
@@ -37,7 +37,8 @@ module RailsSimpleAuth
|
|
|
37
37
|
@after_sign_up_path = :root_path
|
|
38
38
|
@after_confirmation_path = :new_session_path
|
|
39
39
|
|
|
40
|
-
@layout = "
|
|
40
|
+
@layout = "rails_simple_auth"
|
|
41
|
+
@app_name = nil
|
|
41
42
|
|
|
42
43
|
@mailer_sender = "noreply@example.com"
|
|
43
44
|
@mailer_class = "RailsSimpleAuth::AuthMailer"
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rails_simple_auth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ivan Kuznetsov
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -50,6 +49,7 @@ files:
|
|
|
50
49
|
- CHANGELOG.md
|
|
51
50
|
- MIT-LICENSE
|
|
52
51
|
- README.md
|
|
52
|
+
- app/assets/stylesheets/rails_simple_auth/application.css
|
|
53
53
|
- app/controllers/rails_simple_auth/base_controller.rb
|
|
54
54
|
- app/controllers/rails_simple_auth/confirmations_controller.rb
|
|
55
55
|
- app/controllers/rails_simple_auth/omniauth_callbacks_controller.rb
|
|
@@ -57,6 +57,7 @@ files:
|
|
|
57
57
|
- app/controllers/rails_simple_auth/registrations_controller.rb
|
|
58
58
|
- app/controllers/rails_simple_auth/sessions_controller.rb
|
|
59
59
|
- app/mailers/rails_simple_auth/auth_mailer.rb
|
|
60
|
+
- app/views/layouts/rails_simple_auth.html.erb
|
|
60
61
|
- app/views/rails_simple_auth/confirmations/new.html.erb
|
|
61
62
|
- app/views/rails_simple_auth/mailers/confirmation.html.erb
|
|
62
63
|
- app/views/rails_simple_auth/mailers/magic_link.html.erb
|
|
@@ -95,7 +96,6 @@ metadata:
|
|
|
95
96
|
bug_tracker_uri: https://github.com/ivankuznetsov/rails_simple_auth/issues
|
|
96
97
|
documentation_uri: https://github.com/ivankuznetsov/rails_simple_auth#readme
|
|
97
98
|
rubygems_mfa_required: 'true'
|
|
98
|
-
post_install_message:
|
|
99
99
|
rdoc_options: []
|
|
100
100
|
require_paths:
|
|
101
101
|
- lib
|
|
@@ -110,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
110
110
|
- !ruby/object:Gem::Version
|
|
111
111
|
version: '0'
|
|
112
112
|
requirements: []
|
|
113
|
-
rubygems_version: 3.
|
|
114
|
-
signing_key:
|
|
113
|
+
rubygems_version: 3.6.9
|
|
115
114
|
specification_version: 4
|
|
116
115
|
summary: Simple, secure authentication for Rails 8+ applications
|
|
117
116
|
test_files: []
|