rails_simple_auth 1.0.4 → 1.0.6
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 +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +1 -1
- data/lib/generators/rails_simple_auth/install/install_generator.rb +7 -7
- data/lib/generators/rails_simple_auth/temporary_users/USAGE +2 -2
- data/lib/generators/rails_simple_auth/temporary_users/templates/add_temporary_to_users.rb.erb +1 -0
- data/lib/generators/rails_simple_auth/temporary_users/temporary_users_generator.rb +2 -2
- data/lib/rails_simple_auth/controllers/concerns/session_management.rb +1 -1
- data/lib/rails_simple_auth/engine.rb +7 -0
- data/lib/rails_simple_auth/models/concerns/temporary_user.rb +1 -1
- data/lib/rails_simple_auth/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d04d803a06cf6538074412280d1b8b526b227f62433c6e9431adfb52c0a040d
|
|
4
|
+
data.tar.gz: 86f0719d9a2422895271a8c143856e4fd530f0bb93d2bd6d3f037e22808722a2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 02af0cb35354280587ad5ada2e4ffd9d59ba9ce193b28f56120bb61de550a116a0643a0d61b0d10e870db1da5ff6b2a18fee96431e650d52ef5824d7a2dabaa1
|
|
7
|
+
data.tar.gz: ef261bb888584b7ad366b0bea4ae253c2d86fd81ae09072b0a39d0d1e4e52492eedf1d1fdd6a8c366500ec3ae7d101d0b452c1965509a7b6bffe236831f972e2
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.0.6] - 2025-01-19
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Database-level email uniqueness** - Partial unique index ensures permanent users have unique emails at database level (not just Rails validation)
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Simplified `temporary?` method for cleaner implementation
|
|
19
|
+
|
|
20
|
+
## [1.0.5] - 2025-01-19
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- **Secure OmniAuth by default** - Automatically restricts OAuth initiation to POST requests only (prevents CSRF attacks)
|
|
25
|
+
|
|
10
26
|
## [1.0.4] - 2025-01-19
|
|
11
27
|
|
|
12
28
|
### Added
|
data/README.md
CHANGED
|
@@ -40,15 +40,14 @@ module RailsSimpleAuth
|
|
|
40
40
|
say 'Next steps:'
|
|
41
41
|
say ' 1. Review and edit the migration: db/migrate/xxx_add_rails_simple_auth.rb'
|
|
42
42
|
say ' 2. Run: rails db:migrate'
|
|
43
|
-
say " 3. Add
|
|
43
|
+
say " 3. Add authentication to your #{options[:user_model]} model:"
|
|
44
44
|
say ''
|
|
45
45
|
say " class #{options[:user_model]} < ApplicationRecord"
|
|
46
|
-
say '
|
|
47
|
-
say ' include RailsSimpleAuth::Models::Concerns::Confirmable # optional'
|
|
48
|
-
say ' include RailsSimpleAuth::Models::Concerns::MagicLinkable # optional'
|
|
49
|
-
say ' include RailsSimpleAuth::Models::Concerns::OAuthConnectable # optional'
|
|
46
|
+
say ' authenticates_with :confirmable, :magic_linkable'
|
|
50
47
|
say ' end'
|
|
51
48
|
say ''
|
|
49
|
+
say ' Available modules: :confirmable, :magic_linkable, :oauth, :temporary'
|
|
50
|
+
say ''
|
|
52
51
|
say ' 4. Add before_action to protect routes:'
|
|
53
52
|
say ''
|
|
54
53
|
say ' class ApplicationController < ActionController::Base'
|
|
@@ -56,8 +55,9 @@ module RailsSimpleAuth
|
|
|
56
55
|
say ' end'
|
|
57
56
|
say ''
|
|
58
57
|
say 'Optional generators:'
|
|
59
|
-
say ' rails generate rails_simple_auth:views
|
|
60
|
-
say ' rails generate rails_simple_auth:css
|
|
58
|
+
say ' rails generate rails_simple_auth:views # Copy views for customization'
|
|
59
|
+
say ' rails generate rails_simple_auth:css # Copy CSS for styling'
|
|
60
|
+
say ' rails generate rails_simple_auth:temporary_users # Add guest account support'
|
|
61
61
|
say ''
|
|
62
62
|
end
|
|
63
63
|
end
|
|
@@ -9,8 +9,8 @@ Example:
|
|
|
9
9
|
This will create:
|
|
10
10
|
db/migrate/YYYYMMDDHHMMSS_add_temporary_to_users.rb
|
|
11
11
|
|
|
12
|
-
After running the migration,
|
|
13
|
-
|
|
12
|
+
After running the migration, add :temporary to your User model:
|
|
13
|
+
authenticates_with :confirmable, :temporary
|
|
14
14
|
|
|
15
15
|
And enable in your initializer:
|
|
16
16
|
config.temporary_users_enabled = true
|
data/lib/generators/rails_simple_auth/temporary_users/templates/add_temporary_to_users.rb.erb
CHANGED
|
@@ -4,5 +4,6 @@ class AddTemporaryToUsers < ActiveRecord::Migration[<%= Rails::VERSION::MAJOR %>
|
|
|
4
4
|
def change
|
|
5
5
|
add_column :users, :temporary, :boolean, default: false, null: false
|
|
6
6
|
add_index :users, [:temporary, :created_at], name: "index_users_on_temporary_and_created_at"
|
|
7
|
+
add_index :users, :email_address, unique: true, where: "temporary = false", name: "index_users_on_email_address_permanent_unique"
|
|
7
8
|
end
|
|
8
9
|
end
|
|
@@ -28,8 +28,8 @@ module RailsSimpleAuth
|
|
|
28
28
|
say 'Next steps:', :yellow
|
|
29
29
|
say ' 1. Run: bin/rails db:migrate'
|
|
30
30
|
say ''
|
|
31
|
-
say ' 2.
|
|
32
|
-
say '
|
|
31
|
+
say ' 2. Add :temporary to your User model:'
|
|
32
|
+
say ' authenticates_with :confirmable, :temporary'
|
|
33
33
|
say ''
|
|
34
34
|
say ' 3. Enable in your initializer:'
|
|
35
35
|
say ' config.temporary_users_enabled = true'
|
|
@@ -58,7 +58,7 @@ module RailsSimpleAuth
|
|
|
58
58
|
temp_user.destroy!
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
-
Rails.logger.info
|
|
61
|
+
Rails.logger.info "[RailsSimpleAuth] Destroyed temporary user #{temp_user_id} on sign in"
|
|
62
62
|
rescue ActiveRecord::RecordNotDestroyed => e
|
|
63
63
|
Rails.logger.error("[RailsSimpleAuth] Failed to destroy temporary user #{temp_user_id}: #{e.message}")
|
|
64
64
|
end
|
|
@@ -22,5 +22,12 @@ module RailsSimpleAuth
|
|
|
22
22
|
include RailsSimpleAuth::Model
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
# Secure OmniAuth by default - only allow POST to initiate OAuth (prevents CSRF)
|
|
27
|
+
initializer 'rails_simple_auth.omniauth', after: :load_config_initializers do
|
|
28
|
+
if defined?(OmniAuth)
|
|
29
|
+
OmniAuth.config.allowed_request_methods = %i[post]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
25
32
|
end
|
|
26
33
|
end
|