mirror of
https://github.com/dalbodeule/snap-admin.git
synced 2025-06-08 21:38:21 +00:00
Started implementation of #32
This commit is contained in:
parent
8455db747b
commit
60581527f0
@ -85,6 +85,8 @@ public class SnapAdmin {
|
||||
|
||||
private SnapAdminProperties properties;
|
||||
|
||||
private boolean authenticated;
|
||||
|
||||
private static final String VERSION = "0.1.9";
|
||||
|
||||
/**
|
||||
@ -398,6 +400,13 @@ public class SnapAdmin {
|
||||
throw new DbAdminException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAuthenticated() {
|
||||
return authenticated;
|
||||
}
|
||||
|
||||
public void setAuthenticated(boolean authenticated) {
|
||||
this.authenticated = authenticated;
|
||||
}
|
||||
|
||||
}
|
||||
|
31
src/main/java/tech/ailef/snapadmin/external/StartupAuthCheckRunner.java
vendored
Normal file
31
src/main/java/tech/ailef/snapadmin/external/StartupAuthCheckRunner.java
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
package tech.ailef.snapadmin.external;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class StartupAuthCheckRunner implements CommandLineRunner {
|
||||
@Autowired
|
||||
private SnapAdmin snapAdmin;
|
||||
|
||||
@Override
|
||||
public void run(String...args) throws Exception {
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(URI.create("http://localhost:8080/admin"))
|
||||
.build();
|
||||
|
||||
HttpResponse<String> response = HttpClient
|
||||
.newBuilder()
|
||||
.build()
|
||||
.send(request, BodyHandlers.ofString());
|
||||
|
||||
String body = response.body();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user