securial 1.0.0 → 1.0.2

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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +4 -0
  3. data/README.md +14 -9
  4. data/app/controllers/concerns/securial/identity.rb +91 -2
  5. data/app/controllers/securial/accounts_controller.rb +68 -5
  6. data/app/controllers/securial/application_controller.rb +34 -2
  7. data/app/controllers/securial/passwords_controller.rb +44 -4
  8. data/app/controllers/securial/role_assignments_controller.rb +55 -4
  9. data/app/controllers/securial/roles_controller.rb +54 -0
  10. data/app/controllers/securial/sessions_controller.rb +77 -3
  11. data/app/controllers/securial/status_controller.rb +24 -0
  12. data/app/controllers/securial/users_controller.rb +54 -0
  13. data/app/jobs/securial/application_job.rb +9 -0
  14. data/app/mailers/securial/application_mailer.rb +12 -0
  15. data/app/mailers/securial/securial_mailer.rb +30 -0
  16. data/app/models/concerns/securial/password_resettable.rb +70 -0
  17. data/app/models/securial/application_record.rb +19 -0
  18. data/app/models/securial/current.rb +13 -0
  19. data/app/models/securial/role.rb +17 -0
  20. data/app/models/securial/role_assignment.rb +16 -0
  21. data/app/models/securial/session.rb +79 -1
  22. data/app/models/securial/user.rb +34 -0
  23. data/bin/securial +6 -23
  24. data/lib/generators/factory_bot/model/model_generator.rb +1 -0
  25. data/lib/generators/securial/install/install_generator.rb +2 -2
  26. data/lib/generators/securial/install/views_generator.rb +2 -1
  27. data/lib/generators/securial/jbuilder/jbuilder_generator.rb +2 -0
  28. data/lib/generators/securial/scaffold/scaffold_generator.rb +2 -0
  29. data/lib/securial/auth/auth_encoder.rb +3 -3
  30. data/lib/securial/auth/session_creator.rb +1 -1
  31. data/lib/securial/auth/token_generator.rb +13 -13
  32. data/lib/securial/auth.rb +44 -6
  33. data/lib/securial/cli.rb +282 -0
  34. data/lib/securial/config/signature.rb +1 -1
  35. data/lib/securial/config/validation.rb +44 -45
  36. data/lib/securial/config.rb +63 -17
  37. data/lib/securial/engine.rb +41 -0
  38. data/lib/securial/error/auth.rb +52 -0
  39. data/lib/securial/error/base_securial_error.rb +56 -3
  40. data/lib/securial/error/config.rb +33 -0
  41. data/lib/securial/error.rb +33 -3
  42. data/lib/securial/helpers/key_transformer.rb +1 -1
  43. data/lib/securial/helpers/normalizing_helper.rb +1 -1
  44. data/lib/securial/helpers/regex_helper.rb +6 -7
  45. data/lib/securial/helpers/roles_helper.rb +6 -7
  46. data/lib/securial/helpers.rb +48 -4
  47. data/lib/securial/logger/broadcaster.rb +89 -1
  48. data/lib/securial/logger/builder.rb +54 -1
  49. data/lib/securial/logger/formatter.rb +73 -0
  50. data/lib/securial/logger.rb +48 -8
  51. data/lib/securial/middleware.rb +40 -9
  52. data/lib/securial/security/request_rate_limiter.rb +48 -2
  53. data/lib/securial/security.rb +37 -6
  54. data/lib/securial/version.rb +8 -1
  55. data/lib/securial.rb +40 -4
  56. metadata +15 -11
  57. data/lib/securial/cli/run.rb +0 -11
  58. data/lib/securial/cli/securial_new.rb +0 -53
  59. data/lib/securial/cli/show_help.rb +0 -26
  60. data/lib/securial/cli/show_version.rb +0 -9
@@ -1,3 +1,19 @@
1
+ # @title Securial Logger Builder
2
+ #
3
+ # Logger construction utilities for the Securial framework.
4
+ #
5
+ # This file defines a builder class that constructs and configures loggers for the Securial
6
+ # framework based on application configuration. It supports multiple logging destinations
7
+ # (stdout and file) with appropriate formatters for each, and combines them using a
8
+ # broadcaster pattern for unified logging.
9
+ #
10
+ # @example Building a logger with defaults from configuration
11
+ # # Securial.configuration has been set up elsewhere
12
+ # logger = Securial::Logger::Builder.build
13
+ #
14
+ # # Log messages go to both configured destinations
15
+ # logger.info("User authentication successful")
16
+ #
1
17
  require "logger"
