pin_flags 0.1.1 → 0.1.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae850d2a54a2c64eb154558ae616d98d9d7aa1468d48c6977fc1e09b2afdc176
|
4
|
+
data.tar.gz: 63ed88de0f0d12eb5c810756a8ba598c2aca5e7ad0acbb56710040000c1b7341
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e1b94b8fd24b8283c7642a30c2a35da25945c9e4c985a5389565b1f8f5c679b5edd89a6c5cb380d5e26da1c3285b77af0b5546ea4e3a5ec7bc0c27e37e2ce6a
|
7
|
+
data.tar.gz: f883bb9bcc2bc55888c948d7eb6a7c8789485d962bdaeb7c683583dd91bb0561440a0855093a9c54cf8f573d8c7831416f7f3a9664d66ed2a1b1f7271da80bf9
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ A lightweight Rails engine for managing entity based features with built-in cach
|
|
10
10
|
|
11
11
|
- 🚀 Polymorphic "feature tags" which can be tied to any ActiveRecord Model
|
12
12
|
- ⚡ Built-in caching with configurable expiry
|
13
|
-
- 🎨 An admn UI that stays out of your way with minified [BulmaCSS](https://github.com/jgthms/bulma) and [
|
13
|
+
- 🎨 An admn UI that stays out of your way with minified [BulmaCSS](https://github.com/jgthms/bulma) and [AlpineJS](https://github.com/alpinejs/alpine)
|
14
14
|
- 🔒 Isolated namespace to avoid conflicts
|
15
15
|
- 💉 No dependency on Stimulus
|
16
16
|
|
@@ -54,6 +54,48 @@ PinFlags.config do |config|
|
|
54
54
|
end
|
55
55
|
```
|
56
56
|
|
57
|
+
### HTTP Basic Authentication
|
58
|
+
|
59
|
+
PinFlags includes built-in HTTP Basic Authentication to protect the admin interface. Configure it in your initializer:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
PinFlags.config do |config|
|
63
|
+
config.cache_prefix = "budget_tracker_pin_flags"
|
64
|
+
config.cache_expiry = 1.hour
|
65
|
+
config.http_basic_auth_enabled = true # Default: true
|
66
|
+
config.http_basic_auth_user = "admin" # Default: "pin_flags_admin"
|
67
|
+
config.http_basic_auth_password = "password" # Default: "please_change_me"
|
68
|
+
end
|
69
|
+
```
|
70
|
+
|
71
|
+
**Security Note:** Always change the default credentials in production environments.
|
72
|
+
|
73
|
+
### Consider using environment variables for sensitive information:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
PinFlags.config do |config|
|
77
|
+
config.http_basic_auth_user = ENV["PIN_FLAGS_USER"] || "pin_flags_admin"
|
78
|
+
config.http_basic_auth_password = ENV["PIN_FLAGS_PASSWORD"] || "please_change_me"
|
79
|
+
end
|
80
|
+
```
|
81
|
+
|
82
|
+
### Or use Rails credentials:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
PinFlags.config do |config|
|
86
|
+
config.http_basic_auth_user = Rails.application.credentials.pin_flags[:user] || "pin_flags_admin"
|
87
|
+
config.http_basic_auth_password = Rails.application.credentials.pin_flags[:password] || "please_change_me"
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
91
|
+
To disable authentication entirely:
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
PinFlags.config do |config|
|
95
|
+
config.http_basic_auth_enabled = false
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
57
99
|
## Usage
|
58
100
|
|
59
101
|
### Include the module in any of your ActiveRecord models:
|
@@ -167,6 +209,9 @@ end
|
|
167
209
|
|--------|-------------|---------|
|
168
210
|
| `cache_prefix` | Prefix for cache keys | `"pin_flags"` |
|
169
211
|
| `cache_expiry` | Cache expiration time | `12.hours` |
|
212
|
+
| `http_basic_auth_enabled` | Enable HTTP Basic Authentication | `true` |
|
213
|
+
| `http_basic_auth_user` | Username for admin interface | `"pin_flags_admin"` |
|
214
|
+
| `http_basic_auth_password` | Password for admin interface | `"secure_password"` |
|
170
215
|
|
171
216
|
## Development
|
172
217
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module PinFlags::BasicAuthentication
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
before_action :authenticate_by_http_basic
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
def authenticate_by_http_basic
|
10
|
+
if http_basic_authentication_enabled?
|
11
|
+
http_basic_authenticate_or_request_with(**http_basic_authentication_credentials)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def http_basic_authentication_enabled?
|
16
|
+
PinFlags.http_basic_auth_enabled
|
17
|
+
end
|
18
|
+
|
19
|
+
def http_basic_authentication_credentials
|
20
|
+
{
|
21
|
+
name: PinFlags.http_basic_auth_user,
|
22
|
+
password: PinFlags.http_basic_auth_password
|
23
|
+
}.transform_values(&:presence)
|
24
|
+
end
|
25
|
+
end
|
data/lib/pin_flags/version.rb
CHANGED
data/lib/pin_flags.rb
CHANGED
@@ -6,6 +6,10 @@ module PinFlags
|
|
6
6
|
mattr_accessor :cache_prefix, default: "pin_flags"
|
7
7
|
mattr_accessor :cache_expiry, default: 12.hours
|
8
8
|
|
9
|
+
mattr_accessor :http_basic_auth_enabled, default: true
|
10
|
+
mattr_accessor :http_basic_auth_user, default: "pin_flags_admin"
|
11
|
+
mattr_accessor :http_basic_auth_password, default: "please_change_me"
|
12
|
+
|
9
13
|
def self.config
|
10
14
|
yield self if block_given?
|
11
15
|
self
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pin_flags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Demetrious Wilson
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- app/assets/stylesheets/pin_flags/application.css
|
117
117
|
- app/assets/stylesheets/pin_flags/bulma.min.css
|
118
118
|
- app/assets/stylesheets/pin_flags/forms.css
|
119
|
+
- app/controllers/concerns/pin_flags/basic_authentication.rb
|
119
120
|
- app/controllers/pin_flags/application_controller.rb
|
120
121
|
- app/controllers/pin_flags/feature_tags/exports_controller.rb
|
121
122
|
- app/controllers/pin_flags/feature_tags/feature_subscriptions_controller.rb
|