Skip to content

Commit 588abed

Browse files
committed
Prevent status webservices from being returned on the providers endpoint
1 parent 6764051 commit 588abed

4 files changed

Lines changed: 29 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1313

1414
### Added
1515
- List resources request (`GET /resources`) now produce audit events.
16-
([cyberark/conjur#2652](https://github.com/cyberark/conjur/pull/2652)
16+
[cyberark/conjur#2652](https://github.com/cyberark/conjur/pull/2652)
1717

1818
### Changed
1919
- AWS Access Key Rotation now preserves only one key
2020

21+
### Fixed
22+
- Removed Status webservices from the list providers endpoint
23+
[cyberark/conjur#2640](https://github.com/cyberark/conjur/pull/2640)
24+
2125
## [1.18.4] - 2022-09-11
2226

2327
### Added

app/db/repository/authenticator_repository.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ def initialize(data_object:, resource_repository: ::Resource, logger: Rails.logg
88
end
99

1010
def find_all(type:, account:)
11+
identifier = Sequel.function(:identifier, :resource_id)
12+
1113
@resource_repository.where(
1214
Sequel.like(
1315
:resource_id,
1416
"#{account}:webservice:conjur/#{type}/%"
1517
)
18+
).where(
19+
Sequel.like(
20+
identifier,
21+
Authentication::InstalledAuthenticators::AUTHN_STATUS_FILTER
22+
)
1623
).all.map do |webservice|
1724
load_authenticator(account: account, id: webservice.id.split(':').last, type: type)
1825
end.compact

app/domain/authentication/installed_authenticators.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module Authentication
44
class InstalledAuthenticators
55

66
AUTHN_RESOURCE_PREFIX = "conjur/authn-"
7+
AUTHN_STATUS_FILTER = %r{conjur/(authn(?:-[^/]+)?(?:/[^/]+)?)$}
78

89
class << self
910
def authenticators(env, authentication_module: ::Authentication)
@@ -28,7 +29,7 @@ def configured_authenticators
2829
.where(identifier.like("#{AUTHN_RESOURCE_PREFIX}%"))
2930
.where(kind => "webservice")
3031
.select_map(identifier)
31-
.map { |id| id[%r{^conjur/(authn(?:-[^/]+)?(?:/[^/]+)?)$}, 1] } # filter out nested status webservice
32+
.map { |id| id[AUTHN_STATUS_FILTER, 1] } # filter out nested status webservice
3233
.compact
3334
.push(::Authentication::Common.default_authenticator_name)
3435
end

spec/app/db/repository/authenticator_repository_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@
8989
::Role['rspec:policy:conjur/authn-oidc/baz-abc123'].destroy
9090
end
9191
end
92+
93+
context 'when webservices status are presents' do
94+
before(:each) do
95+
::Resource.create(
96+
resource_id: "rspec:webservice:conjur/authn-oidc/foo-abc123/status",
97+
owner_id: "rspec:policy:conjur/authn-oidc/foo-abc123"
98+
)
99+
end
100+
101+
it { expect(repo.find_all(type: 'authn-oidc', account: 'rspec').length).to eq(2) }
102+
103+
after(:each) do
104+
::Resource['rspec:webservice:conjur/authn-oidc/foo-abc123/status'].destroy
105+
end
106+
end
92107
end
93108

94109
after(:each) do

0 commit comments

Comments
 (0)