securial 0.6.1 → 0.8.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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -5
  3. data/app/controllers/concerns/securial/identity.rb +17 -16
  4. data/app/controllers/securial/accounts_controller.rb +2 -2
  5. data/app/controllers/securial/passwords_controller.rb +2 -2
  6. data/app/controllers/securial/role_assignments_controller.rb +5 -7
  7. data/app/controllers/securial/roles_controller.rb +1 -0
  8. data/app/controllers/securial/sessions_controller.rb +6 -8
  9. data/app/controllers/securial/status_controller.rb +1 -1
  10. data/app/controllers/securial/users_controller.rb +8 -7
  11. data/app/mailers/securial/securial_mailer.rb +17 -6
  12. data/app/models/concerns/securial/password_resettable.rb +1 -1
  13. data/app/models/securial/application_record.rb +1 -1
  14. data/app/models/securial/role.rb +1 -1
  15. data/app/models/securial/session.rb +16 -5
  16. data/app/models/securial/user.rb +4 -6
  17. data/app/views/securial/securial_mailer/forgot_password.html.erb +20 -0
  18. data/app/views/securial/securial_mailer/forgot_password.text.erb +14 -0
  19. data/app/views/securial/securial_mailer/sign_in.html.erb +31 -0
  20. data/app/views/securial/securial_mailer/sign_in.text.erb +17 -0
  21. data/app/views/securial/securial_mailer/update_account.html.erb +15 -0
  22. data/app/views/securial/securial_mailer/update_account.text.erb +11 -0
  23. data/app/views/securial/securial_mailer/welcome.html.erb +11 -0
  24. data/app/views/securial/securial_mailer/welcome.text.erb +8 -0
  25. data/app/views/securial/users/_securial_user.json.jbuilder +9 -3
  26. data/config/routes.rb +5 -1
  27. data/db/migrate/{20250515104930_create_securial_roles.rb → 20250603130214_create_securial_roles.rb} +0 -2
  28. data/db/migrate/{20250517155521_create_securial_users.rb → 20250604110520_create_securial_users.rb} +8 -3
  29. data/db/migrate/{20250519075407_create_securial_sessions.rb → 20250604184841_create_securial_sessions.rb} +4 -0
  30. data/lib/generators/securial/install/templates/securial_initializer.erb +2 -2
  31. data/lib/generators/securial/scaffold/templates/controller.erb +1 -0
  32. data/lib/generators/securial/scaffold/templates/routes.erb +1 -1
  33. data/lib/securial/auth/auth_encoder.rb +42 -43
  34. data/lib/securial/auth/session_creator.rb +15 -12
  35. data/lib/securial/auth/token_generator.rb +26 -0
  36. data/lib/securial/auth.rb +12 -0
  37. data/lib/securial/config/configuration.rb +33 -15
  38. data/lib/securial/config/validation/logger_validation.rb +29 -0
  39. data/lib/securial/config/validation/mailer_validation.rb +24 -0
  40. data/lib/securial/config/validation/password_validation.rb +91 -0
  41. data/lib/securial/config/validation/response_validation.rb +37 -0
  42. data/lib/securial/config/validation/roles_validation.rb +32 -0
  43. data/lib/securial/config/validation/security_validation.rb +56 -0
  44. data/lib/securial/config/validation/session_validation.rb +87 -0
  45. data/lib/securial/config/validation.rb +16 -239
  46. data/lib/securial/config.rb +26 -0
  47. data/lib/securial/engine.rb +7 -70
  48. data/lib/securial/engine_initializers.rb +33 -0
  49. data/lib/securial/error/auth.rb +21 -0
  50. data/lib/securial/error/base_securial_error.rb +16 -0
  51. data/lib/securial/error/config.rb +37 -0
  52. data/lib/securial/error.rb +9 -0
  53. data/lib/securial/helpers/normalizing_helper.rb +11 -9
  54. data/lib/securial/helpers/regex_helper.rb +12 -10
  55. data/lib/securial/helpers/roles_helper.rb +17 -0
  56. data/lib/securial/helpers.rb +10 -0
  57. data/lib/securial/logger/broadcaster.rb +60 -0
  58. data/lib/securial/logger/builder.rb +45 -0
  59. data/lib/securial/logger/formatter.rb +35 -0
  60. data/lib/securial/logger.rb +7 -63
  61. data/lib/securial/middleware/request_tag_logger.rb +39 -0
  62. data/lib/securial/middleware.rb +13 -0
  63. data/lib/securial/version.rb +1 -1
  64. data/lib/securial.rb +2 -20
  65. metadata +45 -150
  66. data/app/views/securial/securial_mailer/reset_password.html.erb +0 -5
  67. data/app/views/securial/securial_mailer/reset_password.text.erb +0 -4
  68. data/lib/securial/auth/_index.rb +0 -3
  69. data/lib/securial/auth/errors.rb +0 -15
  70. data/lib/securial/config/_index.rb +0 -3
  71. data/lib/securial/config/errors.rb +0 -20
  72. data/lib/securial/helpers/_index.rb +0 -2
  73. data/lib/securial/inspectors/_index.rb +0 -1
  74. data/lib/securial/inspectors/route_inspector.rb +0 -52
  75. data/lib/securial/key_transformer.rb +0 -32
  76. data/lib/securial/middleware/_index.rb +0 -3
  77. data/lib/securial/middleware/request_logger_tag.rb +0 -18
  78. data/lib/securial/middleware/transform_request_keys.rb +0 -33
  79. data/lib/securial/middleware/transform_response_keys.rb +0 -45
  80. data/lib/securial/rack_attack.rb +0 -48
  81. /data/db/migrate/{20250518122749_create_securial_role_assignments.rb → 20250604123805_create_securial_role_assignments.rb} +0 -0
  82. /data/lib/generators/securial/install/{views_generastor.rb → views_generator.rb} +0 -0
@@ -0,0 +1,45 @@
1
+ require "logger"
2
+ require "active_support/logger"
3
+ require "active_support/tagged_logging"
4
+
5
+ require "securial/logger/broadcaster"
6
+ require "securial/logger/formatter"
7
+
8
+ module Securial
9
+ module Logger
10
+ class Builder
11
+ def self.build
12
+ loggers = []
13
+ progname = "Securial"
14
+
15
+ file_logger_enabled = Securial.configuration.log_to_file
16
+ file_logger_level = Securial.configuration.log_file_level
17
+ stdout_logger_enabled = Securial.configuration.log_to_stdout
18
+ stdout_logger_level = Securial.configuration.log_stdout_level
19
+
20
+ create_file_logger(progname, file_logger_level, loggers) if file_logger_enabled
21
+ create_stdout_logger(progname, stdout_logger_level, loggers) if stdout_logger_enabled
22
+
23
+ Broadcaster.new(loggers)
24
+ end
25
+
26
+ def self.create_file_logger(progname, level, loggers)
27
+ file_logger = ::Logger.new(Rails.root.join("log", "securial-#{Rails.env}.log"))
28
+ file_logger.level = level
29
+ file_logger.progname = progname
30
+ file_logger.formatter = Formatter::PlainFormatter.new
31
+ tagged_file_logger = ActiveSupport::TaggedLogging.new(file_logger)
32
+ loggers << tagged_file_logger
33
+ end
34
+
35
+ def self.create_stdout_logger(progname, level, loggers)
36
+ stdout_logger = ::Logger.new($stdout)
37
+ stdout_logger.level = level
38
+ stdout_logger.progname = progname
39
+ stdout_logger.formatter = Formatter::ColorfulFormatter.new
40
+ tagged_stdout_logger = ActiveSupport::TaggedLogging.new(stdout_logger)
41
+ loggers << tagged_stdout_logger
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,35 @@
1
+ module Securial
2
+ module Logger
3
+ module Formatter
4
+ COLORS = {
5
+ "DEBUG" => "\e[36m", # cyan
6
+ "INFO" => "\e[32m", # green
7
+ "WARN" => "\e[33m", # yellow
8
+ "ERROR" => "\e[31m", # red
9
+ "FATAL" => "\e[35m", # magenta
10
+ "UNKNOWN" => "\e[37m", # white
11
+ }.freeze
12
+ CLEAR = "\e[0m"
13
+ SEVERITY_WIDTH = 5
14
+
15
+ class ColorfulFormatter
16
+ def call(severity, timestamp, progname, msg)
17
+ color = COLORS[severity] || CLEAR
18
+ padded_severity = severity.ljust(SEVERITY_WIDTH)
19
+ formatted = "[#{progname}][#{timestamp.strftime("%Y-%m-%d %H:%M:%S")}] #{padded_severity} -- #{msg}\n"
20
+
21
+ "#{color}#{formatted}#{CLEAR}"
22
+ end
23
+ end
24
+
25
+ class PlainFormatter
26
+ def call(severity, timestamp, progname, msg)
27
+ padded_severity = severity.ljust(SEVERITY_WIDTH)
28
+ formatted = "[#{timestamp.strftime("%Y-%m-%d %H:%M:%S")}] #{padded_severity} -- #{msg}\n"
29
+
30
+ formatted
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,71 +1,15 @@
1
- require "logger"
2
- require "active_support/logger"
3
- require "active_support/tagged_logging"
1
+ require_relative "logger/builder"
4
2
 
5
3
  module Securial
6
- class Logger
7
- def self.build
8
- outputs = []
4
+ class << self
5
+ attr_accessor :logger
9
6
 
10
- unless Securial.configuration.log_to_file == false
11
- log_file = Rails.root.join("log", "securial.log").open("a")
12
- log_file.sync = true
13
- outputs << log_file
14
- end
15
-
16
- unless Securial.configuration.log_to_stdout == false
17
- outputs << STDOUT
18
- end
19
-
20
- if outputs.empty?
21
- null_logger = ::Logger.new(IO::NULL)
22
- return ActiveSupport::TaggedLogging.new(null_logger)
23
- end
24
-
25
- logger = ActiveSupport::Logger.new(MultiIO.new(*outputs))
26
- logger.level = resolve_log_level
27
- logger.formatter = ::Logger::Formatter.new
28
-
29
- ActiveSupport::TaggedLogging.new(logger)
30
- end
31
-
32
- def self.resolve_log_level
33
- file_level = Securial.configuration.log_file_level
34
- stdout_level = Securial.configuration.log_stdout_level
35
-
36
- # Use the lower (more verbose) level of the two
37
- levels = [file_level, stdout_level].compact.map do |lvl|
38
- begin
39
- ::Logger.const_get(lvl.to_s.upcase)
40
- rescue NameError
41
- nil
42
- end
43
- end.compact
44
-
45
- levels.min || ::Logger::INFO
7
+ def logger
8
+ @logger ||= Logger::Builder.build
46
9
  end
47
10
 
48
- private
49
-
50
- class MultiIO
51
- def initialize(*targets)
52
- @targets = targets
53
- end
54
-
55
- def write(*args)
56
- @targets.each { |t| t.write(*args) }
57
- end
58
-
59
- def close
60
- @targets.each do |t|
61
- next if [STDOUT, STDERR].include?(t)
62
- t.close
63
- end
64
- end
65
-
66
- def flush
67
- @targets.each { |t| t.flush if t.respond_to?(:flush) }
68
- end
11
+ def logger=(logger)
12
+ @logger = logger
69
13
  end
70
14
  end
71
15
  end
@@ -0,0 +1,39 @@
1
+ module Securial
2
+ module Middleware
3
+ class RequestTagLogger
4
+ def initialize(app, logger = Securial.logger)
5
+ @app = app
6
+ @logger = logger
7
+ end
8
+
9
+ def call(env)
10
+ request_id = request_id_from_env(env)
11
+ ip_address = ip_from_env(env)
12
+ user_agent = user_agent_from_env(env)
13
+
14
+ tags = []
15
+ tags << request_id if request_id
16
+ tags << "IP:#{ip_address}" if ip_address
17
+ tags << "UA:#{user_agent}" if user_agent
18
+
19
+ @logger.tagged(*tags) do
20
+ @app.call(env)
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def request_id_from_env(env)
27
+ env["action_dispatch.request_id"] || env["HTTP_X_REQUEST_ID"]
28
+ end
29
+
30
+ def ip_from_env(env)
31
+ env["action_dispatch.remote_ip"]&.to_s || env["REMOTE_ADDR"]
32
+ end
33
+
34
+ def user_agent_from_env(env)
35
+ env["HTTP_USER_AGENT"]
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,13 @@
1
+ require "securial/middleware/request_tag_logger"
2
+
3
+ module Securial
4
+ module Middleware
5
+ # This module serves as a namespace for all middleware components in the Securial gem.
6
+ # It currently includes the RequestTagLogger middleware, which tags logs with request IDs.
7
+ #
8
+ # Additional middleware can be added here as the gem evolves.
9
+ #
10
+ # Example usage:
11
+ # use Securial::Middleware::RequestTagLogger
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Securial
2
- VERSION = "0.6.1".freeze
2
+ VERSION = "0.8.0".freeze
3
3
  end
