@@ -69,65 +69,56 @@ def set_defaults
6969 @query_param = nil # No query param lookup by default
7070
7171 # Token Generation
72- # Prefix reflects environment when Rails is present (e.g., "ak_test_" in test)
73- @token_prefix = -> {
74- env = ( defined? ( Rails ) && Rails . respond_to? ( :env ) ) ? Rails . env . to_s : nil
75- env ? "ak_#{ env } _" : "ak_"
76- }
72+ @token_prefix = -> { "ak_" }
7773 @token_length = 24 # Bytes of entropy
7874 @token_alphabet = :base58 # Avoid ambiguous chars (0, O, I, l)
7975
8076 # Storage & Verification
81- @hash_strategy = :bcrypt # bcrypt by default; can be set to :sha256
77+ @hash_strategy = :sha256 # sha256 or :bcrypt
8278 @secure_compare_proc = -> ( a , b ) { ActiveSupport ::SecurityUtils . secure_compare ( a , b ) }
8379 @key_store_adapter = :active_record # Default storage backend
84- # TODO: Define and implement ApiKeys::BasePolicy in later versions
85- # This will define the authorization policy class used to check if a key is valid beyond basic checks.
86- # Allows injecting custom logic (IP allow-listing, time-of-day checks, etc.).
87- # Must be a class name (String or Class) responding to `.new(api_key, request).valid?`
88- # Default: "ApiKeys::BasePolicy" (a basic implementation should be provided)
8980 @policy_provider = "ApiKeys::BasePolicy" # Default authorization policy class name
9081
9182 # Engine Configuration
9283 @parent_controller = '::ApplicationController'
9384
9485 # Owner Context Configuration
95- @current_owner_method = :current_user # Default to current_user for backward compatibility
96- @authenticate_owner_method = :authenticate_user! # Default to authenticate_user! for Devise compatibility
86+ @current_owner_method = :current_user
87+ @authenticate_owner_method = :authenticate_user!
9788
9889 # Optional Behaviors
99- @default_max_keys_per_owner = nil # No global key limit per owner
100- @require_key_name = false # Don't require names for keys globally
101- @expire_after = nil # Keys do not expire by default (e.g., 90.days)
102- @default_scopes = [ ] # No default scopes assigned globally
90+ @default_max_keys_per_owner = nil
91+ @require_key_name = false
92+ @expire_after = nil
93+ @default_scopes = [ ]
10394
10495 # Performance
105- @cache_ttl = 10 . seconds # Align with tests; good default for cache freshness
96+ @cache_ttl = 5 . seconds
10697
10798 # Security
108- @https_only_production = true # Warn if used over HTTP in production
109- @https_strict_mode = false # Don't raise error, just warn
99+ @https_only_production = true
100+ @https_strict_mode = false
110101
111102 # Background Job Queues
112103 @stats_job_queue = :default
113104 @callbacks_job_queue = :default
114105
115106 # Global Async Toggle
116- @enable_async_operations = true # Default to true to enable jobs
107+ @enable_async_operations = true
117108
118109 # Usage Statistics
119- @track_requests_count = false # Don't increment `requests_count` by default
110+ @track_requests_count = false
120111
121112 # Callbacks
122113 @before_authentication = DEFAULT_CALLBACK
123114 @after_authentication = DEFAULT_CALLBACK
124115
125116 # Engine UI Configuration
126- @return_url = "/" # Default fallback path
127- @return_text = "‹ Home" # Default link text
117+ @return_url = "/"
118+ @return_text = "‹ Home"
128119
129120 # Debugging
130- @debug_logging = false # Disable debug logging by default (warn and error get logged regardless of this)
121+ @debug_logging = false
131122
132123 # Tenant Resolution
133124 @tenant_resolver = -> ( api_key ) { api_key . owner if api_key . respond_to? ( :owner ) }
0 commit comments