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

Issue https://github.com/ceskaexpedice/ceska-digitalni-knihovna/issues/93 #1111

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=cz.incad.kramerius
version=7.0.40-rc4
version=7.0.40-rc5
#version=7.0.40-devmerge
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,13 @@ private List<String> findLabels(User user) {
Pair<User,List<String>> retval = proxyUserHandler.user();
if (retval != null) {
licenses.addAll(retval.getValue());
Map<String, String> sessionAttributes = retval.getKey().getSessionAttributes();
sessionAttributes.keySet().forEach(key-> {
user.addSessionAttribute(oneInstance.getName()+"_"+key, sessionAttributes.get(key));
});

/** disabled attributes
*
* Map<String, String> sessionAttributes = retval.getKey().getSessionAttributes();
* sessionAttributes.keySet().forEach(key-> {
* user.addSessionAttribute(oneInstance.getName()+"_"+key, sessionAttributes.get(key));
* });
*/
}
} catch (ProxyHandlerException e) {
LOGGER.log(Level.SEVERE,e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ protected WebResource.Builder buidForwardResponse(String url, boolean headers) {
LOGGER.fine(String.format("Requesting %s", url));
WebResource r = client.resource(url);
if (headers) {
LOGGER.info("CDK_TOKEN_PARAMETERS = " + header);
String message = String.format("URL(%s), CDK_TOKEN_PARAMETERS(%s)", url, header);
LOGGER.fine(message);
return r.header("CDK_TOKEN_PARAMETERS", header);
} else {
return r.getRequestBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public Pair<User, List<String>> user() throws ProxyHandlerException {
String baseurl = forwardUrl();
String url = baseurl + (baseurl.endsWith("/") ? "" : "/") + "api/v5.0/cdk/forward/user";
ClientResponse fResponse = super.forwardedResponse(url);

if (fResponse.getStatus() != 200) {
String errorMessage = "Chyba při volání API: Status code " + fResponse.getStatus() + ", URL: " + url;
LOGGER.log(Level.SEVERE, errorMessage);
throw new ProxyHandlerException(errorMessage);
}

String entity = fResponse.getEntity(String.class);
JSONObject jObject = new JSONObject(entity);
return userFromJSON(jObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public Pair<User, List<String>> user() throws ProxyHandlerException {
String baseurl = forwardUrl();
String url = baseurl + (baseurl.endsWith("/") ? "" : "/") + "api/cdk/v7.0/forward/user";
ClientResponse fResponse = super.forwardedResponse(url);

if (fResponse.getStatus() != 200) {
String errorMessage = "Chyba při volání API: Status code " + fResponse.getStatus() + ", URL: " + url;
LOGGER.log(Level.SEVERE, errorMessage);
throw new ProxyHandlerException(errorMessage);
}

String entity = fResponse.getEntity(String.class);
JSONObject jObject = new JSONObject(entity);
return userFromJSON(jObject);
Expand Down
4 changes: 0 additions & 4 deletions search/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@ jib {
}
to {
image = "ceskaexpedice/kramerius:${version}"
auth {
username = 'pavelstastny'
password = 'armoAoito1.'
}
}
container {
appRoot = '/usr/local/tomcat/webapps/search'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import cz.incad.kramerius.security.User;
import cz.incad.kramerius.security.impl.UserImpl;
import cz.incad.kramerius.security.utils.UserUtils;
import cz.incad.kramerius.utils.conf.KConfiguration;
import org.keycloak.KeycloakPrincipal;
import org.keycloak.KeycloakSecurityContext;
import org.keycloak.adapters.spi.KeycloakAccount;
Expand Down Expand Up @@ -111,7 +112,24 @@ protected Keycloak3rdUser createUserWrapper(HttpServletRequest req, String userN
keycloack3rdUser.setProperty(key, object.toString());
}
});


/** K5 instance */
boolean cdkServerMode = KConfiguration.getInstance().getConfiguration().getBoolean("cdk.server.mode", false);
if (cdkServerMode) {
Set<String> allKeys = keycloack3rdUser.getPropertyKeys();
if (allKeys.contains("eduPersonScopedAffiliation") && !allKeys.contains("affiliation")) {
keycloack3rdUser.setProperty("affiliation", keycloack3rdUser.getProperty("eduPersonScopedAffiliation"));
}
if (allKeys.contains("eduPersonEntitlement") && !allKeys.contains("entitlement")) {
keycloack3rdUser.setProperty("entitlement", keycloack3rdUser.getProperty("eduPersonEntitlement"));
}
if (allKeys.contains("preffered_user_name") && !allKeys.contains("remote_user")) {
keycloack3rdUser.setProperty("remote_user", keycloack3rdUser.getProperty("preffered_user_name"));


}
}

/** standard dnnt user role */
StandardDNNTUsersSupport.makeSureDNNTUsersRole(keycloack3rdUser);

Expand Down
Loading