securial 1.1.0 → 2.1.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/app/controllers/securial/accounts_controller.rb +10 -2
- data/config/routes.rb +4 -1
- data/lib/generators/securial/install/install_generator.rb +1 -1
- data/lib/generators/securial/install/templates/securial_initializer.erb +10 -1
- data/lib/securial/config/signature.rb +1 -0
- data/lib/securial/engine.rb +1 -1
- data/lib/securial/engine_initializers.rb +0 -7
- data/lib/securial/error/base_securial_error.rb +1 -1
- data/lib/securial/middleware/transform_response_keys.rb +1 -4
- data/lib/securial/version.rb +1 -1
- metadata +3 -9
- data/lib/generators/factory_bot/model/model_generator.rb +0 -32
- data/lib/generators/factory_bot/templates/factory.erb +0 -7
- data/lib/securial/factories/securial/role_assignments.rb +0 -6
- data/lib/securial/factories/securial/roles.rb +0 -18
- data/lib/securial/factories/securial/sessions.rb +0 -12
- data/lib/securial/factories/securial/users.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5935f6936b886c221154aa2509102a9abeb05e3ff69102fa915ce522cbb77c55
|
4
|
+
data.tar.gz: fb51df105ce9224dc4dbe115424920deed702cf7a5c0ec5c6939fdbadc669661
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53a75f18d1036097543661e55be3c4bb76a1949ee9ad36c7c3dddfac3a4bedd645d4d31d590a7c723536376f21b9c8cf8df14f5dd784e9de890fea60a9c3d072
|
7
|
+
data.tar.gz: f0d404b3564696c6052f4b9a92b39bb9833d507f83ec67fdf97703b3e7c9489afb8e7f78576518c7651624ee4d1199a70d2a425d3dbe590927bafbf3a72ae0db
|
@@ -26,12 +26,20 @@ module Securial
|
|
26
26
|
# Shows a specific user's profile by username.
|
27
27
|
#
|
28
28
|
# Retrieves and displays public profile information for the requested user.
|
29
|
+
# Requires the `enable_other_profiles` configuration to be true.
|
29
30
|
#
|
30
31
|
# @param [String] params[:username] The username of the requested user profile
|
31
32
|
# @return [void] Renders user profile with 200 OK status or 404 if not found
|
32
33
|
def show
|
33
|
-
|
34
|
-
|
34
|
+
if Securial.configuration.enable_other_profiles
|
35
|
+
@securial_user = Securial::User.find_by(username: params.expect(:username))
|
36
|
+
render_user_profile
|
37
|
+
else
|
38
|
+
render json: {
|
39
|
+
errors: ["User profiles are not enabled"],
|
40
|
+
instructions: "Please contact support for assistance.",
|
41
|
+
}, status: :forbidden
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
45
|
# Registers a new user account.
|
data/config/routes.rb
CHANGED
@@ -17,7 +17,6 @@ Securial::Engine.routes.draw do
|
|
17
17
|
|
18
18
|
scope "accounts" do
|
19
19
|
get "me", to: "accounts#me", as: :me
|
20
|
-
get "account/:username", to: "accounts#show", as: :account_by_username
|
21
20
|
post "register", to: "accounts#register", as: :register
|
22
21
|
put "update", to: "accounts#update_profile", as: :update_profile
|
23
22
|
# post "update_avatar", to: "accounts#update_avatar"
|
@@ -40,5 +39,9 @@ Securial::Engine.routes.draw do
|
|
40
39
|
post "forgot", to: "passwords#forgot_password", as: :forgot_password
|
41
40
|
put "reset", to: "passwords#reset_password", as: :reset_password
|
42
41
|
end
|
42
|
+
|
43
|
+
scope "profiles" do
|
44
|
+
get ":username", to: "accounts#show", as: :profile_by_username
|
45
|
+
end
|
43
46
|
end
|
44
47
|
end
|
@@ -19,7 +19,7 @@ module Securial
|
|
19
19
|
securial_log = log_dir.join("securial-#{Rails.env}.log")
|
20
20
|
|
21
21
|
FileUtils.mkdir_p(log_dir) unless File.directory?(log_dir)
|
22
|
-
FileUtils.touch(securial_log)
|
22
|
+
FileUtils.touch(securial_log)
|
23
23
|
end
|
24
24
|
|
25
25
|
def install_migrations
|
@@ -244,4 +244,13 @@ Securial.configure do |config|
|
|
244
244
|
# the rate limit. The default is "Too many requests, please try again later."
|
245
245
|
# This is only applied if `rate_limiting_enabled` is set to true.
|
246
246
|
config.rate_limit_response_message = "Too many requests, please try again later."
|
247
|
-
|
247
|
+
|
248
|
+
## Set whether to enable other user profiles
|
249
|
+
# This allows users to view other users' profiles by their username.
|
250
|
+
# If this is set to true, users can access profiles of other users
|
251
|
+
# by visiting the URL `/profiles/:username`, where `:username` is the username
|
252
|
+
# of the user whose profile they want to view.
|
253
|
+
# If this is set to false, users can only view their own profile
|
254
|
+
# by visiting the URL `/accounts/me`.
|
255
|
+
config.enable_other_profiles = false
|
256
|
+
end
|
@@ -211,6 +211,7 @@ module Securial
|
|
211
211
|
rate_limit_requests_per_minute: { type: Numeric, required: "rate_limiting_enabled", default: 60 },
|
212
212
|
rate_limit_response_status: { type: Numeric, required: "rate_limiting_enabled", default: 429 },
|
213
213
|
rate_limit_response_message: { type: String, required: "rate_limiting_enabled", default: "Too many requests, please try again later." },
|
214
|
+
enable_other_profiles: { type: [TrueClass, FalseClass], required: true, default: false },
|
214
215
|
}
|
215
216
|
end
|
216
217
|
end
|
data/lib/securial/engine.rb
CHANGED
@@ -9,13 +9,6 @@ module Securial
|
|
9
9
|
]
|
10
10
|
end
|
11
11
|
|
12
|
-
initializer "securial.factory_bot", after: "factory_bot.set_factory_paths" do
|
13
|
-
if defined?(FactoryBot)
|
14
|
-
FactoryBot.definition_file_paths << Engine.root.join("lib", "securial", "factories")
|
15
|
-
require_relative "../generators/factory_bot/model/model_generator"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
12
|
initializer "securial.security.request_rate_limiter" do |app|
|
20
13
|
if Securial.configuration.rate_limiting_enabled
|
21
14
|
Securial::Security::RequestRateLimiter.apply!
|
@@ -44,10 +44,7 @@ module Securial
|
|
44
44
|
#
|
45
45
|
# @example
|
46
46
|
# middleware = TransformResponseKeys.new(app)
|
47
|
-
|
48
|
-
# @deprecated Use `Securial.configuration.response_keys_format` instead of format parameter
|
49
|
-
#
|
50
|
-
def initialize(app, format: :lowerCamelCase)
|
47
|
+
def initialize(app)
|
51
48
|
@app = app
|
52
49
|
end
|
53
50
|
|
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: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aly Badawy
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-07-
|
10
|
+
date: 2025-07-09 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|
@@ -149,8 +149,6 @@ files:
|
|
149
149
|
- db/migrate/20250604123805_create_securial_role_assignments.rb
|
150
150
|
- db/migrate/20250604184841_create_securial_sessions.rb
|
151
151
|
- db/migrate/20250606182648_seed_roles_and_users.rb
|
152
|
-
- lib/generators/factory_bot/model/model_generator.rb
|
153
|
-
- lib/generators/factory_bot/templates/factory.erb
|
154
152
|
- lib/generators/securial/install/install_generator.rb
|
155
153
|
- lib/generators/securial/install/templates/securial_initializer.erb
|
156
154
|
- lib/generators/securial/install/views_generator.rb
|
@@ -179,10 +177,6 @@ files:
|
|
179
177
|
- lib/securial/error/auth.rb
|
180
178
|
- lib/securial/error/base_securial_error.rb
|
181
179
|
- lib/securial/error/config.rb
|
182
|
-
- lib/securial/factories/securial/role_assignments.rb
|
183
|
-
- lib/securial/factories/securial/roles.rb
|
184
|
-
- lib/securial/factories/securial/sessions.rb
|
185
|
-
- lib/securial/factories/securial/users.rb
|
186
180
|
- lib/securial/helpers.rb
|
187
181
|
- lib/securial/helpers/key_transformer.rb
|
188
182
|
- lib/securial/helpers/normalizing_helper.rb
|
@@ -207,7 +201,7 @@ licenses:
|
|
207
201
|
- MIT
|
208
202
|
metadata:
|
209
203
|
homepage_uri: https://github.com/AlyBadawy/Securial/wiki
|
210
|
-
release_date: '2025-07-
|
204
|
+
release_date: '2025-07-09'
|
211
205
|
allowed_push_host: https://rubygems.org
|
212
206
|
source_code_uri: https://github.com/AlyBadawy/Securial
|
213
207
|
documentation_uri: https://alybadawy.github.io/Securial/_index.html
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require "rails/generators"
|
2
|
-
require "rails/generators/named_base"
|
3
|
-
|
4
|
-
# @!ignore
|
5
|
-
module FactoryBot
|
6
|
-
module Generators
|
7
|
-
class ModelGenerator < Rails::Generators::NamedBase
|
8
|
-
source_root File.expand_path("../templates", __dir__)
|
9
|
-
|
10
|
-
argument :attributes, type: :array, default: [], banner: "field[:type] field[:type]"
|
11
|
-
|
12
|
-
def create_factory_file
|
13
|
-
template "factory.erb", File.join("lib/securial/factories/securial", "#{file_name.pluralize}.rb")
|
14
|
-
end
|
15
|
-
|
16
|
-
# Helper method accessible in the template
|
17
|
-
def securial_attribute_defaults
|
18
|
-
{
|
19
|
-
string: '"MyString"',
|
20
|
-
text: '"MyText"',
|
21
|
-
integer: "1",
|
22
|
-
float: "1.5",
|
23
|
-
decimal: '"9.99"',
|
24
|
-
datetime: "Time.zone.now",
|
25
|
-
time: "Time.zone.now",
|
26
|
-
date: "Time.zone.now",
|
27
|
-
boolean: "false",
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :securial_role, class: "Securial::Role" do
|
3
|
-
role_name { "MyString" }
|
4
|
-
hide_from_profile { false }
|
5
|
-
|
6
|
-
trait :admin do
|
7
|
-
role_name { "Admin" }
|
8
|
-
end
|
9
|
-
|
10
|
-
trait :user do
|
11
|
-
role_name { "User" }
|
12
|
-
end
|
13
|
-
|
14
|
-
trait :hidden do
|
15
|
-
hide_from_profile { true }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :securial_session, class: "Securial::Session" do
|
3
|
-
ip_address { "127.0.0.1" }
|
4
|
-
user_agent { "Ruby/RSpec" }
|
5
|
-
refresh_count { 1 }
|
6
|
-
refresh_token { SecureRandom.hex(64) }
|
7
|
-
last_refreshed_at { Time.current }
|
8
|
-
refresh_token_expires_at { 1.week.from_now }
|
9
|
-
revoked { false }
|
10
|
-
association :user, factory: :securial_user
|
11
|
-
end
|
12
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
FactoryBot.define do
|
2
|
-
factory :securial_user, class: "Securial::User" do
|
3
|
-
email_address { Faker::Internet.email }
|
4
|
-
password { "Password_.1" }
|
5
|
-
password_confirmation { "Password_.1" }
|
6
|
-
first_name { Faker::Name.first_name }
|
7
|
-
last_name { Faker::Name.last_name }
|
8
|
-
phone { Faker::PhoneNumber.cell_phone }
|
9
|
-
username { Faker::Internet.username(specifier: 3..20) }
|
10
|
-
bio { Faker::Lorem.paragraph }
|
11
|
-
|
12
|
-
trait :admin do
|
13
|
-
admin_role = Securial.configuration.admin_role.to_s.strip.titleize
|
14
|
-
roles { [Securial::Role.find_or_create_by(role_name: admin_role)] }
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|