KEYCLOAK-891 Create server info page on admin console
This commit is contained in:
parent
2186fe32a9
commit
6cf42db584
7 changed files with 65 additions and 13 deletions
|
@ -71,7 +71,6 @@
|
|||
<span>Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="serverInfo">Keycloak {{serverInfo.version}}</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -863,6 +863,9 @@ module.config([ '$routeProvider', function($routeProvider) {
|
|||
},
|
||||
controller : 'RealmBruteForceCtrl'
|
||||
})
|
||||
.when('/server-info', {
|
||||
templateUrl : 'partials/server-info.html'
|
||||
})
|
||||
.when('/logout', {
|
||||
templateUrl : 'partials/home.html',
|
||||
controller : 'LogoutCtrl'
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{authUrl}}/realms/{{auth.user.realm}}/account?referrer=security-admin-console">Manage Account</a></li>
|
||||
<li><a href="#/server-info">Server Info</a></li>
|
||||
<li class="separator"><a href="" ng-click="auth.authz.logout()">Sign Out</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<div id="content-area" class="col-sm-12" role="main">
|
||||
<h2></h2>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h2>Server Info</h2>
|
||||
|
||||
<table class="table table-striped table-bordered">
|
||||
<tr>
|
||||
<td>Version</td>
|
||||
<td>{{serverInfo.version}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Server Time</td>
|
||||
<td>{{serverInfo.serverTime}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Providers</td>
|
||||
<td>
|
||||
<table class="table table-striped table-bordered">
|
||||
<tr data-ng-repeat="(spi, providers) in serverInfo.providers">
|
||||
<td>{{spi}}</td>
|
||||
<td>{{providers.sort().join(', ')}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
|
@ -836,11 +836,4 @@ legend .kc-icon-collapse {
|
|||
|
||||
table table {
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
#serverInfo {
|
||||
color: #666;
|
||||
position: absolute;
|
||||
bottom: 10px;
|
||||
right: 10px;
|
||||
}
|
|
@ -33,3 +33,8 @@
|
|||
border-top-color: rgba(255,255,255,0.05);
|
||||
}
|
||||
|
||||
.dropdown-menu .separator {
|
||||
border-top: 1px solid #ddd;
|
||||
margin-top: 5px;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
|
|
@ -9,17 +9,21 @@ import org.keycloak.freemarker.ThemeProvider;
|
|||
import org.keycloak.models.KeycloakSession;
|
||||
import org.keycloak.protocol.LoginProtocol;
|
||||
import org.keycloak.protocol.LoginProtocolFactory;
|
||||
import org.keycloak.provider.Provider;
|
||||
import org.keycloak.provider.ProviderFactory;
|
||||
import org.keycloak.provider.Spi;
|
||||
import org.keycloak.social.SocialProvider;
|
||||
import org.keycloak.util.ProviderLoader;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.core.Context;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ServiceLoader;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
|
@ -38,15 +42,25 @@ public class ServerInfoAdminResource {
|
|||
@GET
|
||||
public ServerInfoRepresentation getInfo() {
|
||||
ServerInfoRepresentation info = new ServerInfoRepresentation();
|
||||
info.setVersion(Version.VERSION);
|
||||
info.version = Version.VERSION;
|
||||
info.serverTime = new Date().toString();
|
||||
setSocialProviders(info);
|
||||
setThemes(info);
|
||||
setEventListeners(info);
|
||||
setProtocols(info);
|
||||
setApplicationImporters(info);
|
||||
setProviders(info);
|
||||
return info;
|
||||
}
|
||||
|
||||
private void setProviders(ServerInfoRepresentation info) {
|
||||
Map<String, Set<String>> providers = new HashMap<String, Set<String>>();
|
||||
for (Spi spi : ServiceLoader.load(Spi.class)) {
|
||||
providers.put(spi.getName(), session.listProviderIds(spi.getProviderClass()));
|
||||
}
|
||||
info.providers = providers;
|
||||
}
|
||||
|
||||
private void setThemes(ServerInfoRepresentation info) {
|
||||
ThemeProvider themeProvider = session.getProvider(ThemeProvider.class, "extending");
|
||||
info.themes = new HashMap<String, List<String>>();
|
||||
|
@ -100,24 +114,27 @@ public class ServerInfoAdminResource {
|
|||
|
||||
private String version;
|
||||
|
||||
private String serverTime;
|
||||
|
||||
private Map<String, List<String>> themes;
|
||||
|
||||
private List<String> socialProviders;
|
||||
private List<String> protocols;
|
||||
private List<Map<String, String>> applicationImporters;
|
||||
|
||||
private Map<String, Set<String>> providers;
|
||||
|
||||
private List<String> eventListeners;
|
||||
|
||||
public ServerInfoRepresentation() {
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
public String getServerTime() {
|
||||
return serverTime;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getThemes() {
|
||||
|
@ -139,6 +156,10 @@ public class ServerInfoAdminResource {
|
|||
public List<Map<String, String>> getApplicationImporters() {
|
||||
return applicationImporters;
|
||||
}
|
||||
|
||||
public Map<String, Set<String>> getProviders() {
|
||||
return providers;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue