use of org.pac4j.core.config.Config in project cas by apereo.
the class CasSecurityContextConfiguration method casAdminPagesPac4jConfig.
@RefreshScope
@Bean
public Config casAdminPagesPac4jConfig() {
try {
final AdminPagesSecurityProperties adminProps = casProperties.getAdminPagesSecurity();
if (StringUtils.isNotBlank(adminProps.getLoginUrl()) && StringUtils.isNotBlank(adminProps.getService())) {
final CasConfiguration casConfig = new CasConfiguration(adminProps.getLoginUrl());
final DirectCasClient client = new DirectCasClient(casConfig);
client.setName(CAS_CLIENT_NAME);
final Config cfg = new Config(adminProps.getService(), client);
if (adminProps.getUsers() == null) {
LOGGER.warn("List of authorized users for admin pages security is not defined. " + "Allowing access for all authenticated users");
client.setAuthorizationGenerator(new DefaultCasAuthorizationGenerator<>());
cfg.setAuthorizer(new IsAuthenticatedAuthorizer());
} else {
final Resource file = ResourceUtils.prepareClasspathResourceIfNeeded(adminProps.getUsers());
if (file != null && file.exists()) {
LOGGER.debug("Loading list of authorized users from [{}]", file);
final Properties properties = new Properties();
properties.load(file.getInputStream());
client.setAuthorizationGenerator(new SpringSecurityPropertiesAuthorizationGenerator(properties));
cfg.setAuthorizer(new RequireAnyRoleAuthorizer(adminProps.getAdminRoles()));
}
}
return cfg;
}
} catch (final Exception e) {
LOGGER.warn(e.getMessage(), e);
}
return new Config();
}
use of org.pac4j.core.config.Config in project pac4j by pac4j.
the class DefaultLogoutLogicTests method setUp.
@Before
public void setUp() {
logic = new DefaultLogoutLogic<>();
context = MockWebContext.create();
config = new Config();
config.setClients(new Clients());
httpActionAdapter = (code, ctx) -> null;
defaultUrl = null;
logoutUrlPattern = null;
localLogout = null;
centralLogout = null;
profiles = new LinkedHashMap<>();
}
use of org.pac4j.core.config.Config in project pac4j by pac4j.
the class DefaultCallbackLogicTests method setUp.
@Before
public void setUp() {
logic = new DefaultCallbackLogic<>();
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
context = new J2EContext(request, response);
config = new Config();
httpActionAdapter = (code, ctx) -> null;
defaultUrl = null;
renewSession = null;
clientFinder = new DefaultCallbackClientFinder();
}
use of org.pac4j.core.config.Config in project druid by druid-io.
the class Pac4jAuthenticator method createPac4jConfig.
private Config createPac4jConfig(OIDCConfig oidcConfig) {
OidcConfiguration oidcConf = new OidcConfiguration();
oidcConf.setClientId(oidcConfig.getClientID());
oidcConf.setSecret(oidcConfig.getClientSecret().getPassword());
oidcConf.setDiscoveryURI(oidcConfig.getDiscoveryURI());
oidcConf.setExpireSessionWithToken(true);
oidcConf.setUseNonce(true);
oidcConf.setReadTimeout(Ints.checkedCast(pac4jCommonConfig.getReadTimeout().getMillis()));
oidcConf.setResourceRetriever(// ResourceRetriever is used to get Auth server configuration from "discoveryURI"
new CustomSSLResourceRetriever(pac4jCommonConfig.getReadTimeout().getMillis(), sslSocketFactory));
OidcClient oidcClient = new OidcClient(oidcConf);
oidcClient.setUrlResolver(new DefaultUrlResolver(true));
oidcClient.setCallbackUrlResolver(new NoParameterCallbackUrlResolver());
// This is used by OidcClient in various places to make HTTPrequests.
if (sslSocketFactory != null) {
HTTPRequest.setDefaultSSLSocketFactory(sslSocketFactory);
}
return new Config(Pac4jCallbackResource.SELF_URL, oidcClient);
}
Aggregations