Skip to content

Commit

Permalink
Pass cert validation CA to JwksResolver like with OidcFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
asa-yeamans committed May 11, 2023
1 parent e36b900 commit 298cdf3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions config/oidc/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ message OIDCConfig {
// true in any other cases.
// Optional.
bool skip_verify_peer_cert = 3;

// When specified, the Authservice will trust the specified Certificate Authority when performing HTTPS calls to
// the Token Endpoint of the OIDC Identity Provider.
// Optional.
string trusted_certificate_authority = 4;
}

oneof jwks_config {
Expand Down
5 changes: 3 additions & 2 deletions src/filters/oidc/jwks_resolver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ DynamicJwksResolverImpl::JwksFetcher::JwksFetcher(
? config.periodic_fetch_interval_sec()
: kJwksPeriodicFetchIntervalSec)),
timer_(ioc_, periodic_fetch_interval_sec_),
verify_peer_cert_(!config.skip_verify_peer_cert()) {
config_(config) {
// Extract initial JWKs.
// After timer callback sucessful, next timer invocation will be scheduled.
timer_.expires_at(std::chrono::steady_clock::now() +
Expand All @@ -37,7 +37,8 @@ void DynamicJwksResolverImpl::JwksFetcher::request(
const boost::system::error_code&) {
boost::asio::spawn(ioc_, [this](boost::asio::yield_context yield) {
common::http::TransportSocketOptions opt;
opt.verify_peer_ = verify_peer_cert_;
opt.ca_cert_ = config_.trusted_certificate_authority();
opt.verify_peer_ = ! config_.skip_verify_peer_cert();
auto resp = http_ptr_->Get(jwks_uri_, {}, "", opt, "", ioc_, yield);
auto next_schedule_interval = periodic_fetch_interval_sec_;

Expand Down
2 changes: 1 addition & 1 deletion src/filters/oidc/jwks_resolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class DynamicJwksResolverImpl : public JwksResolver {
boost::asio::io_context& ioc_;
std::chrono::seconds periodic_fetch_interval_sec_;
boost::asio::steady_timer timer_;
bool verify_peer_cert_ = false;
const config::oidc::OIDCConfig::JwksFetcherConfig config_;
};

explicit DynamicJwksResolverImpl(
Expand Down

0 comments on commit 298cdf3

Please sign in to comment.