add CAS authentication #138
@ -0,0 +1,8 @@
|
||||
package net.hostsharing.hsadminng.config;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
public interface Authenticator {
|
||||
|
||||
String authenticate(final HttpServletRequest httpRequest);
|
||||
}
|
@ -16,7 +16,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
@Service
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CasAuthenticator {
|
||||
public class CasAuthenticator implements Authenticator {
|
||||
|
||||
@Value("${hsadminng.cas.server-url}")
|
||||
private String casServerUrl;
|
||||
@ -28,11 +28,6 @@ public class CasAuthenticator {
|
||||
|
||||
@SneakyThrows
|
||||
public String authenticate(final HttpServletRequest httpRequest) {
|
||||
// FIXME: create FakeCasAuthenticator
|
||||
if (casServerUrl.equals("fake")) {
|
||||
return httpRequest.getHeader("current-subject");
|
||||
}
|
||||
|
||||
final var ticket = httpRequest.getHeader("Authorization");
|
||||
final var url = casServerUrl + "/p3/serviceValidate" +
|
||||
"?service=" + serviceUrl +
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.hostsharing.hsadminng.test;
|
||||
|
||||
import net.hostsharing.hsadminng.config.Authenticator;
|
||||
import net.hostsharing.hsadminng.config.CasAuthenticator;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@ -19,7 +20,7 @@ public class DisableSecurityConfig {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public CasAuthenticator casServiceTicketValidator() {
|
||||
return new CasAuthenticator("fake", null);
|
||||
public Authenticator casServiceTicketValidator() {
|
||||
return new FakeAuthenticator();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package net.hostsharing.hsadminng.test;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import net.hostsharing.hsadminng.config.Authenticator;
|
||||
import net.hostsharing.hsadminng.config.CasAuthenticator;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
@Service
|
||||
public class FakeAuthenticator implements Authenticator {
|
||||
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public String authenticate(final HttpServletRequest httpRequest) {
|
||||
return httpRequest.getHeader("current-subject");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user