workin on idc login flow

This commit is contained in:
2025-07-03 13:02:31 +02:00
parent 38081894ef
commit b9bff9733d
11 changed files with 234 additions and 97 deletions

View File

@@ -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);
}
}
}
</script>
<style>
@@ -47,6 +67,7 @@
</form>
<fieldset>
<legend>{t('login.OIDC_Login')}</legend>
<button>SRSoftware</button>
<button>ORC ID</button>
{#each services as service,i}
<button on:click={() => redirectTo(service)}>{service}</button>
{/each}
</fieldset>