Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - toggle between refreshable and one-time instantiation of pac4j clients #5315

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
import java.util.Optional;

/**
* This is {@link RefreshableDelegatedClients}.
* This is {@link RefreshableDelegatedClients}, which shims {@link Clients}
* to rebuild any delegated clients when either {@link Clients#findClient(String) findClient}
* or {@link Clients#findAllClients() findAllClients} are called.
* In practice, this means that clients will be rebuilt for each request.
*
* @see org.apereo.cas.configuration.model.support.pac4j.Pac4jDelegatedAuthenticationCoreProperties#lazyInit
*
* @author Misagh Moayyed
* @since 6.4.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,21 @@ public static class Pac4jAuthenticationEventExecutionPlanClientConfiguration {
public Clients builtClients(final CasConfigurationProperties casProperties,
@Qualifier("pac4jDelegatedClientFactory")
final DelegatedClientFactory pac4jDelegatedClientFactory) {
return new RefreshableDelegatedClients(casProperties.getServer().getLoginUrl(), pac4jDelegatedClientFactory);
if (casProperties.getAuthn().getPac4j().getCore().isLazyInit()) {
LOGGER.info("Delegated clients will be dynamically initialized");
return new RefreshableDelegatedClients(casProperties.getServer().getLoginUrl(),
pac4jDelegatedClientFactory);
} else {
val clients = pac4jDelegatedClientFactory.build();
LOGGER.debug("Built the following delegated clients: [{}]", clients);
if (clients.isEmpty()) {
LOGGER.debug("No delegated authentication clients are defined and/or configured");
} else {
LOGGER.info("Located and prepared [{}] delegated authentication client(s)", clients.size());

}
return new Clients(casProperties.getServer().getLoginUrl(), new ArrayList<>(clients));
}
}
}

Expand Down