2
18
  require "active_support/logger"
3
19
  require "active_support/tagged_logging"
@@ -7,7 +23,22 @@ require "securial/logger/formatter"
7
23
 
8
24
  module Securial
9
25
  module Logger
26
+ # Builder for constructing Securial's logging system.
27
+ #
28
+ # This class provides factory methods to create properly configured logger instances
29
+ # based on the application's configuration settings. It supports multiple logging
30
+ # destinations and handles the setup of formatters, log levels, and tagging.
31
+ #
10
32
  class Builder
33
+ # Builds a complete logger system based on configuration settings.
34
+ #
35
+ # Creates file and/or stdout loggers as specified in configuration and
36
+ # combines them using a Broadcaster to provide unified logging to multiple
37
+ # destinations with appropriate formatting for each.
38
+ #
39
+ # @return [Securial::Logger::Broadcaster] A broadcaster containing all configured loggers
40
+ # @see Securial::Logger::Broadcaster
41
+ #
11
42
  def self.build
12
43
  loggers = []
13
44
  progname = "Securial"
@@ -23,6 +54,17 @@ module Securial
23
54
  Broadcaster.new(loggers)
24
55
  end
25
56
 
57
+ # Creates and configures a file logger.
58
+ #
59
+ # Sets up a logger that writes to a Rails environment-specific log file
60
+ # with plain text formatting and adds it to the provided loggers array.
61
+ #
62
+ # @param progname [String] The program name to include in log entries
63
+ # @param level [Integer, Symbol] The log level (e.g., :info, :debug)
64
+ # @param loggers [Array<Logger>] Array to which the new logger will be added
65
+ # @return [ActiveSupport::TaggedLogging] The configured file logger
66
+ # @see Securial::Logger::Formatter::PlainFormatter
67
+ #
26
68
  def self.create_file_logger(progname, level, loggers)
27
69
  file_logger = ::Logger.new(Rails.root.join("log", "securial-#{Rails.env}.log"))
28
70
  file_logger.level = level
@@ -32,12 +74,23 @@ module Securial
32
74
  loggers << tagged_file_logger
33
75
  end
34
76
 
77
+ # Creates and configures a stdout logger.
78
+ #
79
+ # Sets up a logger that writes to standard output with colorful formatting
80
+ # and adds it to the provided loggers array.
81
+ #
82
+ # @param progname [String] The program name to include in log entries
83
+ # @param level [Integer, Symbol] The log level (e.g., :info, :debug)
84
+ # @param loggers [Array<Logger>] Array to which the new logger will be added
85
+ # @return [ActiveSupport::TaggedLogging] The configured stdout logger
86
+ # @see Securial::Logger::Formatter::ColorfulFormatter
87
+ #
35
88
  def self.create_stdout_logger(progname, level, loggers)
36
89
  stdout_logger = ::Logger.new($stdout)
37
90
  stdout_logger.level = level
38
91
  stdout_logger.progname = progname
39
92
  stdout_logger.formatter = Formatter::ColorfulFormatter.new
40
- tagged_stdout_logger = ActiveSupport::TaggedLogging.new(stdout_logger)
93
+ tagged_stdout_logger = ActiveSupport::TaggedLogging.new(stdout_logger)
41
94
  loggers << tagged_stdout_logger
42
95
  end
43
96
  end
@@ -1,6 +1,33 @@
1
+ # @title Securial Logger Formatters
2
+ #
3
+ # Log formatting utilities for the Securial framework's logging system.
4
+ #
5
+ # This file defines formatter classes that determine how log messages are displayed,
6
+ # providing both colorful terminal-friendly output and plain text output options.
7
+ # These formatters are used by the Securial::Logger system to ensure consistent
8
+ # and readable log formats across different environments.
9
+ #
10
+ # @example Using a formatter with a standard Ruby logger
11
+ # require 'logger'
12
+ # logger = Logger.new(STDOUT)
13
+ # logger.formatter = Securial::Logger::Formatter::ColorfulFormatter.new
14
+ #
15
+ # logger.info("Application started")
16
+ # # Output: [2023-11-15 14:30:22] INFO -- Application started (in green color)
17
+ #
1
18
  module Securial
2
19
  module Logger
20
+ # Formatting utilities for Securial's logging system.
21
+ #
22
+ # This module contains formatter classes and constants that determine
23
+ # how log messages are presented. It provides both colored output for
24
+ # terminal environments and plain text output for file logging.
25
+ #
3
26
  module Formatter
27
+ # Terminal color codes for different log severity levels.
28
+ #
29
+ # @return [Hash{String => String}] Mapping of severity names to ANSI color codes
30
+ #
4
31
  COLORS = {
5
32
  "DEBUG" => "\e[36m", # cyan
6
33
  "INFO" => "\e[32m", # green
@@ -9,10 +36,38 @@ module Securial
9
36
  "FATAL" => "\e[35m", # magenta
10
37
  "UNKNOWN" => "\e[37m", # white
11
38
  }.freeze
39
+
40
+ # ANSI code to reset terminal colors.
41
+ #
42
+ # @return [String] Terminal color reset sequence
43
+ #
12
44
  CLEAR = "\e[0m"
45
+
46
+ # Width used for severity level padding in log output.
47
+ #
48
+ # @return [Integer] Number of characters to use for severity field
49
+ #
13
50
  SEVERITY_WIDTH = 5
14
51
 
52
+ # Formatter that adds color to log output for terminal display.
53
+ #
54
+ # This formatter colorizes log messages based on their severity level,
55
+ # making them easier to distinguish in terminal output. It follows the
56
+ # standard Ruby Logger formatter interface.
57
+ #
58
+ # @example
59
+ # logger = Logger.new(STDOUT)
60
+ # logger.formatter = Securial::Logger::Formatter::ColorfulFormatter.new
61
+ #
15
62
  class ColorfulFormatter
63
+ # Formats a log message with color based on severity.
64
+ #
65
+ # @param severity [String] Log severity level (DEBUG, INFO, etc.)
66
+ # @param timestamp [Time] Time when the log event occurred
67
+ # @param progname [String] Program name or context for the log message
68
+ # @param msg [String] The log message itself
69
+ # @return [String] Formatted log message with appropriate ANSI color codes
70
+ #
16
71
  def call(severity, timestamp, progname, msg)
17
72
  color = COLORS[severity] || CLEAR
18
73
  padded_severity = severity.ljust(SEVERITY_WIDTH)
@@ -22,7 +77,25 @@ module Securial
22
77
  end
23
78
  end
24
79
 
80
+ # Formatter that produces plain text log output without colors.
81
+ #
82
+ # This formatter is suitable for file logging or environments where
83
+ # terminal colors are not supported. It follows the standard Ruby
84
+ # Logger formatter interface.
85
+ #
86
+ # @example
87
+ # logger = Logger.new('application.log')
88
+ # logger.formatter = Securial::Logger::Formatter::PlainFormatter.new
89
+ #
25
90
  class PlainFormatter
91
+ # Formats a log message in plain text without color codes.
92
+ #
93
+ # @param severity [String] Log severity level (DEBUG, INFO, etc.)
94
+ # @param timestamp [Time] Time when the log event occurred
95
+ # @param progname [String] Program name or context for the log message
96
+ # @param msg [String] The log message itself
97
+ # @return [String] Formatted log message as plain text
98
+ #
26
99
  def call(severity, timestamp, progname, msg)
27
100
  padded_severity = severity.ljust(SEVERITY_WIDTH)
28
101
  formatted = "[#{timestamp.strftime("%Y-%m-%d %H:%M:%S")}] #{padded_severity} -- #{msg}\n"
@@ -1,15 +1,55 @@
1
+ # @title Securial Logger Configuration
2
+ #
3
+ # Defines the logging interface for the Securial framework.
4
+ #
5
+ # This file establishes the logging system for Securial, providing methods
6
+ # to access and configure the application's logger instance. By default,
7
+ # it initializes a logger using the Securial::Logger::Builder class, which
8
+ # configures appropriate log levels and formatters based on the current environment.
9
+ #
10
+ # @example Basic logging usage
11
+ # # Log messages at different levels
12
+ # Securial.logger.debug("Detailed debugging information")
13
+ # Securial.logger.info("General information about system operation")
14
+ # Securial.logger.warn("Warning about potential issue")
15
+ # Securial.logger.error("Error condition")
16
+ #
17
+ # @example Setting a custom logger
18
+ # # Configure a custom logger
19
+ # custom_logger = Logger.new(STDOUT)
20
+ # custom_logger.level = :info
21
+ # Securial.logger = custom_logger
22
+ #
1
23
  require_relative "logger/builder"
