diff --git a/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java b/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java index 42fd24e..619268e 100644 --- a/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java +++ b/de.srsoftware.oidc.app/src/main/java/de/srsoftware/oidc/app/Application.java @@ -81,7 +81,7 @@ public class Application { new Forward(INDEX).bindPath(ROOT).on(server); new WellKnownController().bindPath(WELL_KNOWN, "/realms/oidc" + WELL_KNOWN).on(server); new UserController(mailConfig, sessionService, userService, staticPages).bindPath(API_USER).on(server); - var tokenControllerConfig = new TokenController.Configuration("https://lightoidc.srsoftware.de", 10); // TODO configure or derive from hostname + var tokenControllerConfig = new TokenController.Configuration(10); new TokenController(authService, clientService, keyManager, userService, tokenControllerConfig).bindPath(API_TOKEN).on(server); new ClientController(authService, clientService, sessionService, userService).bindPath(API_CLIENT).on(server); new KeyStoreController(keyStore).bindPath(JWKS).on(server); diff --git a/de.srsoftware.oidc.backend/src/main/java/de/srsoftware/oidc/backend/TokenController.java b/de.srsoftware.oidc.backend/src/main/java/de/srsoftware/oidc/backend/TokenController.java index f5f8f83..46d0c32 100644 --- a/de.srsoftware.oidc.backend/src/main/java/de/srsoftware/oidc/backend/TokenController.java +++ b/de.srsoftware.oidc.backend/src/main/java/de/srsoftware/oidc/backend/TokenController.java @@ -27,7 +27,7 @@ import org.jose4j.lang.JoseException; import org.json.JSONObject; public class TokenController extends PathHandler { - public record Configuration(String issuer, int tokenExpirationMinutes) { + public record Configuration(int tokenExpirationMinutes) { } private final ClientService clients; private final AuthorizationService authorizations; @@ -115,7 +115,8 @@ public class TokenController extends PathHandler { var user = optUser.get(); var accessToken = users.accessToken(user); - String jwToken = createJWT(client, user, accessToken); + var issuer = hostname(ex); + String jwToken = createJWT(client, user, accessToken, issuer); ex.getResponseHeaders().add("Cache-Control", "no-store"); JSONObject response = new JSONObject(); response.put(ACCESS_TOKEN, accessToken.id()); @@ -126,13 +127,13 @@ public class TokenController extends PathHandler { return sendContent(ex, response); } - private String createJWT(Client client, User user, AccessToken accessToken) { + private String createJWT(Client client, User user, AccessToken accessToken, String issuer) { try { PublicJsonWebKey key = keyManager.getKey(); var algo = key.getAlgorithm(); var atHash = this.atHash(algo, accessToken); key.setUse("sig"); - JwtClaims claims = createIdTokenClaims(user, client, atHash); + JwtClaims claims = createIdTokenClaims(user, client, atHash, issuer); // A JWT is a JWS and/or a JWE with JSON claims as the payload. // In this example it is a JWS so we create a JsonWebSignature object. @@ -167,13 +168,13 @@ public class TokenController extends PathHandler { } } - private JwtClaims createIdTokenClaims(User user, Client client, String atHash) { + private JwtClaims createIdTokenClaims(User user, Client client, String atHash, String issuer) { var optNonce = authorizations.consumeNonce(user.uuid(), client.id()); JwtClaims claims = new JwtClaims(); // required claims: - claims.setIssuer(config.issuer); // who creates the token and signs it - claims.setSubject(user.uuid()); // the subject/principal is whom the token is about + claims.setIssuer(issuer); // who creates the token and signs it + claims.setSubject(user.uuid()); // the subject/principal is whom the token is about claims.setAudience(client.id()); claims.setExpirationTimeMinutesInTheFuture(config.tokenExpirationMinutes); // time when the token will expire (10 minutes from now) claims.setIssuedAtToNow(); diff --git a/de.srsoftware.oidc.backend/src/main/java/de/srsoftware/oidc/backend/UserController.java b/de.srsoftware.oidc.backend/src/main/java/de/srsoftware/oidc/backend/UserController.java index 52e945a..f915fe8 100644 --- a/de.srsoftware.oidc.backend/src/main/java/de/srsoftware/oidc/backend/UserController.java +++ b/de.srsoftware.oidc.backend/src/main/java/de/srsoftware/oidc/backend/UserController.java @@ -21,6 +21,7 @@ import jakarta.mail.*; import jakarta.mail.internet.*; import java.io.IOException; import java.time.Duration; +import java.util.Comparator; import java.util.Map; import java.util.Optional; import java.util.Set; diff --git a/de.srsoftware.oidc.web/src/main/resources/de/authorization.html b/de.srsoftware.oidc.web/src/main/resources/de/authorization.html new file mode 100644 index 0000000..0533750 --- /dev/null +++ b/de.srsoftware.oidc.web/src/main/resources/de/authorization.html @@ -0,0 +1,42 @@ + + + + Light OIDC + + + + + + + + + + + + +
+ Fehlender Rückgabe-Typ: code +
+ + + + \ No newline at end of file diff --git a/de.srsoftware.oidc.web/src/main/resources/de/reset_password.template.txt b/de.srsoftware.oidc.web/src/main/resources/de/reset_password.template.txt new file mode 100644 index 0000000..2b77005 --- /dev/null +++ b/de.srsoftware.oidc.web/src/main/resources/de/reset_password.template.txt @@ -0,0 +1,12 @@ +Link zum Zurückseten des Passworts für {service} +Liebe(r) {displayname}, + +Jemand – wahrscheinlich du – beauftragte das Passwort für {service} zurückzusetzen. + +Falls du das warst öffne bitte den folgenden Link in deinem Browser: + +{link} + +Falls du das Zurücksetzen *nicht angefragt hast* (oder versehentlich), kannst du diese Mail einfach ignorieren. + +Beste Grüße, dein OIDC-Admin. \ No newline at end of file diff --git a/de.srsoftware.oidc.web/src/main/resources/en/scripts/authorization.js b/de.srsoftware.oidc.web/src/main/resources/en/scripts/authorization.js index d88c4b9..e565373 100644 --- a/de.srsoftware.oidc.web/src/main/resources/en/scripts/authorization.js +++ b/de.srsoftware.oidc.web/src/main/resources/en/scripts/authorization.js @@ -84,4 +84,7 @@ function backendAutorization(){ }).then(handleResponse); } -backendAutorization(); +document.addEventListener("logged_in", function(event) { // wait until page loaded + backendAutorization(); +}); + diff --git a/de.srsoftware.oidc.web/src/main/resources/en/scripts/clients.js b/de.srsoftware.oidc.web/src/main/resources/en/scripts/clients.js index 23a000a..1739337 100644 --- a/de.srsoftware.oidc.web/src/main/resources/en/scripts/clients.js +++ b/de.srsoftware.oidc.web/src/main/resources/en/scripts/clients.js @@ -8,17 +8,19 @@ function handleClients(response){ return; } var clients = response.json().then(clients => { + var arr = []; + for (let id in clients) arr.push(clients[id]); + arr.sort((a,b) => a.name < b.name ? -1 : 1); var bottom = document.getElementById('bottom'); - for (let id in clients){ + for (let client of arr){ var row = document.createElement("tr"); - var client = clients[id]; row.innerHTML = `${client.name} - ${id} + ${client.client_id} ${client.redirect_uris.join("
")} ${link(client.landing_page)} - - + + `; bottom.parentNode.insertBefore(row,bottom); } diff --git a/de.srsoftware.oidc.web/src/main/resources/en/scripts/users.js b/de.srsoftware.oidc.web/src/main/resources/en/scripts/users.js index 08a2670..b384050 100644 --- a/de.srsoftware.oidc.web/src/main/resources/en/scripts/users.js +++ b/de.srsoftware.oidc.web/src/main/resources/en/scripts/users.js @@ -39,10 +39,13 @@ function handleUsers(response){ return; } response.json().then(users => { + var arr = []; + for (let id in users) arr.push(users[id]); + arr.sort((a,b) => a.username < b.username ? -1 : 1); var bottom = document.getElementById('bottom'); - for (let id in users){ + for (var u of arr){ var row = document.createElement("tr"); - var u = users[id]; + //var u = users[id]; var manage = { clients : u.permissions.includes('MANAGE_CLIENTS'), perms : u.permissions.includes('MANAGE_PERMISSIONS'), @@ -52,16 +55,16 @@ function handleUsers(response){ row.innerHTML = `${u.username} ${u.realname} ${u.email} - ${id} + ${u.uuid} - - - - + + + + - - + + `; bottom.parentNode.insertBefore(row,bottom); if (user.permissions.includes('MANAGE_PERMISSIONS')) showAll('permissions');