data/lib/securial.rb CHANGED
@@ -5,25 +5,7 @@ require "jbuilder"
5
5
 
6
6
  module Securial
7
7
  class << self
8
- attr_accessor :configuration
9
-
10
- def configuration
11
- @configuration ||= Securial::Config::Configuration.new
12
- end
13
-
14
- def configuration=(config)
15
- @configuration = config
16
- Securial::Config::Validation.validate_all!(configuration)
17
- end
18
-
19
- def configure
20
- yield(configuration)
21
- end
22
-
23
- # Returns the pluralized form of the admin role.
24
- # This behavior is intentional and aligns with the project's routing conventions.
25
- def admin_namespace
26
- configuration.admin_role.to_s.pluralize.downcase
27
- end
8
+ delegate :protected_namespace, to: Securial::Helpers::RolesHelper
9
+ delegate :titleized_admin_role, to: Securial::Helpers::RolesHelper
28
10
  end
29
11
  end
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: 0.6.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aly Badawy
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-30 00:00:00.000000000 Z
10
+ date: 2025-06-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -65,132 +65,6 @@ dependencies:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
67
  version: '2.10'
68
- - !ruby/object:Gem::Dependency
69
- name: ostruct
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '0.6'
75
- type: :runtime
76
- prerelease: false
77
- version_requirements: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '0.6'
82
- - !ruby/object:Gem::Dependency
83
- name: rack-attack
84
- requirement: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '6.7'
89
- type: :runtime
90
- prerelease: false
91
- version_requirements: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '6.7'
96
- - !ruby/object:Gem::Dependency
97
- name: faker
98
- requirement: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '3.5'
103
- type: :development
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '3.5'
110
- - !ruby/object:Gem::Dependency
111
- name: capybara
112
- requirement: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '3.40'
117
- type: :development
118
- prerelease: false
119
- version_requirements: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: '3.40'
124
- - !ruby/object:Gem::Dependency
125
- name: database_cleaner
126
- requirement: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: '2.1'
131
- type: :development
132
- prerelease: false
133
- version_requirements: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - "~>"
136
- - !ruby/object:Gem::Version
137
- version: '2.1'
138
- - !ruby/object:Gem::Dependency
139
- name: factory_bot_rails
140
- requirement: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - "~>"
143
- - !ruby/object:Gem::Version
144
- version: '6.4'
145
- type: :development
146
- prerelease: false
147
- version_requirements: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - "~>"
150
- - !ruby/object:Gem::Version
151
- version: '6.4'
152
- - !ruby/object:Gem::Dependency
153
- name: generator_spec
154
- requirement: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - "~>"
157
- - !ruby/object:Gem::Version
158
- version: '0.10'
159
- type: :development
160
- prerelease: false
161
- version_requirements: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - "~>"
164
- - !ruby/object:Gem::Version
165
- version: '0.10'
166
- - !ruby/object:Gem::Dependency
167
- name: rspec-rails
168
- requirement: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - "~>"
171
- - !ruby/object:Gem::Version
172
- version: '7.1'
173
- type: :development
174
- prerelease: false
175
- version_requirements: !ruby/object:Gem::Requirement
176
- requirements:
177
- - - "~>"
178
- - !ruby/object:Gem::Version
179
- version: '7.1'
180
- - !ruby/object:Gem::Dependency
181
- name: shoulda-matchers
182
- requirement: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - "~>"
185
- - !ruby/object:Gem::Version
186
- version: '6.5'
187
- type: :development
188
- prerelease: false
189
- version_requirements: !ruby/object:Gem::Requirement
190
- requirements:
191
- - - "~>"
192
- - !ruby/object:Gem::Version
193
- version: '6.5'
194
68
  description: Securial is a mountable Rails engine that provides robust, extensible
195
69
  authentication and access control for Rails applications. It supports JWT, API tokens,
196
70
  session-based auth, and is designed for easy integration with modern web and mobile
@@ -231,8 +105,14 @@ files:
231
105
  - app/views/securial/roles/_securial_role.json.jbuilder
232
106
  - app/views/securial/roles/index.json.jbuilder
233
107
  - app/views/securial/roles/show.json.jbuilder
234
- - app/views/securial/securial_mailer/reset_password.html.erb
235
- - app/views/securial/securial_mailer/reset_password.text.erb
108
+ - app/views/securial/securial_mailer/forgot_password.html.erb
109
+ - app/views/securial/securial_mailer/forgot_password.text.erb
110
+ - app/views/securial/securial_mailer/sign_in.html.erb
111
+ - app/views/securial/securial_mailer/sign_in.text.erb
112
+ - app/views/securial/securial_mailer/update_account.html.erb
113
+ - app/views/securial/securial_mailer/update_account.text.erb
114
+ - app/views/securial/securial_mailer/welcome.html.erb
115
+ - app/views/securial/securial_mailer/welcome.text.erb
236
116
  - app/views/securial/sessions/_session.json.jbuilder
237
117
  - app/views/securial/sessions/index.json.jbuilder
238
118
  - app/views/securial/sessions/show.json.jbuilder
@@ -243,15 +123,15 @@ files:
243
123
  - app/views/securial/users/show.json.jbuilder
244
124
  - bin/securial
245
125
  - config/routes.rb
246
- - db/migrate/20250515104930_create_securial_roles.rb
247
- - db/migrate/20250517155521_create_securial_users.rb
248
- - db/migrate/20250518122749_create_securial_role_assignments.rb
249
- - db/migrate/20250519075407_create_securial_sessions.rb
126
+ - db/migrate/20250603130214_create_securial_roles.rb
127
+ - db/migrate/20250604110520_create_securial_users.rb
128
+ - db/migrate/20250604123805_create_securial_role_assignments.rb
129
+ - db/migrate/20250604184841_create_securial_sessions.rb
250
130
  - lib/generators/factory_bot/model/model_generator.rb
251
131
  - lib/generators/factory_bot/templates/factory.erb
252
132
  - lib/generators/securial/install/install_generator.rb
253
133
  - lib/generators/securial/install/templates/securial_initializer.erb
254
- - lib/generators/securial/install/views_generastor.rb
134
+ - lib/generators/securial/install/views_generator.rb
255
135
  - lib/generators/securial/jbuilder/jbuilder_generator.rb
256
136
  - lib/generators/securial/jbuilder/templates/_resource.json.erb
257
137
  - lib/generators/securial/jbuilder/templates/index.json.erb
@@ -262,42 +142,57 @@ files:
262
142
  - lib/generators/securial/scaffold/templates/routes.erb
263
143
  - lib/generators/securial/scaffold/templates/routing_spec.erb
264
144
  - lib/securial.rb
265
- - lib/securial/auth/_index.rb
145
+ - lib/securial/auth.rb
266
146
  - lib/securial/auth/auth_encoder.rb
267
- - lib/securial/auth/errors.rb
268
147
  - lib/securial/auth/session_creator.rb
269
- - lib/securial/config/_index.rb
148
+ - lib/securial/auth/token_generator.rb
149
+ - lib/securial/config.rb
270
150
  - lib/securial/config/configuration.rb
271
- - lib/securial/config/errors.rb
272
151
  - lib/securial/config/validation.rb
152
+ - lib/securial/config/validation/logger_validation.rb
153
+ - lib/securial/config/validation/mailer_validation.rb
154
+ - lib/securial/config/validation/password_validation.rb
155
+ - lib/securial/config/validation/response_validation.rb
156
+ - lib/securial/config/validation/roles_validation.rb
157
+ - lib/securial/config/validation/security_validation.rb
158
+ - lib/securial/config/validation/session_validation.rb
273
159
  - lib/securial/engine.rb
160
+ - lib/securial/engine_initializers.rb
161
+ - lib/securial/error.rb
162
+ - lib/securial/error/auth.rb
163
+ - lib/securial/error/base_securial_error.rb
164
+ - lib/securial/error/config.rb
274
165
  - lib/securial/factories/securial/role_assignments.rb
