-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into cn-aes-conf-hilevel
- Loading branch information
Showing
7 changed files
with
159 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ EXPOSE 5000 | |
LABEL org.opencontainers.image.url="ghcr.io/janssenproject/jans/cedarling-flask-sidecar" \ | ||
org.opencontainers.image.authors="Janssen Project <[email protected]>" \ | ||
org.opencontainers.image.vendor="Janssen Project" \ | ||
org.opencontainers.image.version="1.2.0-1" \ | ||
org.opencontainers.image.version="0.0.0-nightly" \ | ||
org.opencontainers.image.title="AuthZen Flask API" \ | ||
org.opencontainers.image.description="Flask API that implements the [AuthZen](https://openid.github.io/authzen/) specification with the [cedarling](../) python binding." | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "flask-sidecar" | ||
version = "1.2.0" | ||
version = "0.0.0" | ||
description = "Sidecar for cedarling" | ||
authors = ["SafinWasi <[email protected]>"] | ||
license = "Apache-2.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...-link/server/src/main/java/io/jans/keycloak/link/server/service/ConfigurationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright [2024] [Janssen Project] | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.jans.keycloak.link.server.service; | ||
|
||
import io.jans.config.GluuConfiguration; | ||
import io.jans.keycloak.link.model.config.StaticConfiguration; | ||
import io.jans.model.SmtpConfiguration; | ||
import io.jans.orm.PersistenceEntryManager; | ||
import io.jans.service.EncryptionService; | ||
import io.jans.util.StringHelper; | ||
import io.jans.util.security.StringEncrypter.EncryptionException; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import org.slf4j.Logger; | ||
|
||
/** | ||
* | ||
* @author Yuriy Movchan Date: 12/12/2023 | ||
*/ | ||
@ApplicationScoped | ||
public class ConfigurationService { | ||
|
||
@Inject | ||
private Logger log; | ||
|
||
@Inject | ||
private PersistenceEntryManager persistenceEntryManager; | ||
|
||
@Inject | ||
private StaticConfiguration staticConfiguration; | ||
|
||
@Inject | ||
private EncryptionService encryptionService; | ||
|
||
public GluuConfiguration getConfiguration() { | ||
String configurationDn = staticConfiguration.getBaseDn().getConfiguration(); | ||
if (StringHelper.isEmpty(configurationDn)) { | ||
return null; | ||
} | ||
|
||
return persistenceEntryManager.find(GluuConfiguration.class, configurationDn); | ||
} | ||
|
||
/** | ||
* Build DN string for configuration | ||
* | ||
* @param inum Inum | ||
* @return DN string for specified configuration or DN for configurations branch if inum is null | ||
* @throws Exception | ||
*/ | ||
public String getDnForConfiguration(String inum) { | ||
String baseDn = staticConfiguration.getBaseDn().getConfiguration(); | ||
if (StringHelper.isEmpty(inum)) { | ||
return baseDn; | ||
} | ||
|
||
return String.format("inum=%s,%s", inum, baseDn); | ||
} | ||
|
||
public void decryptSmtpPasswords(SmtpConfiguration smtpConfiguration) { | ||
if (smtpConfiguration == null) { | ||
return; | ||
} | ||
String password = smtpConfiguration.getSmtpAuthenticationAccountPassword(); | ||
if (StringHelper.isNotEmpty(password)) { | ||
try { | ||
smtpConfiguration.setSmtpAuthenticationAccountPasswordDecrypted(encryptionService.decrypt(password)); | ||
} catch (EncryptionException ex) { | ||
log.error("Failed to decrypt SMTP user password", ex); | ||
} | ||
} | ||
password = smtpConfiguration.getKeyStorePassword(); | ||
if (StringHelper.isNotEmpty(password)) { | ||
try { | ||
smtpConfiguration.setKeyStorePasswordDecrypted(encryptionService.decrypt(password)); | ||
} catch (EncryptionException ex) { | ||
log.error("Failed to decrypt Kestore password", ex); | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters