Browse Source

GUI improvements

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
main
Stephan Richter 1 month ago
parent
commit
3fd024f4f7
  1. 128
      de.srsoftware.oidc.api/src/main/java/de/srsoftware/oidc/api/Constants.java
  2. 2
      de.srsoftware.oidc.app/build.gradle
  3. 20
      de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java
  4. 22
      de.srsoftware.oidc.web/src/main/resources/de/edit_client.html
  5. 22
      de.srsoftware.oidc.web/src/main/resources/de/new_client.html
  6. 22
      de.srsoftware.oidc.web/src/main/resources/en/edit_client.html
  7. 22
      de.srsoftware.oidc.web/src/main/resources/en/new_client.html
  8. 21
      de.srsoftware.oidc.web/src/main/resources/en/scripts/edit_client.js
  9. 21
      de.srsoftware.oidc.web/src/main/resources/en/scripts/new_client.js
  10. 9
      de.srsoftware.oidc.web/src/main/resources/en/style.css

128
de.srsoftware.oidc.api/src/main/java/de/srsoftware/oidc/api/Constants.java

@ -3,69 +3,69 @@ package de.srsoftware.oidc.api; @@ -3,69 +3,69 @@ package de.srsoftware.oidc.api;
public class Constants {
public static final String ACCESS_TOKEN = "access_token";
public static final String APP_NAME = "LightOIDC";
public static final String AT_HASH = "at_hash";
public static final String ATTEMPTS = "attempts";
public static final String AUTH_CODE = "authorization_code";
public static final String AUTHORZED = "authorized";
public static final String BEARER = "Bearer";
public static final String CAUSE = "cause";
public static final String CLIENT_ID = "client_id";
public static final String CLIENT_SECRET = "client_secret";
public static final String CODE = "code";
public static final String EMAIL = "email";
public static final String ERROR = "error";
public static final String CONFIG_PATH = "LIGHTOIDC_CONFIG_PATH";
public static final String CONFIRMED = "confirmed";
public static final String DAYS = "days";
public static final String ENCRYPTION_KEY = "encryption_key";
public static final String ERROR_DESCRIPTION = "error_description";
public static final String ERROR_INVALID_REDIRECT = "error_invalid_redirect";
public static final String ERROR_LOCKED = "error_locked";
public static final String ERROR_LOGIN_FAILED = "error_login_failed";
public static final String ERROR_MISSING_PARAMETER = "error_missing_parameter";
public static final String ACCESS_TOKEN = "access_token";
public static final String APP_NAME = "LightOIDC";
public static final String AT_HASH = "at_hash";
public static final String ATTEMPTS = "attempts";
public static final String AUTH_CODE = "authorization_code";
public static final String AUTHORZED = "authorized";
public static final String BEARER = "Bearer";
public static final String CAUSE = "cause";
public static final String CLIENT_ID = "client_id";
public static final String CLIENT_SECRET = "client_secret";
public static final String CODE = "code";
public static final String EMAIL = "email";
public static final String ERROR = "error";
public static final String CONFIG_PATH = "LIGHTOIDC_CONFIG_PATH";
public static final String CONFIRMED = "confirmed";
public static final String DAYS = "days";
public static final String ENCRYPTION_KEY = "encryption_key";
public static final String ERROR_DESCRIPTION = "error_description";
public static final String ERROR_INVALID_REDIRECT = "error_invalid_redirect";
public static final String ERROR_LOCKED = "error_locked";
public static final String ERROR_LOGIN_FAILED = "error_login_failed";
public static final String ERROR_MISSING_PARAMETER = "error_missing_parameter";
public static final String ERROR_MISSONG_CODE_RESPONSE_TYPE = "error_missing_code";
public static final String ERROR_NO_USERNAME = "error_no_username";
public static final String ERROR_UNKNOWN_CLIENT = "error_unknown_client";
public static final String ERROR_UNSUPPORTED_RESPONSE_TYPE = "error_unsupported_response_type";
public static final String EXPIRATION = "expiration";
public static final String EXPIRES_IN = "expires_in";
public static final String GRANT_TYPE = "grant_type";
public static final String ID_TOKEN = "id_token";
public static final String INVALID_CLIENT = "invalid_client";
public static final String INVALID_GRANT = "invalid_grant";
public static final String INVALID_REDIRECT_URI = "invalid_request_uri";
public static final String INVALID_REQUEST = "invalid_request";
public static final String INVALID_REQUEST_OBJECT = "invalid_request_object";
public static final String INVALID_SCOPE = "invalid_scope";
public static final String LANDING_PAGE = "landing_page";
public static final String MAILCONFIG = "mail_config";
public static final String NAME = "name";
public static final String NONCE = "nonce";
public static final String PARAM = "parameter";
public static final String PERMISSION = "permission";
public static final String OPENID = "openid";
public static final String REDIRECT_URI = "redirect_uri";
public static final String REDIRECT_URIS = "redirect_uris";
public static final String RELEASE = "release";
public static final String REQUEST_NOT_SUPPORTED = "request_not_supported";
public static final String RESPONSE_TYPE = "response_type";
public static final String SALT = "salt";
public static final String SCOPE = "scope";
public static final String SECRET = "secret";
public static final String SESSION_DURATION = "session_duration";
public static final String SMTP_USER = "smtp_user";
public static final String SMTP_PASSWORD = "smtp_pass";
public static final String SMTP_AUTH = "smtp_auth";
public static final String SMTP_HOST = "smtp_host";
public static final String SMTP_PORT = "smtp_port";
public static final String STATE = "state";
public static final String START_TLS = "start_tls";
public static final String TOKEN = "token";
public static final String TOKEN_TYPE = "token_type";
public static final String TRUST = "trust";
public static final String UNAUTHORIZED_CLIENT = "unauthorized_client";
public static final String USER = "user";
public static final String USER_ID = "user_id";
public static final String ERROR_NO_USERNAME = "error_no_username";
public static final String ERROR_UNKNOWN_CLIENT = "error_unknown_client";
public static final String ERROR_UNSUPPORTED_RESPONSE_TYPE = "error_unsupported_response_type";
public static final String EXPIRATION = "expiration";
public static final String EXPIRES_IN = "expires_in";
public static final String GRANT_TYPE = "grant_type";
public static final String ID_TOKEN = "id_token";
public static final String INVALID_CLIENT = "invalid_client";
public static final String INVALID_GRANT = "invalid_grant";
public static final String INVALID_REDIRECT_URI = "invalid_request_uri";
public static final String INVALID_REQUEST = "invalid_request";
public static final String INVALID_REQUEST_OBJECT = "invalid_request_object";
public static final String INVALID_SCOPE = "invalid_scope";
public static final String LANDING_PAGE = "landing_page";
public static final String MAILCONFIG = "mail_config";
public static final String NAME = "name";
public static final String NONCE = "nonce";
public static final String PARAM = "parameter";
public static final String PERMISSION = "permission";
public static final String OPENID = "openid";
public static final String REDIRECT_URI = "redirect_uri";
public static final String REDIRECT_URIS = "redirect_uris";
public static final String RELEASE = "release";
public static final String REQUEST_NOT_SUPPORTED = "request_not_supported";
public static final String RESPONSE_TYPE = "response_type";
public static final String SALT = "salt";
public static final String SCOPE = "scope";
public static final String SECRET = "secret";
public static final String SESSION_DURATION = "session_duration";
public static final String SMTP_USER = "smtp_user";
public static final String SMTP_PASSWORD = "smtp_pass";
public static final String SMTP_AUTH = "smtp_auth";
public static final String SMTP_HOST = "smtp_host";
public static final String SMTP_PORT = "smtp_port";
public static final String STATE = "state";
public static final String START_TLS = "start_tls";
public static final String TOKEN = "token";
public static final String TOKEN_TYPE = "token_type";
public static final String TRUST = "trust";
public static final String UNAUTHORIZED_CLIENT = "unauthorized_client";
public static final String USER = "user";
public static final String USER_ID = "user_id";
}

2
de.srsoftware.oidc.app/build.gradle

@ -44,4 +44,4 @@ jar { @@ -44,4 +44,4 @@ jar {
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
}

20
de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java

@ -53,16 +53,16 @@ public class Application { @@ -53,16 +53,16 @@ public class Application {
private static System.Logger LOG = new ColorLogger("Application").setLogLevel(DEBUG);
public static void main(String[] args) throws Exception {
var argMap = map(args);
Optional<Path> basePath = argMap.get(BASE_PATH) instanceof Path p ? Optional.of(p) : empty();
var configDir = configDir(APP_NAME);
var defaultFile = configDir.resolve("data.json");
var configFile = (argMap.get(CONFIG_PATH) instanceof Path p ? p : configDir.resolve("config.json")).toFile();
var config = new Configuration(configFile);
var encryptionKey = nullable(System.getenv(ENCRYPTION_KEY)).or(() -> config.get(ENCRYPTION_KEY));
var passHasher = new UuidHasher();
var firstHash = passHasher.hash(FIRST_USER_PASS, FIRST_UUID);
var firstUser = new User(FIRST_USER, firstHash, FIRST_USER, "%s@internal".formatted(FIRST_USER), FIRST_UUID).add(MANAGE_CLIENTS, MANAGE_PERMISSIONS, MANAGE_SMTP, MANAGE_USERS);
var argMap = map(args);
Optional<Path> basePath = argMap.get(BASE_PATH) instanceof Path p ? Optional.of(p) : empty();
var configDir = configDir(APP_NAME);
var defaultFile = configDir.resolve("data.json");
var configFile = (argMap.get(CONFIG_PATH) instanceof Path p ? p : configDir.resolve("config.json")).toFile();
var config = new Configuration(configFile);
var encryptionKey = nullable(System.getenv(ENCRYPTION_KEY)).or(() -> config.get(ENCRYPTION_KEY));
var passHasher = new UuidHasher();
var firstHash = passHasher.hash(FIRST_USER_PASS, FIRST_UUID);
var firstUser = new User(FIRST_USER, firstHash, FIRST_USER, "%s@internal".formatted(FIRST_USER), FIRST_UUID).add(MANAGE_CLIENTS, MANAGE_PERMISSIONS, MANAGE_SMTP, MANAGE_USERS);
FileStoreProvider fileStoreProvider = new FileStoreProvider(passHasher);

22
de.srsoftware.oidc.web/src/main/resources/de/edit_client.html

@ -43,6 +43,28 @@ @@ -43,6 +43,28 @@
</tr>
</table>
</fieldset>
<fieldset class="wide">
<legend>Client-Konfiguration</legend>
<p>Nutzen Sie die folgenden Daten, um ihren Client einzurichten:</p>
<table>
<tr>
<th>Autodiscovery-URL:</th>
<td><code id="autodiscover"></code></td>
</tr>
<tr>
<th>Autorization-Endpunkt:</th>
<td><code id="authorization"></code></td>
</tr>
<tr>
<th>Token-Endpunkt:</th>
<td><code id="token"></code></td>
</tr>
<tr>
<th>Userinfo-Endpunkt:</th>
<td><code id="userinfo"></code></td>
</tr>
</table>
</fieldset>
</div>
</body>
</html>

22
de.srsoftware.oidc.web/src/main/resources/de/new_client.html

@ -42,6 +42,28 @@ @@ -42,6 +42,28 @@
</tr>
</table>
</fieldset>
<fieldset class="wide">
<legend>Client-Konfiguration</legend>
<p>Nutzen Sie die folgenden Daten, um ihren Client einzurichten:</p>
<table>
<tr>
<th>Autodiscovery-URL:</th>
<td><code id="autodiscover"></code></td>
</tr>
<tr>
<th>Autorization-Endpunkt:</th>
<td><code id="authorization"></code></td>
</tr>
<tr>
<th>Token-Endpunkt:</th>
<td><code id="token"></code></td>
</tr>
<tr>
<th>Userinfo-Endpunkt:</th>
<td><code id="userinfo"></code></td>
</tr>
</table>
</fieldset>
</div>
</body>
</html>

22
de.srsoftware.oidc.web/src/main/resources/en/edit_client.html

@ -43,6 +43,28 @@ @@ -43,6 +43,28 @@
</tr>
</table>
</fieldset>
<fieldset class="wide">
<legend>Client configuration</legend>
<p>User the following data to set up your client:</p>
<table>
<tr>
<th>Autodiscovery URL:</th>
<td><code id="autodiscover"></code></td>
</tr>
<tr>
<th>Autorization endpoint:</th>
<td><code id="authorization"></code></td>
</tr>
<tr>
<th>Token endpoint:</th>
<td><code id="token"></code></td>
</tr>
<tr>
<th>Userinfo endpoint:</th>
<td><code id="userinfo"></code></td>
</tr>
</table>
</fieldset>
</div>
</body>
</html>

22
de.srsoftware.oidc.web/src/main/resources/en/new_client.html

@ -42,6 +42,28 @@ @@ -42,6 +42,28 @@
</tr>
</table>
</fieldset>
<fieldset class="wide">
<legend>Client configuration</legend>
<p>User the following data to set up your client:</p>
<table>
<tr>
<th>Autodiscovery URL:</th>
<td><code id="autodiscover"></code></td>
</tr>
<tr>
<th>Autorization endpoint:</th>
<td><code id="authorization"></code></td>
</tr>
<tr>
<th>Token endpoint:</th>
<td><code id="token"></code></td>
</tr>
<tr>
<th>Userinfo endpoint:</th>
<td><code id="userinfo"></code></td>
</tr>
</table>
</fieldset>
</div>
</body>
</html>

21
de.srsoftware.oidc.web/src/main/resources/en/scripts/edit_client.js

@ -1,7 +1,16 @@ @@ -1,7 +1,16 @@
var params = new URLSearchParams(window.location.search);
var id = params.get('id');
function handleAutoDiscover(response){
if (response.ok){
response.json().then(json => {
console.log(json);
setText('authorization',json.authorization_endpoint);
setText('token',json.token_endpoint);
setText('userinfo',json.userinfo_endpoint);
});
}
}
function handleLoadResponse(response){
if (response.ok){
response.json().then(json => {
@ -48,11 +57,17 @@ function updateClient(){ @@ -48,11 +57,17 @@ function updateClient(){
setTimeout(resetButton,4000);
}
fetch(api+'/client',
{
document.addEventListener("DOMContentLoaded", function(event) { // wait until page loaded
fetch(api+'/client', {
method: 'POST',
body: JSON.stringify({
client_id : id
}),
credentials:'include'
}).then(handleLoadResponse);
var autodiscover = window.location.origin+'/.well-known/openid-configuration';
setText('autodiscover',autodiscover);
fetch(autodiscover).then(handleAutoDiscover);
});

21
de.srsoftware.oidc.web/src/main/resources/en/scripts/new_client.js

@ -14,7 +14,7 @@ function addClient(){ @@ -14,7 +14,7 @@ function addClient(){
},
body : JSON.stringify(newData),
credentials:'include'
}).then(handleClientdResponse);
}).then(handleClientResponse);
setText('button','sent…');
setTimeout(function(){
@ -23,7 +23,18 @@ function addClient(){ @@ -23,7 +23,18 @@ function addClient(){
},10000);
}
function handleClientdResponse(response){
function handleAutoDiscover(response){
if (response.ok){
response.json().then(json => {
console.log(json);
setText('authorization',json.authorization_endpoint);
setText('token',json.token_endpoint);
setText('userinfo',json.userinfo_endpoint);
});
}
}
function handleClientResponse(response){
if (response.ok){
redirect("clients.html");
} else {
@ -36,4 +47,10 @@ function checkPermissions(){ @@ -36,4 +47,10 @@ function checkPermissions(){
if (user && !user.permissions.includes('MANAGE_CLIENTS')) redirect("index.html");
}
document.addEventListener("DOMContentLoaded", function(event) { // wait until page loaded
setTimeout(checkPermissions,100);
var autodiscover = window.location.origin+'/.well-known/openid-configuration';
setText('autodiscover',autodiscover);
fetch(autodiscover).then(handleAutoDiscover);
});

9
de.srsoftware.oidc.web/src/main/resources/en/style.css

@ -67,11 +67,18 @@ body fieldset { @@ -67,11 +67,18 @@ body fieldset {
display: inline-block;
}
code {
font-weight: bold;
color: orange;
}
.wide input, textarea{
width: 600px;
}
th {
padding: 10px;
}
input:-webkit-autofill{
filter: none;
box-shadow: 0 0 0 100px rgb(38, 103, 152) inset;

Loading…
Cancel
Save