Skip to content

Commit

Permalink
fix: adjust python's lib path ref #104
Browse files Browse the repository at this point in the history
  • Loading branch information
jgomer2001 committed Mar 1, 2022
1 parent dcfcb86 commit d54ae9d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class PersistenceService implements IPersistenceService {
private LdapOperationService ldapOperationService;

private String rootDn;
private String pythonLibLocation;

private JsonNode dynamicConfig;

Expand Down Expand Up @@ -265,6 +266,10 @@ public StringEncrypter getStringEncrypter() {
return stringEncrypter;
}

public String getPythonLibLocation() {
return pythonLibLocation;
}

public CacheConfiguration getCacheConfiguration() {
return cacheConfiguration;
}
Expand Down Expand Up @@ -342,6 +347,7 @@ private boolean loadApplianceSettings(Properties properties) {
boolean success = false;
try {
loadASSettings(properties.getProperty("jansAuth_ConfigurationEntryDN"), properties.getProperty("persistence.type"));
pythonLibLocation = properties.getProperty("pythonModulesDir");
rootDn = "o=jans";
success = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class AuthnScriptsReloader extends JobListenerSupport {

private String scriptsJobName;
private Map<String, Long> scriptFingerPrints;
private String pythonLibLocation;

public void init(int gap) {
try {
Expand Down Expand Up @@ -87,7 +86,7 @@ public void jobToBeExecuted(JobExecutionContext context) {

logger.debug("AuthnScriptsReloader. Running timer job for acrs: {}", acrs.toString());
//In Gluu, every time a single script is changed via oxTrust, all custom scripts are reloaded. This is
//not the case when for instance, the oxRevision attribute of a cust script is altered manually (as when developing)
//not the case when for instance, the jansRevision attribute of a cust script is altered manually (as when developing)
//In the future, oxTrust should only reload the script that has changed for performance reasons.
for (String acr : acrs) {
script = persistenceService.getScript(acr);
Expand Down Expand Up @@ -169,7 +168,7 @@ public void jobToBeExecuted(JobExecutionContext context) {
long rev = Optional.ofNullable(script.getRevision()).map(r -> r == Long.MAX_VALUE ? 0 : r).orElse(0L);
script.setRevision(rev + 1);
if (persistenceService.modify(script)) {
logger.debug("oxRevision updated for script '{}'", script.getDisplayName());
logger.debug("jansRevision updated for script '{}'", script.getDisplayName());
}
break;
default:
Expand All @@ -186,14 +185,8 @@ public void jobToBeExecuted(JobExecutionContext context) {

@PostConstruct
private void inited() {

scriptsJobName = getClass().getSimpleName() + "_scripts";
scriptFingerPrints = new HashMap<>();

//the following works fine in both windows dev environment, and linux VMs
pythonLibLocation = Utils.onWindows() ? System.getenv("PYTHON_HOME") + File.separator + "Lib" : "/opt/gluu/python/libs";
logger.info("Using {} as python's lib path", pythonLibLocation);

}

private void copyToLibsDir(CustomScript script) {
Expand All @@ -203,7 +196,7 @@ private void copyToLibsDir(CustomScript script) {
byte[] contents = getScriptContents(script);

if (contents != null) {
Path destPath = Paths.get(pythonLibLocation, MessageFormat.format(FILENAME_TEMPLATE, acr));
Path destPath = Paths.get(persistenceService.getPythonLibLocation(), MessageFormat.format(FILENAME_TEMPLATE, acr));
Files.write(destPath, contents);
logger.trace("The script for acr '{}' has been copied to {}", acr, destPath.toString());
} else {
Expand Down
5 changes: 1 addition & 4 deletions casa/app/src/main/resources/labels/admin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ adm.cors_origin_placeholder=https://myapp.acme.co
amd.cors_invalid_origin={0} is not a valid domain

adm.passreset_title=Password reset availability
adm.passreset_text={
Activate/Deactivate the password reset functionality for users. This feature can be enabled only if
your Gluu Server installation is not using a backend LDAP for identities synchronization.
}
adm.passreset_text=Activate/Deactivate the password reset functionality for users.

adm.methods_title=Enabled authentication methods
adm.methods_text={
Expand Down

0 comments on commit d54ae9d

Please sign in to comment.