275
166
  - lib/securial/factories/securial/roles.rb
276
167
  - lib/securial/factories/securial/sessions.rb
277
168
  - lib/securial/factories/securial/users.rb
278
- - lib/securial/helpers/_index.rb
169
+ - lib/securial/helpers.rb
279
170
  - lib/securial/helpers/normalizing_helper.rb
280
171
  - lib/securial/helpers/regex_helper.rb
281
- - lib/securial/inspectors/_index.rb
282
- - lib/securial/inspectors/route_inspector.rb
283
- - lib/securial/key_transformer.rb
172
+ - lib/securial/helpers/roles_helper.rb
284
173
  - lib/securial/logger.rb
285
- - lib/securial/middleware/_index.rb
286
- - lib/securial/middleware/request_logger_tag.rb
287
- - lib/securial/middleware/transform_request_keys.rb
288
- - lib/securial/middleware/transform_response_keys.rb
289
- - lib/securial/rack_attack.rb
174
+ - lib/securial/logger/broadcaster.rb
175
+ - lib/securial/logger/builder.rb
176
+ - lib/securial/logger/formatter.rb
177
+ - lib/securial/middleware.rb
178
+ - lib/securial/middleware/request_tag_logger.rb
290
179
  - lib/securial/version.rb
291
180
  - lib/tasks/securial_tasks.rake
292
181
  homepage: https://github.com/AlyBadawy/Securial/wiki
293
182
  licenses:
294
183
  - MIT
295
184
  metadata:
296
- release_date: '2025-05-30'
185
+ release_date: '2025-06-06'
297
186
  allowed_push_host: https://rubygems.org
298
187
  homepage_uri: https://github.com/AlyBadawy/Securial/wiki
299
188
  source_code_uri: https://github.com/AlyBadawy/Securial
300
189
  changelog_uri: https://github.com/AlyBadawy/Securial/blob/main/CHANGELOG.md
190
+ post_install_message: "\n ---\n [SECURIAL] Thank you for installing Securial!\n\n
191
+ \ Securial is a mountable Rails engine that provides robust,\n extensible authentication
192
+ and access control for Rails applications.\n Please review the [changelog]
193
+ and [WIKI] for more info on the latest\n changes and how to use this gem/engine:\n
194
+ \ [changelog]: https://github.com/AlyBadawy/Securial/blob/main/CHANGELOG.md\n
195
+ \ [WIKI]: https://github.com/AlyBadawy/Securial/wiki\n ---\n "
301
196
  rdoc_options: []
302
197
  require_paths:
303
198
  - lib
@@ -305,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
305
200
  requirements:
306
201
  - - ">="
307
202
  - !ruby/object:Gem::Version
308
- version: 3.4.1
203
+ version: 3.4.0
309
204
  required_rubygems_version: !ruby/object:Gem::Requirement
310
205
  requirements:
311
206
  - - ">="
@@ -1,5 +0,0 @@
1
- <p>
2
- You can reset your password within the next <%= Securial.configuration.reset_password_token_expires_in.inspect %>.
3
- </p>
4
-
5
- <p>Your password reset token is: <%= @user.reset_password_token %></p>
@@ -1,4 +0,0 @@
1
- You can reset your password within the next <%= Securial.configuration.reset_password_token_expires_in.inspect %>.
2
-
3
-
4
- Your password reset token is: <%= @user.reset_password_token %>
@@ -1,3 +0,0 @@
1
- require_relative "errors"
2
- require_relative "auth_encoder"
3
- require_relative "session_creator"
@@ -1,15 +0,0 @@
1
- module Securial
2
- module Auth
3
- module Errors
4
- class BaseAuthError < StandardError
5
- def backtrace; []; end
6
- end
7
-
8
- class AuthEncodeError < BaseAuthError; end
9
- class AuthDecodeError < BaseAuthError; end
10
-
11
- class AuthRevokedError < BaseAuthError; end
12
- class AuthExpiredError < BaseAuthError; end
13
- end
14
- end
15
- end
@@ -1,3 +0,0 @@
1
- require_relative "./configuration"
2
- require_relative "./validation"
3
- require_relative "./errors"
@@ -1,20 +0,0 @@
1
- module Securial
2
- module Config
3
- module Errors
4
- class BaseConfigError < StandardError
5
- def backtrace; []; end
6
- end
7
-
8
- class ConfigAdminRoleError < BaseConfigError; end
9
-
10
- class ConfigSessionExpirationDurationError < BaseConfigError; end
11
- class ConfigSessionAlgorithmError < BaseConfigError; end
12
- class ConfigSessionSecretError < BaseConfigError; end
13
-
14
- class ConfigMailerSenderError < BaseConfigError; end
15
- class ConfigPasswordError < BaseConfigError; end
16
- class ConfigResponseError < BaseConfigError; end
17
- class ConfigSecurityError < BaseConfigError; end
18
- end
19
- end
20
- end
@@ -1,2 +0,0 @@
1
- require_relative "normalizing_helper"
2
- require_relative "regex_helper"
@@ -1 +0,0 @@
1
- require_relative "route_inspector"
@@ -1,52 +0,0 @@
1
- module Securial
2
- module Inspectors
3
- module RouteInspector
4
- def self.print_routes(controller: nil)
5
- filtered = Securial::Engine.routes.routes.select do |r|
6
- ctrl = r.defaults[:controller]
7
- controller.nil? || ctrl == "securial/#{controller}"
8
- end
9
-
10
- print_headers(filtered, controller)
11
- print_details(filtered, controller)
12
- true
13
- end
14
-
15
- class << self
16
- private
17
-
18
- # rubocop:disable Rails/Output
19
- def print_headers(filtered, controller)
20
- Securial::ENGINE_LOGGER.debug "Securial engine routes:"
21
- Securial::ENGINE_LOGGER.debug "Total routes: #{filtered.size}"
22
- Securial::ENGINE_LOGGER.debug "Filtered by controller: #{controller}" if controller
23
- Securial::ENGINE_LOGGER.debug "Filtered routes: #{filtered.size}" if controller
24
- Securial::ENGINE_LOGGER.debug "-" * 120
25
- Securial::ENGINE_LOGGER.debug "#{'Verb'.ljust(8)} #{'Path'.ljust(45)} #{'Controller#Action'.ljust(40)} Name"
26
- Securial::ENGINE_LOGGER.debug "-" * 120
27
- end
28
-
29
- def print_details(filtered, controller) # rubocop:disable Rails/Output
30
- if filtered.empty?
31
- if controller
32
- Securial::ENGINE_LOGGER.debug "No routes found for controller: #{controller}"
33
- else
34
- Securial::ENGINE_LOGGER.debug "No routes found for Securial engine"
35
- end
36
- Securial::ENGINE_LOGGER.debug "-" * 120
37
- return
38
- end
39
-
40
- Securial::ENGINE_LOGGER.debug filtered.map { |r|
41
- name = r.name || ""
42
- verb = r.verb.to_s.ljust(8)
43
- path = r.path.spec.to_s.sub(/\(\.:format\)/, "").ljust(45)
44
- ctrl_action = "#{r.defaults[:controller]}##{r.defaults[:action]}"
45
- "#{verb} #{path} #{ctrl_action.ljust(40)} #{name}"
46
- }.join("\n")
47
- end
48
- # rubocop:enable Rails/Output
49
- end
50
- end
51
- end
52
- end
@@ -1,32 +0,0 @@
1
- # lib/securial/key_transformer.rb
2
- module Securial
3
- module KeyTransformer
4
- def self.camelize(str, format)
5
- return str unless str.is_a?(String)
6
-
7
- case format
8
- when :lowerCamelCase
9
- str.camelize(:lower)
10
- when :UpperCamelCase
11
- str.camelize
12
- else
13
- str
14
- end
15
- end
16
-
17
- def self.underscore(str)
18
- str.to_s.underscore
19
- end
20
-
21
- def self.deep_transform_keys(obj, &block)
22
- case obj
23
- when Hash
24
- obj.transform_keys(&block).transform_values { |v| deep_transform_keys(v, &block) }
25
- when Array
26
- obj.map { |e| deep_transform_keys(e, &block) }
27
- else
28
- obj
29
- end
30
- end
31
- end
32
- end
@@ -1,3 +0,0 @@
1
- require_relative "./transform_request_keys"
2
- require_relative "./transform_response_keys"
3
- require_relative "./request_logger_tag"