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
|
@Service
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class CasAuthenticator {
|
public class CasAuthenticator implements Authenticator {
|
||||||
|
|
||||||
@Value("${hsadminng.cas.server-url}")
|
@Value("${hsadminng.cas.server-url}")
|
||||||
private String casServerUrl;
|
private String casServerUrl;
|
||||||
@ -28,11 +28,6 @@ public class CasAuthenticator {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public String authenticate(final HttpServletRequest httpRequest) {
|
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 ticket = httpRequest.getHeader("Authorization");
|
||||||
final var url = casServerUrl + "/p3/serviceValidate" +
|
final var url = casServerUrl + "/p3/serviceValidate" +
|
||||||
"?service=" + serviceUrl +
|
"?service=" + serviceUrl +
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.hostsharing.hsadminng.test;
|
package net.hostsharing.hsadminng.test;
|
||||||
|
|
||||||
|
import net.hostsharing.hsadminng.config.Authenticator;
|
||||||
import net.hostsharing.hsadminng.config.CasAuthenticator;
|
import net.hostsharing.hsadminng.config.CasAuthenticator;
|
||||||
import org.springframework.boot.test.context.TestConfiguration;
|
import org.springframework.boot.test.context.TestConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -19,7 +20,7 @@ public class DisableSecurityConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CasAuthenticator casServiceTicketValidator() {
|
public Authenticator casServiceTicketValidator() {
|
||||||
return new CasAuthenticator("fake", null);
|
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