2
24
 
3
25
  module Securial
4
- class << self
5
- attr_accessor :logger
26
+ extend self
27
+ attr_accessor :logger
6
28
 
7
- def logger
8
- @logger ||= Logger::Builder.build
9
- end
29
+ # Returns the logger instance used by Securial.
30
+ #
31
+ # If no logger has been set, initializes a new logger instance using
32
+ # the Securial::Logger::Builder class, which configures the logger
33
+ # based on the current environment settings.
34
+ #
35
+ # @return [Securial::Logger::Builder] the configured logger instance
36
+ # @see Securial::Logger::Builder
37
+ def logger
38
+ @logger ||= Securial::Logger::Builder.build
39
+ end
10
40
 
11
- def logger=(logger)
12
- @logger = logger
13
- end
41
+ # Sets the logger instance for Securial.
42
+ #
43
+ # This allows applications to provide their own custom logger
44
+ # implementation that may have specialized formatting or output
45
+ # destinations.
46
+ #
47
+ # @param logger [Logger] a Logger-compatible object that responds to standard
48
+ # logging methods (debug, info, warn, error, fatal)
49
+ # @return [Logger] the newly set logger instance
50
+ # @example
51
+ # Securial.logger = Rails.logger
52
+ def logger=(logger)
53
+ @logger = logger
14
54
  end
15
55
  end
@@ -1,16 +1,47 @@
1
+ # @title Securial Middleware Components
2
+ #
3
+ # Rack middleware components for the Securial framework.
4
+ #
5
+ # This file serves as the entry point for middleware-related functionality in Securial,
6
+ # loading specialized middleware classes that provide features like request/response
7
+ # processing, logging enhancements, and security header management.
8
+ #
1
9
  require "securial/middleware/request_tag_logger"
2
10
  require "securial/middleware/transform_request_keys"
3
11
  require "securial/middleware/transform_response_keys"
4
12
  require "securial/middleware/response_headers"
5
13
 
6
14
  module Securial
7
- module Middleware
8
- # This module serves as a namespace for all middleware components in the Securial gem.
9
- # It currently includes the RequestTagLogger middleware, which tags logs with request IDs.
10
- #
11
- # Additional middleware can be added here as the gem evolves.
12
- #
13
- # Example usage:
14
- # use Securial::Middleware::RequestTagLogger
15
- end
15
+ # Namespace for Rack middleware components in the Securial framework.
16
+ #
17
+ # This module contains several middleware components that enhance Rails applications:
18
+ #
19
+ # - {RequestTagLogger} - Tags logs with request IDs for better traceability
20
+ # - {TransformRequestKeys} - Transforms incoming request parameter keys to a consistent format
21
+ # - {TransformResponseKeys} - Transforms outgoing response JSON keys to match client conventions
22
+ # - {ResponseHeaders} - Adds security headers to responses based on configuration
23
+ #
24
+ # @example Using middleware in a Rails application (config/application.rb)
25
+ # module YourApp
26
+ # class Application < Rails::Application
27
+ # # Add request logging with unique IDs
28
+ # config.middleware.use Securial::Middleware::RequestTagLogger
29
+ #
30
+ # # Transform request keys from camelCase to snake_case
31
+ # config.middleware.use Securial::Middleware::TransformRequestKeys
32
+ #
33
+ # # Transform response keys from snake_case to camelCase
34
+ # config.middleware.use Securial::Middleware::TransformResponseKeys
35
+ #
36
+ # # Add security headers to all responses
37
+ # config.middleware.use Securial::Middleware::ResponseHeaders
38
+ # end
39
+ # end
40
+ #
41
+ # @see Securial::Middleware::RequestTagLogger
42
+ # @see Securial::Middleware::TransformRequestKeys
43
+ # @see Securial::Middleware::TransformResponseKeys
44
+ # @see Securial::Middleware::ResponseHeaders
45
+ #
46
+ module Middleware; end
16
47
  end
@@ -1,11 +1,57 @@
1
+ # @title Securial Request Rate Limiter
2
+ #
3
+ # Rate limiting middleware for protecting authentication endpoints in the Securial framework.
4
+ #
5
+ # This file implements rate limiting for sensitive endpoints like login and password reset,
6
+ # protecting them from brute force attacks, credential stuffing, and denial of service attempts.
7
+ # It uses the Rack::Attack middleware to track and limit request rates based on IP address
8
+ # and provided credentials.
9
+ #
10
+ # @example Basic configuration in a Rails initializer
11
+ # # In config/initializers/securial.rb
12
+ # Securial.configure do |config|
13
+ # config.rate_limit_requests_per_minute = 5
14
+ # config.rate_limit_response_status = 429
15
+ # config.rate_limit_response_message = "Too many requests. Please try again later."
16
+ # end
17
+ #
18
+ # # Apply rate limiting
19
+ # Securial::Security::RequestRateLimiter.apply!
20
+ #
1
21
  require "rack/attack"
2
22
  require "securial/config"
3
23
 
4
24
  module Securial
5
25
  module Security
26
+ # Protects authentication endpoints with configurable rate limiting.
27
+ #
28
+ # This module provides Rack::Attack-based rate limiting for sensitive Securial
29
+ # endpoints, preventing brute force attacks and abuse. It limits requests based
30
+ # on both IP address and credential values (like email address), providing
31
+ # multi-dimensional protection against different attack vectors.
32
+ #
33
+ # Protected endpoints include:
34
+ # - Login attempts (/sessions/login)
35
+ # - Password reset requests (/password/forgot)
36
+ #
6
37
  module RequestRateLimiter
7
- module_function
38
+ extend self
8
39
 
40
+ # Applies rate limiting rules to the Rack::Attack middleware.
41
+ #
42
+ # This method configures Rack::Attack with throttling rules for sensitive endpoints
43
+ # and sets up a custom JSON response format for throttled requests. It should be
44
+ # called during application initialization, typically in a Rails initializer.
45
+ #
46
+ # Rate limits are defined using settings from the Securial configuration:
47
+ # - rate_limit_requests_per_minute: Maximum requests allowed per minute
48
+ # - rate_limit_response_status: HTTP status code to return (typically 429)
49
+ # - rate_limit_response_message: Message to include in throttled responses
50
+ #
51
+ # @return [void]
52
+ # @see Securial::Config::Configuration
53
+ # @see Rack::Attack
54
+ #
9
55
  def apply! # rubocop:disable Metrics/MethodLength
10
56
  resp_status = Securial.configuration.rate_limit_response_status
11
57
  resp_message = Securial.configuration.rate_limit_response_message
@@ -36,7 +82,7 @@ module Securial
36
82
  "Content-Type" => "application/json",
37
83
  "Retry-After" => retry_after.to_s,
38
84
  },
39
- [{ error: resp_message }.to_json],
85
+ [{ errors: [resp_message] }.to_json],
40
86
  ]
41
87
  end
42
88
  end
@@ -1,8 +1,39 @@
1
+ # @title Securial Security Components
2
+ #
3
+ # Security components and protections for the Securial framework.
4
+ #
5
+ # This file serves as the entry point for security-related functionality in Securial,
6
+ # loading specialized security modules that provide protection mechanisms including
7
+ # rate limiting, CSRF protection, and other security measures to safeguard
8
+ # Securial-powered applications.
9
+ #
10
+ # @example Using the rate limiter
11
+ # # Set up a rate limiter for login attempts
12
+ # limiter = Securial::Security::RequestRateLimiter.new(
13
+ # max_requests: 5,
14
+ # period: 1.minute,
15
+ # block_duration: 15.minutes
16
+ # )
17
+ #
18
+ # # Check if a request is allowed
19
+ # if limiter.allowed?(request.ip)
20
+ # # Process login attempt
21
+ # else
22
+ # # Return rate limit exceeded response
23
+ # end
24
+ #
1
25
  require "securial/security/request_rate_limiter"
2
26
 
3
- module Securial
4
- module Security
5
- # This module serves as a namespace for security-related functionality.
6
- # It can be extended with additional security features in the future.
7
- end
8
- end
27
+ module Securial
28
+ # Namespace for security-related functionality in the Securial framework.
29
+ #
30
+ # The Security module contains components that implement various security
31
+ # measures to protect applications from common attacks and threats:
32
+ #
33
+ # - {RequestRateLimiter} - Protection against brute force and DoS attacks
34
+ # - Additional security components may be added in future versions
35
+ #
36
+ # @see Securial::Security::RequestRateLimiter
37
+ #
38
+ module Security; end
39
+ end
@@ -1,3 +1,10 @@
1
1
  module Securial
2
- VERSION = "1.0.0".freeze
2
+ # Current version of the Securial gem.
3
+ #
4
+ # This constant is used by the gem specification to determine the version of the gem
5
+ # when it is built and published to RubyGems. It follows Semantic Versioning 2.0.0.
6
+ #
7
+ # @see https://semver.org/ Semantic Versioning 2.0.0
8
+ # @return [String] the current version in the format "major.minor.patch"
9
+ VERSION = "1.0.2".freeze
3
10
  end
data/lib/securial.rb CHANGED
@@ -1,11 +1,47 @@
1
+ # Main entry point for the Securial gem.
2
+ #
3
+ # This file serves as the primary entry point for the Securial gem,
4
+ # requiring necessary dependencies, setting up the module structure,
5
+ # and establishing method delegation.
6
+ #
7
+ # The Securial gem is a mountable Rails engine that provides authentication
8
+ # and authorization capabilities for Rails applications, supporting JWT,
9
+ # API tokens, and session-based authentication.
10
+ #
11
+ # @example Basic usage in a Rails application
12
+ # # In Gemfile
13
+ # gem 'securial'
14
+ #
15
+ # # In routes.rb
16
+ # Rails.application.routes.draw do
17
+ # mount Securial::Engine => '/securial'
18
+ # end
19
+ #
20
+ # @see Securial::Engine
21
+ # @see Securial::VERSION
22
+ #
1
23
  require "securial/version"
2
24
  require "securial/engine"
3
25
 
4
26
  require "jbuilder"
5
27
 
28
+ # Main namespace for the Securial authentication and authorization framework.
29
+ #
30
+ # This module provides access to core functionality of the Securial gem
31
+ # by exposing key helper methods and serving as the root namespace for
32
+ # all Securial components.
33
+ #
6
34
  module Securial
7
- class << self
8
- delegate :protected_namespace, to: Securial::Helpers::RolesHelper
9
- delegate :titleized_admin_role, to: Securial::Helpers::RolesHelper
10
- end
35
+ extend self
36
+
37
+ # @!method protected_namespace
38
+ # Returns the namespace used for protected resources in the application.
39
+ # @return [String] the protected namespace designation
40
+
41
+ # @!method titleized_admin_role
42
+ # Returns the admin role name with proper title-case formatting.
43
+ # @return [String] the admin role title
44
+
45
+ delegate :protected_namespace, to: Securial::Helpers::RolesHelper
46
+ delegate :titleized_admin_role, to: Securial::Helpers::RolesHelper
11
47
  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: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aly Badawy
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-18 00:00:00.000000000 Z
10
+ date: 2025-06-25 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -55,16 +55,22 @@ dependencies:
55
55
  name: jwt
56
56
  requirement: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '3.0'
61
+ - - "<"
59
62
  - !ruby/object:Gem::Version
60
- version: 3.0.0
63
+ version: '3.2'
61
64
  type: :runtime
62
65
  prerelease: false
63
66
  version_requirements: !ruby/object:Gem::Requirement
64
67
  requirements:
65
- - - "~>"
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '3.0'
71
+ - - "<"
66
72
  - !ruby/object:Gem::Version
67
- version: 3.0.0
73
+ version: '3.2'
68
74
  - !ruby/object:Gem::Dependency
69
75
  name: rack-attack
70
76
  requirement: !ruby/object:Gem::Requirement
@@ -90,6 +96,7 @@ executables:
90
96
  extensions: []
91
97
  extra_rdoc_files: []
92
98
  files:
99
+ - ".yardopts"
93
100
  - MIT-LICENSE
94
101
  - README.md
95
102
  - Rakefile
@@ -161,10 +168,7 @@ files:
161
168
  - lib/securial/auth/auth_encoder.rb
162
169
  - lib/securial/auth/session_creator.rb
163
170
  - lib/securial/auth/token_generator.rb
164
- - lib/securial/cli/run.rb
165
- - lib/securial/cli/securial_new.rb
166
- - lib/securial/cli/show_help.rb
167
- - lib/securial/cli/show_version.rb
171
+ - lib/securial/cli.rb
168
172
  - lib/securial/config.rb
169
173
  - lib/securial/config/configuration.rb
170
174
  - lib/securial/config/signature.rb
@@ -202,7 +206,7 @@ homepage: https://github.com/AlyBadawy/Securial/wiki
202
206
  licenses:
203
207
  - MIT
204
208
  metadata:
205
- release_date: '2025-06-18'
209
+ release_date: '2025-06-25'
206
210
  allowed_push_host: https://rubygems.org
207
211
  homepage_uri: https://github.com/AlyBadawy/Securial/wiki
208
212
  source_code_uri: https://github.com/AlyBadawy/Securial
@@ -1,11 +0,0 @@
1
- # rubocop:disable Rails/Output
2
- def run(command, chdir: nil)
3
- puts "→ #{command}"
4
- if chdir
5
- Dir.chdir(chdir) do
6
- system(command) || abort("❌ Command failed: #{command}")
7
- end
8
- else
9
- system(command) || abort("❌ Command failed: #{command}")
10
- end
11
- end
@@ -1,53 +0,0 @@
1
- # rubocop:disable Rails/Output
2
- require_relative "run"
3
-
4
- def securial_new(app_name, rails_options)
5
- puts "🏗️ Creating new Rails app: #{app_name}"
6
- create_rails_app(app_name, rails_options)
7
- add_securial_gem(app_name)
8
- install_gems(app_name)
9
- install_securial(app_name)
10
- mount_securial_engine(app_name)
11
- print_final_instructions(app_name)
12
- end
13
-
14
- def create_rails_app(app_name, rails_options)
15
- rails_command = ["rails", "new", app_name, *rails_options].join(" ")
16
- run(rails_command)
17
- end
18
-
19
- def add_securial_gem(app_name)
20
- puts "📦 Adding Securial gem to Gemfile"
21
- gemfile_path = File.join(app_name, "Gemfile")
22
- File.open(gemfile_path, "a") { |f| f.puts "\ngem 'securial'" }
23
- end
24
-
25
- def install_gems(app_name)
26
- run("bundle install", chdir: app_name)
27
- end
28
-
29
- def install_securial(app_name)
30
- puts "🔧 Installing Securial"
31
- run("bin/rails generate securial:install", chdir: app_name)
32
- run("bin/rails db:migrate", chdir: app_name)
33
- end
34
-
35
- def mount_securial_engine(app_name)
36
- puts "🔗 Mounting Securial engine in routes"
37
- routes_path = File.join(app_name, "config/routes.rb")
38
- routes = File.read(routes_path)
39
- updated = routes.sub("Rails.application.routes.draw do") do |match|
40
- "#{match}\n mount Securial::Engine => '/securial'"
41
- end
42
- File.write(routes_path, updated)
43
- end
44
-
45
- def print_final_instructions(app_name)
46
- puts "🎉 Securial has been successfully installed in your Rails app!"
47
- puts "✅ Your app is ready at: ./#{app_name}"
48
- puts ""
49
- puts "➡️ Next steps:"
50
- puts " cd #{app_name}"
51
- puts "⚙️ Optional: Configure Securial in config/initializers/securial.rb"
52
- puts " rails server"
53
- end
@@ -1,26 +0,0 @@
1
- # rubocop:disable Rails/Output
2
- def show_help
3
- puts <<~HELP
4
- Securial CLI
5
-
6
- Securial is a mountable Rails engine that provides robust, extensible
7
- authentication and access control for Rails applications. It supports JWT,
8
- API tokens, session-based auth, and is designed for easy integration with
9
- modern web and mobile apps.
10
-
11
- Usage:
12
- securial new APP_NAME [rails_options...] # Create a new Rails app with Securial pre-installed
13
- securial -v, --version # Show the Securial gem version
14
- securial -h, --help # Show this help message
15
-
16
- Example:
17
- securial new myapp --api --database=postgresql -T
18
-
19
- More Info:
20
- review the [Changelog] and [WIKI] for more info on the latest
21
- changes and how to use this gem/engine:
22
- [Changelog]: https://github.com/AlyBadawy/Securial/blob/main/CHANGELOG.md
23
- [WIKI]: https://github.com/AlyBadawy/Securial/wiki
24
-
25
- HELP
26
- end
@@ -1,9 +0,0 @@
1
- # rubocop:disable Rails/Output
2
- def show_version
3
- begin
4
- require "securial/version"
5
- puts "Securial v#{Securial::VERSION}"
6
- rescue LoadError
7
- puts "Securial version information not available."
8
- end
9
- end