use of com.erudika.para.client.ParaClient in project scoold by Erudika.
the class ScooldServer method paraClientBean.
@Bean
public ParaClient paraClientBean() {
logger.info("Listening on port {}...", getServerPort());
String accessKey = Config.getConfigParam("access_key", "x");
ParaClient pc = new ParaClient(accessKey, Config.getConfigParam("secret_key", "x"));
pc.setEndpoint(Config.getConfigParam("endpoint", "http://localhost:8080"));
// unlimited batch size
pc.setChunkSize(Config.getConfigInt("batch_request_size", 0));
logger.info("Initialized ParaClient with endpoint {} and access key '{}'.", pc.getEndpoint(), accessKey);
printRootAppConnectionNotice(accessKey);
printGoogleMigrationNotice();
// update the Scoold App settings through the Para App settings API.
Map<String, Object> settings = new HashMap<String, Object>();
settings.put("gp_app_id", Config.GPLUS_APP_ID);
settings.put("gp_secret", Config.GPLUS_SECRET);
settings.put("fb_app_id", Config.FB_APP_ID);
settings.put("fb_secret", Config.FB_SECRET);
settings.put("gh_app_id", Config.GITHUB_APP_ID);
settings.put("gh_secret", Config.GITHUB_SECRET);
settings.put("in_app_id", Config.LINKEDIN_APP_ID);
settings.put("in_secret", Config.LINKEDIN_SECRET);
settings.put("tw_app_id", Config.TWITTER_APP_ID);
settings.put("tw_secret", Config.TWITTER_SECRET);
settings.put("ms_app_id", Config.MICROSOFT_APP_ID);
settings.put("ms_secret", Config.MICROSOFT_SECRET);
settings.put("sl_app_id", Config.SLACK_APP_ID);
settings.put("sl_secret", Config.SLACK_SECRET);
settings.put("az_app_id", Config.AMAZON_APP_ID);
settings.put("az_secret", Config.AMAZON_SECRET);
// Microsoft tenant id support - https://github.com/Erudika/scoold/issues/208
settings.put("ms_tenant_id", Config.getConfigParam("ms_tenant_id", null));
// OAuth 2 settings
settings.putAll(oauthSettings(""));
settings.putAll(oauthSettings("second"));
settings.putAll(oauthSettings("third"));
// LDAP settings
settings.put("security.ldap.server_url", Config.getConfigParam("security.ldap.server_url", ""));
settings.put("security.ldap.base_dn", Config.getConfigParam("security.ldap.base_dn", ""));
settings.put("security.ldap.bind_dn", Config.getConfigParam("security.ldap.bind_dn", ""));
settings.put("security.ldap.bind_pass", Config.getConfigParam("security.ldap.bind_pass", ""));
settings.put("security.ldap.user_search_base", Config.getConfigParam("security.ldap.user_search_base", ""));
settings.put("security.ldap.user_search_filter", Config.getConfigParam("security.ldap.user_search_filter", "(cn={0})"));
settings.put("security.ldap.user_dn_pattern", Config.getConfigParam("security.ldap.user_dn_pattern", "uid={0}"));
settings.put("security.ldap.password_attribute", Config.getConfigParam("security.ldap.password_attribute", "userPassword"));
settings.put("security.ldap.username_as_name", Config.getConfigBoolean("security.ldap.username_as_name", false));
settings.put("security.ldap.active_directory_domain", Config.getConfigParam("security.ldap.active_directory_domain", ""));
settings.put("security.ldap.mods_group_node", Config.getConfigParam("security.ldap.mods_group_node", ""));
settings.put("security.ldap.admins_group_node", Config.getConfigParam("security.ldap.admins_group_node", ""));
if (!Config.getConfigParam("security.ldap.compare_passwords", "").isEmpty()) {
settings.put("security.ldap.compare_passwords", Config.getConfigParam("security.ldap.compare_passwords", ""));
}
// email verification
settings.put("security.allow_unverified_emails", Config.getConfigBoolean("security.allow_unverified_emails", StringUtils.isBlank(Config.getConfigParam("mail.host", ""))));
// sessions
settings.put("security.one_session_per_user", Config.getConfigBoolean("security.one_session_per_user", true));
settings.put("session_timeout", Config.getConfigInt("session_timeout", Config.SESSION_TIMEOUT_SEC));
// URLs for success and failure
settings.put("signin_success", getServerURL() + CONTEXT_PATH + SIGNINLINK + "/success?jwt=id");
settings.put("signin_failure", getServerURL() + CONTEXT_PATH + SIGNINLINK + "?code=3&error=true");
ScooldUtils.tryConnectToPara(() -> {
pc.throwExceptionOnHTTPError(true);
pc.setAppSettings(settings);
pc.throwExceptionOnHTTPError(false);
// finally, check if app actually exists
return pc.getTimestamp() > 0;
});
return pc;
}
Aggregations