Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

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

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

### Fixed
- Removed Status webservices from the list providers endpoint

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lists should be surrounded by blank lines

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend something like:

Suggested change
- Removed Status webservices from the list providers endpoint
- OIDC Provider endpoint no longer includes duplicates when Status is enabled.

[cyberark/conjur#2640](https://github.com/cyberark/conjur/pull/2640)

## [1.18.4] - 2022-09-11

### Added
Expand Down
14 changes: 11 additions & 3 deletions app/db/repository/authenticator_repository.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
module DB
module Repository
class AuthenticatorRepository
def initialize(data_object:, resource_repository: ::Resource, logger: Rails.logger)
def initialize(
data_object:,
resource_repository: ::Resource,
logger: Rails.logger,
enabled_authenticators: Rails.application.config.conjur_config.authenticators
)
@resource_repository = resource_repository
@data_object = data_object
@logger = logger
@enabled_authenticators = enabled_authenticators
end

def find_all(type:, account:)
@resource_repository.where(
enabled_authenticator_types = @enabled_authenticators.select { |authenticator| authenticator.match("#{type}") }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.

.map { |authenticator| "#{account}:webservice:conjur/#{authenticator}" }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 2 (not 8) spaces for indenting an expression in an assignment spanning multiple lines.

@resource_repository.where(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation detected.

Sequel.like(
:resource_id,
"#{account}:webservice:conjur/#{type}/%"
)
).all.map do |webservice|
).all.select { |webservice|enabled_authenticator_types.include?(webservice.resource_id) }.map do |webservice|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after closing | missing.

load_authenticator(account: account, id: webservice.id.split(':').last, type: type)
end.compact
end
Expand Down
3 changes: 2 additions & 1 deletion app/domain/authentication/installed_authenticators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Authentication
class InstalledAuthenticators

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Freeze mutable objects assigned to constants.


class << self
def authenticators(env, authentication_module: ::Authentication)
Expand All @@ -28,7 +29,7 @@ def configured_authenticators
.where(identifier.like("#{AUTHN_RESOURCE_PREFIX}%"))
.where(kind => "webservice")
.select_map(identifier)
.map { |id| id[%r{^conjur/(authn(?:-[^/]+)?(?:/[^/]+)?)$}, 1] } # filter out nested status webservice
.map { |id| id[AUTHN_STATUS_FILTER, 1] } # filter out nested status webservice
.compact
.push(::Authentication::Common.default_authenticator_name)
end
Expand Down
2 changes: 1 addition & 1 deletion ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
RAILS_ENV:
REQUIRE_SIMPLECOV: "true"
CONJUR_LOG_LEVEL: debug
CONJUR_AUTHENTICATORS: authn-ldap/test,authn-ldap/secure,authn-oidc/keycloak,authn-oidc,authn-k8s/test,authn-azure/prod,authn-gcp,authn-jwt/raw,authn-jwt/keycloak,authn-oidc/keycloak2,authn-oidc/okta-2
CONJUR_AUTHENTICATORS: authn-ldap/test,authn-ldap/secure,authn-oidc/keycloak,authn-oidc,authn-oidc/okta,authn-oidc/oidceast,authn-k8s/test,authn-azure/prod,authn-gcp,authn-jwt/raw,authn-jwt/keycloak,authn-oidc/keycloak2,authn-oidc/okta-2
LDAP_URI: ldap://ldap-server:389
LDAP_BASE: dc=conjur,dc=net
LDAP_FILTER: '(uid=%s)'
Expand Down
2 changes: 1 addition & 1 deletion dev/start
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ enable_oidc_authenticators() {
echo "Configuring Keycloak as OpenID provider for automatic testing"
# We enable an OIDC authenticator without a service-id to test that it's
# invalid.
enabled_authenticators="$enabled_authenticators,authn-oidc/keycloak,authn-oidc,authn-oidc/keycloak2"
enabled_authenticators="$enabled_authenticators,authn-oidc/keycloak,authn-oidc/okta,authn-oidc/oidceast,authn-oidc/keycloak2"

if [[ $ENABLE_OIDC_OKTA = true ]]; then
echo "Configuring OKTA as OpenID provider for manual testing"
Expand Down
24 changes: 23 additions & 1 deletion spec/app/db/repository/authenticator_repository_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@
let(:repo) do
DB::Repository::AuthenticatorRepository.new(
resource_repository: resource_repository,
data_object: Authentication::AuthnOidc::V2::DataObjects::Authenticator
data_object: Authentication::AuthnOidc::V2::DataObjects::Authenticator,
enabled_authenticators: enabled_authenticators
)
end

let (:enabled_authenticators) {
%w[authn-oidc/foo-abc123
authn-oidc/baz-abc123
authn-oidc/bar-abc123]
}

let(:arguments) { %i[provider_uri client_id client_secret claim_mapping nonce state] }

describe('#find_all') do
Expand Down Expand Up @@ -89,6 +96,21 @@
::Role['rspec:policy:conjur/authn-oidc/baz-abc123'].destroy
end
end

context 'when webservices status are presents' do
before(:each) do
::Resource.create(
resource_id: "rspec:webservice:conjur/authn-oidc/foo-abc123/status",
owner_id: "rspec:policy:conjur/authn-oidc/foo-abc123"
)
end

it { expect(repo.find_all(type: 'authn-oidc', account: 'rspec').length).to eq(2) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How cumbersome would it be to actually verify the contents of the list, rather than just the count?

Being explicit about the expected outcome would be a more valuable assurance than just the number of results.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would not work since we and not brining over the real resource_id in the repository, but a created one based on the service_id which is the same between the status and normal web-services.


after(:each) do
::Resource['rspec:webservice:conjur/authn-oidc/foo-abc123/status'].destroy
end
end
end

after(:each) do
Expand Down