securial 2.1.5 → 3.0.0
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/README.md +4 -1
- data/app/controllers/securial/accounts_controller.rb +4 -4
- data/app/controllers/securial/passwords_controller.rb +3 -3
- data/app/controllers/securial/role_assignments_controller.rb +4 -4
- data/app/controllers/securial/roles_controller.rb +2 -2
- data/app/controllers/securial/sessions_controller.rb +1 -1
- data/app/controllers/securial/users_controller.rb +2 -2
- data/lib/generators/securial/scaffold/templates/controller.erb +2 -2
- data/lib/securial/cli.rb +16 -26
- data/lib/securial/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ffba4e0acb875cdfa25cf3e55ccf964c3c017b88878f8d958d1bf86adb95534
|
|
4
|
+
data.tar.gz: cdf490eb49b905cba1343c197767339b5395bc1836a37db85d3cb6deb6481b58
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9833d4f8c1b0bfb40882fdab02a9cfea8b6e1c2c7607354a804f5907e0bbceac9e24b43db657f9dc2cce43249ab93fdbdf9e013dfaa7d72bd183034bac6fec66
|
|
7
|
+
data.tar.gz: f647ff3f14eecdff509a93493498fc3413f03331b43173cd8decc3d82fc86bf4d4de0a8276b9ed4815596ea6e3d894af1691931757d4cf83cf3bcc8eea431fd4
|
data/README.md
CHANGED
|
@@ -12,12 +12,15 @@
|
|
|
12
12
|
[](https://github.com/alybadawy/securial/wiki)
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
|
|
15
16
|
---
|
|
16
17
|
|
|
17
18
|
## Overview
|
|
18
19
|
|
|
19
20
|
### 🛡️ What is Securial?
|
|
20
21
|
|
|
22
|
+
<img align="right" width="400" height="400" alt="Securial Logo" src="https://github.com/user-attachments/assets/0950aba1-de3e-467d-a335-55f2fa47a8ac" />
|
|
23
|
+
|
|
21
24
|
**Securial** is a mountable Rails engine that provides robust, extensible authentication and access control for Rails applications. It supports:
|
|
22
25
|
|
|
23
26
|
- 🔑 JWT-based authentication
|
|
@@ -124,5 +127,5 @@ The gem is available as open source under the terms of the [MIT license](https:/
|
|
|
124
127
|
|
|
125
128
|
---
|
|
126
129
|
|
|
127
|
-
|
|
130
|
+
|
|
128
131
|

|
|
@@ -54,7 +54,7 @@ module Securial
|
|
|
54
54
|
render :show, status: :created, location: @securial_user
|
|
55
55
|
else
|
|
56
56
|
render json: {
|
|
57
|
-
errors: @securial_user.errors.full_messages }, status: :
|
|
57
|
+
errors: @securial_user.errors.full_messages }, status: :unprocessable_content
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -74,13 +74,13 @@ module Securial
|
|
|
74
74
|
render json: {
|
|
75
75
|
errors: @securial_user.errors.full_messages,
|
|
76
76
|
instructions: "Please ensure all required fields are filled out correctly.",
|
|
77
|
-
}, status: :
|
|
77
|
+
}, status: :unprocessable_content
|
|
78
78
|
end
|
|
79
79
|
else
|
|
80
80
|
render json: {
|
|
81
81
|
errors: ["Current password is incorrect"],
|
|
82
82
|
instructions: "Please verify your current password and try again.",
|
|
83
|
-
}, status: :
|
|
83
|
+
}, status: :unprocessable_content
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
@@ -99,7 +99,7 @@ module Securial
|
|
|
99
99
|
render json: {
|
|
100
100
|
errors: ["Current password is incorrect"],
|
|
101
101
|
instructions: "Please verify your current password and try again.",
|
|
102
|
-
}, status: :
|
|
102
|
+
}, status: :unprocessable_content
|
|
103
103
|
end
|
|
104
104
|
end
|
|
105
105
|
|
|
@@ -48,7 +48,7 @@ module Securial
|
|
|
48
48
|
if @user.update(params.permit(:password, :password_confirmation))
|
|
49
49
|
render status: :ok, json: { message: "Password has been reset." }
|
|
50
50
|
else
|
|
51
|
-
render status: :
|
|
51
|
+
render status: :unprocessable_content, json: { errors: @user.errors }
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
@@ -65,10 +65,10 @@ module Securial
|
|
|
65
65
|
begin
|
|
66
66
|
@user = User.find_by_reset_password_token!(params[:token]) # rubocop:disable Rails/DynamicFindBy
|
|
67
67
|
unless @user.reset_password_token_valid?
|
|
68
|
-
render status: :
|
|
68
|
+
render status: :unprocessable_content, json: { errors: { token: "is invalid or has expired" } } and return
|
|
69
69
|
end
|
|
70
70
|
rescue ActiveSupport::MessageVerifier::InvalidSignature, ActiveRecord::RecordNotFound
|
|
71
|
-
render status: :
|
|
71
|
+
render status: :unprocessable_content, json: { errors: { token: "is invalid or has expired" } } and return
|
|
72
72
|
end
|
|
73
73
|
end
|
|
74
74
|
end
|
|
@@ -29,7 +29,7 @@ module Securial
|
|
|
29
29
|
render json: {
|
|
30
30
|
errors: ["Role already assigned to user"],
|
|
31
31
|
instructions: "Please check the user's current roles before assigning a new one.",
|
|
32
|
-
}, status: :
|
|
32
|
+
}, status: :unprocessable_content
|
|
33
33
|
return
|
|
34
34
|
end
|
|
35
35
|
@securial_role_assignment = RoleAssignment.new(securial_role_assignment_params)
|
|
@@ -55,7 +55,7 @@ module Securial
|
|
|
55
55
|
render json: {
|
|
56
56
|
errors: ["Role is not assigned to user"],
|
|
57
57
|
instructions: "Please check the user's current roles before attempting to remove a role.",
|
|
58
|
-
}, status: :
|
|
58
|
+
}, status: :unprocessable_content
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
@@ -74,14 +74,14 @@ module Securial
|
|
|
74
74
|
render json: {
|
|
75
75
|
errors: ["User not found"],
|
|
76
76
|
instructions: "Please check the user ID and try again.",
|
|
77
|
-
}, status: :
|
|
77
|
+
}, status: :unprocessable_content
|
|
78
78
|
return false
|
|
79
79
|
end
|
|
80
80
|
if @securial_role.nil?
|
|
81
81
|
render json: {
|
|
82
82
|
errors: ["Role not found"],
|
|
83
83
|
instructions: "Please check the role ID and try again.",
|
|
84
|
-
}, status: :
|
|
84
|
+
}, status: :unprocessable_content
|
|
85
85
|
return false
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -48,7 +48,7 @@ module Securial
|
|
|
48
48
|
if @securial_role.save
|
|
49
49
|
render :show, status: :created, location: @securial_role
|
|
50
50
|
else
|
|
51
|
-
render json: @securial_role.errors, status: :
|
|
51
|
+
render json: @securial_role.errors, status: :unprocessable_content
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
|
|
@@ -63,7 +63,7 @@ module Securial
|
|
|
63
63
|
if @securial_role.update(securial_role_params)
|
|
64
64
|
render :show
|
|
65
65
|
else
|
|
66
|
-
render json: @securial_role.errors, status: :
|
|
66
|
+
render json: @securial_role.errors, status: :unprocessable_content
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
69
|
|
|
@@ -49,7 +49,7 @@ module Securial
|
|
|
49
49
|
if @securial_user.save
|
|
50
50
|
render :show, status: :created, location: @securial_user
|
|
51
51
|
else
|
|
52
|
-
render json: @securial_user.errors, status: :
|
|
52
|
+
render json: @securial_user.errors, status: :unprocessable_content
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -64,7 +64,7 @@ module Securial
|
|
|
64
64
|
if @securial_user.update(securial_user_params)
|
|
65
65
|
render :show, status: :ok, location: @securial_user
|
|
66
66
|
else
|
|
67
|
-
render json: @securial_user.errors, status: :
|
|
67
|
+
render json: @securial_user.errors, status: :unprocessable_content
|
|
68
68
|
end
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -15,7 +15,7 @@ module Securial
|
|
|
15
15
|
if @<%= singular_table_name %>.save
|
|
16
16
|
render :show, status: :created, location: @<%= singular_table_name %>
|
|
17
17
|
else
|
|
18
|
-
render json: @<%= singular_table_name %>.errors, status: :
|
|
18
|
+
render json: @<%= singular_table_name %>.errors, status: :unprocessable_content
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ module Securial
|
|
|
23
23
|
if @<%= singular_table_name %>.update(<%= singular_table_name %>_params)
|
|
24
24
|
render :show
|
|
25
25
|
else
|
|
26
|
-
render json: @<%= singular_table_name %>.errors, status: :
|
|
26
|
+
render json: @<%= singular_table_name %>.errors, status: :unprocessable_content
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
data/lib/securial/cli.rb
CHANGED
|
@@ -208,43 +208,33 @@ module Securial
|
|
|
208
208
|
adapter = config.dig("default", "adapter")
|
|
209
209
|
return unless adapter.is_a?(String) && %w[postgresql mysql2].include?(adapter)
|
|
210
210
|
|
|
211
|
-
# Step 2: Modify the raw file line-by-line
|
|
211
|
+
# Step 2: Modify the raw YAML file line-by-line
|
|
212
212
|
lines = File.readlines(db_config_path)
|
|
213
|
-
inside_default = false
|
|
214
213
|
updated_lines = []
|
|
214
|
+
inside_default = false
|
|
215
|
+
inserted = false
|
|
216
|
+
|
|
217
|
+
lines.each do |line|
|
|
218
|
+
updated_lines << line
|
|
215
219
|
|
|
216
|
-
lines.each_with_index do |line, index|
|
|
217
220
|
if line =~ /^default:/
|
|
218
221
|
inside_default = true
|
|
219
|
-
updated_lines << line
|
|
220
222
|
next
|
|
221
223
|
end
|
|
222
224
|
|
|
223
|
-
if inside_default
|
|
224
|
-
#
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
225
|
+
if inside_default && line.strip.start_with?("adapter:")
|
|
226
|
+
# Insert immediately after the adapter line
|
|
227
|
+
updated_lines += [
|
|
228
|
+
" host: <%= ENV.fetch(\"DB_HOST\", \"localhost\") %>\n",
|
|
229
|
+
" username: <%= ENV.fetch(\"DB_USERNAME\") { \"postgres\" } %>\n",
|
|
230
|
+
" password: <%= ENV.fetch(\"DB_PASSWORD\") { \"postgres\" } %>\n",
|
|
231
|
+
]
|
|
232
|
+
inserted = true
|
|
231
233
|
end
|
|
232
234
|
|
|
233
|
-
|
|
235
|
+
# Exit `default:` block when another top-level key appears
|
|
236
|
+
inside_default = false if inside_default && line =~ /^\S/ && line !~ /^\s/
|
|
234
237
|
end
|
|
235
|
-
|
|
236
|
-
# Find index of `default:` line to insert after
|
|
237
|
-
insert_index = updated_lines.find_index { |l| l =~ /^default:/ }
|
|
238
|
-
return unless insert_index
|
|
239
|
-
|
|
240
|
-
injection = [
|
|
241
|
-
" host: <%= ENV.fetch(\"DB_HOST\", \"localhost\") %>",
|
|
242
|
-
" username: <%= ENV.fetch(\"DB_USERNAME\") { \"postgres\" } %>",
|
|
243
|
-
" password: <%= ENV.fetch(\"DB_PASSWORD\") { \"postgres\" } %>",
|
|
244
|
-
]
|
|
245
|
-
|
|
246
|
-
updated_lines.insert(insert_index + 1, *injection)
|
|
247
|
-
|
|
248
238
|
File.write(db_config_path, updated_lines.join)
|
|
249
239
|
end
|
|
250
240
|
|
data/lib/securial/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: securial
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aly Badawy
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-
|
|
10
|
+
date: 2025-12-26 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rails
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '8.
|
|
18
|
+
version: '8.1'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '8.
|
|
25
|
+
version: '8.1'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: bcrypt
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -201,7 +201,7 @@ licenses:
|
|
|
201
201
|
- MIT
|
|
202
202
|
metadata:
|
|
203
203
|
homepage_uri: https://github.com/AlyBadawy/Securial/wiki
|
|
204
|
-
release_date: '2025-
|
|
204
|
+
release_date: '2025-12-26'
|
|
205
205
|
allowed_push_host: https://rubygems.org
|
|
206
206
|
source_code_uri: https://github.com/AlyBadawy/Securial
|
|
207
207
|
documentation_uri: https://alybadawy.github.io/Securial/_index.html
|
|
@@ -228,14 +228,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
228
228
|
requirements:
|
|
229
229
|
- - ">="
|
|
230
230
|
- !ruby/object:Gem::Version
|
|
231
|
-
version:
|
|
231
|
+
version: 4.0.0
|
|
232
232
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
233
|
requirements:
|
|
234
234
|
- - ">="
|
|
235
235
|
- !ruby/object:Gem::Version
|
|
236
236
|
version: '0'
|
|
237
237
|
requirements: []
|
|
238
|
-
rubygems_version:
|
|
238
|
+
rubygems_version: 4.0.3
|
|
239
239
|
specification_version: 4
|
|
240
240
|
summary: Authentication and access control Rails engine for your API.
|
|
241
241
|
test_files: []
|