Skip to content

Commit

Permalink
Add /up as a default allowed path
Browse files Browse the repository at this point in the history
  • Loading branch information
sfnelson committed Apr 26, 2024
1 parent c80dab7 commit 9811b05
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.5.0] - 2024-04-26

- Add `/up` as a default allowed path (Rails 7.1+ health check)

## [0.4.0] - 2022-06-10

- Add support for IP address allowlists
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/katalyst/katalyst-basic-auth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/katalyst-basic-auth/blob/master/CODE_OF_CONDUCT.md).
Bug reports and pull requests are welcome on GitHub at https://github.com/katalyst/basic-auth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/katalyst-basic-auth/blob/master/CODE_OF_CONDUCT.md).

## License

Expand Down
11 changes: 5 additions & 6 deletions katalyst-basic-auth.gemspec
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
# frozen_string_literal: true

require_relative "lib/katalyst/basic/auth/version"

Gem::Specification.new do |spec|
spec.name = "katalyst-basic-auth"
spec.version = Katalyst::Basic::Auth::VERSION
spec.version = "0.5.0"
spec.authors = ["Katalyst Interactive"]
spec.email = ["admin@katalyst.com.au"]
spec.email = ["developers@katalyst.com.au"]

spec.summary = "Gem to add basic auth on staging websites"
spec.description = "Makes it easy to add basic auth on staging and development apps."
spec.homepage = "https://github.com/katalyst/katalyst-basic-auth"
spec.license = "MIT"

# Supports Rails 3+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.8")

spec.metadata["allowed_push_host"] = "https://rubygems.org"
spec.metadata["rubygems_mfa_required"] = "true"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/katalyst/katalyst-basic-auth"
spec.metadata["changelog_uri"] = "https://github.com/katalyst/katalyst-basic-auth/blob/main/CHANGELOG.md"
spec.metadata["source_code_uri"] = "https://github.com/katalyst/basic-auth"
spec.metadata["changelog_uri"] = "https://github.com/katalyst/basic-auth/blob/main/CHANGELOG.md"

spec.files = Dir["{lib}/**/*", "CHANGELOG.md", "LICENSE.txt", "README.md"]

Expand Down
1 change: 0 additions & 1 deletion lib/katalyst/basic/auth.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require_relative "auth/version"
require_relative "auth/config"
require_relative "auth/middleware"
require_relative "auth/rails" if defined?(Rails)
Expand Down
8 changes: 6 additions & 2 deletions lib/katalyst/basic/auth/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ def add(path:, username: nil, password: nil, enabled: nil, ip_allowlist: nil)
config
end

def up(path = "/up")
new(path: path, enabled: false)
end

def all
@all ||= [new]
@all ||= [new, up]
end

def reset!
@all = [new]
@all = [new, up]
end

def each(&block)
Expand Down
9 changes: 0 additions & 9 deletions lib/katalyst/basic/auth/version.rb

This file was deleted.

7 changes: 0 additions & 7 deletions spec/katalyst/basic/auth_spec.rb

This file was deleted.

9 changes: 9 additions & 0 deletions spec/katalyst/basic/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
it { expect(basic_auth).to have_received(:call) }
end

context "with rails health check path" do
let(:request_path) { "/up" }

before { middleware.call(env) }

it { expect(app).to have_received(:call) }
it { expect(basic_auth).not_to have_received(:call) }
end

context "with an excluded path" do
let(:request_path) { "/no_auth/path" }

Expand Down

0 comments on commit 9811b05

Please sign in to comment.