Commit 0a197e21 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

18: Adapt according to needs of first actual implementation (CR)

Task-Url: #18
parent b75f9143
Pipeline #18149 passed with stage
in 1 minute and 37 seconds
package eu.dariah.de.dariahsp.web.controller;
import java.util.Map;
import java.util.Optional;
import org.pac4j.core.client.Client;
import org.pac4j.core.config.Config;
......@@ -27,6 +28,18 @@ public class CommonLoginController {
@Autowired private Config config;
@Autowired private JEEContext jeeContext;
private final String loginView;
public CommonLoginController() {
this.loginView = "login";
}
public CommonLoginController(String loginView) {
this.loginView = loginView;
}
/**
* Present the local login form; override if the desired view is not 'login'
*
......@@ -39,7 +52,7 @@ public class CommonLoginController {
final FormClient formClient = (FormClient) config.getClients().findClient(securityConfig.getLocal().getAuthorizerName()).orElseThrow();
map.put("callbackUrl", formClient.getCallbackUrl());
map.put("requestUrl", requestUrl);
return "login";
return loginView;
}
/**
......@@ -66,13 +79,13 @@ public class CommonLoginController {
/**
* Initiate a login based on a requested authentication client specified in terms of a client_name GET parameter
*
* @param client_name name of the authentication client
* @param client_name name of the authentication client, null selects default
* @return redirection
*/
@RequestMapping("/loginClient")
@RequestMapping("/startLogin")
@ResponseBody
public String forceLogin() {
final String clientName = authInfoHelper.getRequestedClientName();
final String clientName = Optional.ofNullable(authInfoHelper.getRequestedClientName()).orElse(securityConfig.getEnabledClientNames().get(0));
final Client<?> client = config.getClients().findClient(clientName).orElse(null);
if (client==null) {
throw new AuthenticatorNotAvailable(clientName);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment