From b9bff9733d2d687065345493c99034110a0c826b Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Thu, 3 Jul 2025 13:02:31 +0200 Subject: [PATCH] workin on idc login flow --- frontend/src/App.svelte | 2 +- frontend/src/Components/Login.svelte | 25 +++++- .../src/routes/user/ConnectedServices.svelte | 46 ++++++++++ frontend/src/routes/user/LoginServices.svelte | 9 +- frontend/src/routes/user/Profile.svelte | 65 ++++++++++++++ frontend/src/routes/user/User.svelte | 85 ++----------------- translations/src/main/resources/de.json | 7 +- .../srsoftware/umbrella/user/Constants.java | 2 +- .../de/srsoftware/umbrella/user/Paths.java | 1 + .../srsoftware/umbrella/user/UserModule.java | 85 +++++++++++++++++-- .../umbrella/user/model/ForeignLogin.java | 4 +- 11 files changed, 234 insertions(+), 97 deletions(-) create mode 100644 frontend/src/routes/user/ConnectedServices.svelte create mode 100644 frontend/src/routes/user/Profile.svelte diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index d08d9bd..05c90f5 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -32,7 +32,7 @@ - +

Page not found

diff --git a/frontend/src/Components/Login.svelte b/frontend/src/Components/Login.svelte index ce8b999..db333fe 100644 --- a/frontend/src/Components/Login.svelte +++ b/frontend/src/Components/Login.svelte @@ -4,6 +4,7 @@ import { checkUser, tryLogin } from '../user.svelte.js'; let credentials = { username : null, password : null } + let services = $state([]); function doLogin(ev){ tryLogin(credentials); @@ -15,7 +16,26 @@ onMount(async () => { await checkUser(); + const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/oidc/buttons`; + const resp = await fetch(url,{credentials:'include'}); + if (resp.ok){ + const json = await resp.json(); + for (let service of json) services.push(service); + } }); + + async function redirectTo(service){ + const url = `${location.protocol}//${location.host.replace('5173','8080')}/api/user/oidc/redirect/${service}`; + const resp = await fetch(url,{credentials:'include'}); + if (resp.ok){ + var json = await resp.json(); + if (json.authorization_endpoint) { + var endpoint = json.authorization_endpoint; + delete json.authorization_endpoint; + location.href = endpoint + '?' + new URLSearchParams(json); + } + } + }