katalyst-basic-auth 0.5.0 → 1.0.1
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/CHANGELOG.md +9 -0
- data/README.md +1 -1
- data/lib/katalyst/basic/auth/config.rb +24 -9
- data/lib/katalyst-basic-auth.rb +3 -0
- metadata +6 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0690a58df78d87a4b6ec2a4399953e9e42a3a6cad751dd80e7583881cc9a620
|
|
4
|
+
data.tar.gz: 56c1bd702be0b16cabc4b66291724ee344ec6ae6130011bb50aa71aad04d31ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7475af04fa7c36c0dd6a09bc7713880807c64678d480a13184bad2db6ae1fc2867c26e92a3bbfbbd337a9161d2be94642f8c6a68716731bda81450557efa7b1b
|
|
7
|
+
data.tar.gz: aaea9752360f625d4aaaaac20fa29358553098f08e03ed7a85ae7a75b1b3e80a7f561d69aa1d8fc5b90c79afa8949f259a1ac651685c206efad5fe4206fb1d9b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [1.0.1] - 2026-11-26
|
|
2
|
+
|
|
3
|
+
- Fix: normalise repeated slashes before matching paths, e.g. `//admin` is matched as `/admin`
|
|
4
|
+
- Fix: match configured paths on segment boundaries, e.g. excluding `/up` no longer excludes `/uploads`
|
|
5
|
+
|
|
6
|
+
## [1.0.0] - 2025-08-04
|
|
7
|
+
|
|
8
|
+
- Drop support for old ruby versions
|
|
9
|
+
|
|
1
10
|
## [0.5.0] - 2024-04-26
|
|
2
11
|
|
|
3
12
|
- Add `/up` as a default allowed path (Rails 7.1+ health check)
|
data/README.md
CHANGED
|
@@ -29,7 +29,7 @@ The following environment variables can optionally be defined to configure the g
|
|
|
29
29
|
|
|
30
30
|
| Environment Variable | Description |
|
|
31
31
|
| ------ | ----- |
|
|
32
|
-
| KATALYST_BASIC_AUTH_ENABLED | If "yes" or "true", the middleware will be enabled. By default, the middleware is enabled on staging and uat Rails environments |
|
|
32
|
+
| KATALYST_BASIC_AUTH_ENABLED | If "yes" or "true", the middleware will be enabled. By default, the middleware is enabled on staging and uat Rails environments. To disable basic auth in these environments, you must explicitly set this to a non-true value. |
|
|
33
33
|
| KATALYST_BASIC_AUTH_USER | The username for basic authentication. Default is the Rails application name in lowercase. |
|
|
34
34
|
| KATALYST_BASIC_AUTH_PASS | The password for basic authentication. A password will be generated if not set. |
|
|
35
35
|
| KATALYST_BASIC_AUTH_IP_ALLOWLIST | Comma or space separated list of IP addresses or CIDR ranges to allow without basic auth |
|
|
@@ -17,10 +17,17 @@ module Katalyst
|
|
|
17
17
|
# @param path [String] Request path
|
|
18
18
|
# @return [Config] The config for the given path
|
|
19
19
|
def for_path(path)
|
|
20
|
-
path
|
|
20
|
+
path = normalize_path(path)
|
|
21
21
|
all.sort_by(&:path)
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
.reverse
|
|
23
|
+
.detect { |i| i.match?(path) } || global
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Compare paths the way the Rails router will see them, e.g. "//admin" routes to "/admin"
|
|
27
|
+
# @param path [String, nil] Request path
|
|
28
|
+
# @return [String] Path with repeated slashes collapsed
|
|
29
|
+
def normalize_path(path)
|
|
30
|
+
"/#{path}".squeeze("/")
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
# @return [Config] The global configuration
|
|
@@ -39,7 +46,7 @@ module Katalyst
|
|
|
39
46
|
username: username,
|
|
40
47
|
password: password,
|
|
41
48
|
enabled: enabled,
|
|
42
|
-
ip_allowlist: ip_allowlist
|
|
49
|
+
ip_allowlist: ip_allowlist,
|
|
43
50
|
)
|
|
44
51
|
all.delete(all.detect { |i| i.path == config.path })
|
|
45
52
|
all << config
|
|
@@ -58,8 +65,8 @@ module Katalyst
|
|
|
58
65
|
@all = [new, up]
|
|
59
66
|
end
|
|
60
67
|
|
|
61
|
-
def each(&
|
|
62
|
-
all.each(&
|
|
68
|
+
def each(&)
|
|
69
|
+
all.each(&)
|
|
63
70
|
end
|
|
64
71
|
|
|
65
72
|
def description
|
|
@@ -79,7 +86,7 @@ module Katalyst
|
|
|
79
86
|
def enabled_rails_env?
|
|
80
87
|
return false unless rails?
|
|
81
88
|
|
|
82
|
-
|
|
89
|
+
%w[staging uat].include?(Rails.env)
|
|
83
90
|
end
|
|
84
91
|
|
|
85
92
|
def rails?
|
|
@@ -107,7 +114,7 @@ module Katalyst
|
|
|
107
114
|
if rails? && Rails.application.respond_to?(:secret_key_base)
|
|
108
115
|
Rails.application.secret_key_base
|
|
109
116
|
else
|
|
110
|
-
ENV
|
|
117
|
+
ENV.fetch("SECRET_KEY_BASE", nil)
|
|
111
118
|
end
|
|
112
119
|
end
|
|
113
120
|
|
|
@@ -126,6 +133,14 @@ module Katalyst
|
|
|
126
133
|
path == ROOT_PATH
|
|
127
134
|
end
|
|
128
135
|
|
|
136
|
+
# Matches the configured path and anything below it, on path segment boundaries,
|
|
137
|
+
# e.g. "/up" matches "/up" and "/up/db" but not "/uploads"
|
|
138
|
+
# @param request_path [String] Normalized request path
|
|
139
|
+
def match?(request_path)
|
|
140
|
+
prefix = path.chomp("/")
|
|
141
|
+
request_path == prefix || request_path.start_with?("#{prefix}/")
|
|
142
|
+
end
|
|
143
|
+
|
|
129
144
|
def allow_ip?(env)
|
|
130
145
|
request = ::Rack::Request.new(env)
|
|
131
146
|
return false unless request.ip
|
|
@@ -136,7 +151,7 @@ module Katalyst
|
|
|
136
151
|
|
|
137
152
|
def description
|
|
138
153
|
output = []
|
|
139
|
-
output << "path: #{root_path? ?
|
|
154
|
+
output << "path: #{root_path? ? '(global)' : path}"
|
|
140
155
|
output << "enabled: #{enabled?}"
|
|
141
156
|
output << "username: #{username}"
|
|
142
157
|
output << "password: #{password}"
|
metadata
CHANGED
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: katalyst-basic-auth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Katalyst Interactive
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
- !ruby/object:Gem::Dependency
|
|
14
|
-
name: rack
|
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
|
16
|
-
requirements:
|
|
17
|
-
- - ">="
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '0'
|
|
20
|
-
type: :runtime
|
|
21
|
-
prerelease: false
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ">="
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: '0'
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
27
12
|
description: Makes it easy to add basic auth on staging and development apps.
|
|
28
13
|
email:
|
|
29
14
|
- developers@katalyst.com.au
|
|
@@ -34,6 +19,7 @@ files:
|
|
|
34
19
|
- CHANGELOG.md
|
|
35
20
|
- LICENSE.txt
|
|
36
21
|
- README.md
|
|
22
|
+
- lib/katalyst-basic-auth.rb
|
|
37
23
|
- lib/katalyst/basic/auth.rb
|
|
38
24
|
- lib/katalyst/basic/auth/config.rb
|
|
39
25
|
- lib/katalyst/basic/auth/middleware.rb
|
|
@@ -48,7 +34,6 @@ metadata:
|
|
|
48
34
|
homepage_uri: https://github.com/katalyst/katalyst-basic-auth
|
|
49
35
|
source_code_uri: https://github.com/katalyst/basic-auth
|
|
50
36
|
changelog_uri: https://github.com/katalyst/basic-auth/blob/main/CHANGELOG.md
|
|
51
|
-
post_install_message:
|
|
52
37
|
rdoc_options: []
|
|
53
38
|
require_paths:
|
|
54
39
|
- lib
|
|
@@ -56,15 +41,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
56
41
|
requirements:
|
|
57
42
|
- - ">="
|
|
58
43
|
- !ruby/object:Gem::Version
|
|
59
|
-
version:
|
|
44
|
+
version: '3.3'
|
|
60
45
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
46
|
requirements:
|
|
62
47
|
- - ">="
|
|
63
48
|
- !ruby/object:Gem::Version
|
|
64
49
|
version: '0'
|
|
65
50
|
requirements: []
|
|
66
|
-
rubygems_version:
|
|
67
|
-
signing_key:
|
|
51
|
+
rubygems_version: 4.0.20
|
|
68
52
|
specification_version: 4
|
|
69
53
|
summary: Gem to add basic auth on staging websites
|
|
70
54
|
test_files: []
|