Compare commits

..

No commits in common. "v0.3.1" and "v0.3.0" have entirely different histories.

10 changed files with 10 additions and 54 deletions

View file

@ -1,8 +0,0 @@
# Environment variables for E2E testing
DATABASE_URL=postgresql://postgres:1234@localhost:5432/test?schema=public
AUTH_SECRET=ptfg+yUj3mQfdPh+5d1ooIkiB7KLO6J2q3jiBhILzE/eabiL # generate with openssl rand -base64 36
KEYCLOAK_CLIENT_ID=visitenbuch
KEYCLOAK_CLIENT_SECRET=supersecret
KEYCLOAK_ISSUER=http://localhost:9090
KEYCLOAK_LOGOUT=http://localhost:9090/session/end

View file

@ -23,9 +23,7 @@ jobs:
- name: 👁️ Checkout repository
uses: actions/checkout@v4
- name: 📦 pnpm install
run: |
pnpm install
cp .env.test .env
run: pnpm install
- name: 🧐 lint
run: |
npm run check

2
.gitignore vendored
View file

@ -4,5 +4,7 @@ node_modules
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

View file

@ -3,17 +3,6 @@
All notable changes to this project will be documented in this file.
## [v0.3.1](https://code.thetadev.de/HSA/Visitenbuch/compare/v0.3.0..v0.3.1) - 2024-05-13
### 🚀 Features
- Logout user from OIDC provider - ([8316d40](https://code.thetadev.de/HSA/Visitenbuch/commit/8316d4078c1ccaf40e9d026c559be2d0c03f92fb))
### 🧪 Testing
- Fix environment files - ([f01fb6f](https://code.thetadev.de/HSA/Visitenbuch/commit/f01fb6f191cf6978252b89656b09144d7fc1cde6))
## [v0.3.0](https://code.thetadev.de/HSA/Visitenbuch/compare/v0.2.1..v0.3.0) - 2024-05-12
### 🚀 Features

View file

@ -1,9 +1,6 @@
# Environment variables to configure the application
# Copy this file to .env and edit the configuration if necessary
DATABASE_URL=postgresql://postgres:1234@localhost:5432/visitenbuch?schema=public
AUTH_SECRET=ptfg+yUj3mQfdPh+5d1ooIkiB7KLO6J2q3jiBhILzE/eabiL # generate with openssl rand -base64 36
KEYCLOAK_CLIENT_ID=visitenbuch
KEYCLOAK_CLIENT_SECRET=supersecret
KEYCLOAK_ISSUER=http://localhost:9090
KEYCLOAK_LOGOUT=http://localhost:9090/session/end
KEYCLOAK_ISSUER=https://example.com/realms/master

View file

@ -1,6 +1,6 @@
{
"name": "visitenbuch",
"version": "0.3.1",
"version": "0.3.0",
"private": true,
"license": "AGPL-3.0",
"scripts": {

View file

@ -13,15 +13,3 @@ services:
POSTGRES_PASSWORD: "1234"
volumes:
- ./postgres:/var/lib/postgresql/data
oidc:
image: thetadev256/oidc-mock-server
restart: unless-stopped
ports:
- 9090:3000
environment:
CLIENT_ID: visitenbuch
CLIENT_SECRET: supersecret
CLIENT_REDIRECT_URIS: http://localhost:5173/auth/callback/keycloak;http://localhost:4173/auth/callback/keycloak
CLIENT_LOGOUT_REDIRECT_URIS: http://localhost:5173/login?noAuto=1;http://localhost:4173/login?noAuto=1
ISSUER_HOST: localhost:9090

View file

@ -71,8 +71,7 @@ export async function makeAuthjsRequest(
event: RequestEvent,
authjsEndpoint: string,
params: Record<string, string>,
noRedirect = false,
): Promise<void> {
): Promise<never> {
const headers = new Headers(event.request.headers);
headers.set("Content-Type", "application/x-www-form-urlencoded");
@ -86,7 +85,7 @@ export async function makeAuthjsRequest(
for (const c of res?.cookies ?? []) {
event.cookies.set(c.name, c.value, { path: "/", ...c.options });
}
if (!noRedirect) return redirect(302, res.redirect ?? "");
return redirect(302, res.redirect ?? "");
}
export async function auth(event: RequestEvent): Promise<Session | null> {

View file

@ -1,22 +1,13 @@
import type { Actions } from "./$types";
import { redirect } from "@sveltejs/kit";
import { baseUrl } from "$lib/shared/util";
import { env } from "$env/dynamic/private";
import { makeAuthjsRequest } from "$lib/server/auth";
export const actions: Actions = {
default: async (event) => {
let callbackUrl = `${baseUrl(event.url)}/login?noAuto=1`;
const callbackUrl = `${baseUrl(event.url)}/login?noAuto=1`;
const cburl = new URL(env.KEYCLOAK_LOGOUT ?? env.KEYCLOAK_ISSUER + "/protocol/openid-connect/logout");
cburl.searchParams.append("post_logout_redirect_uri", callbackUrl);
cburl.searchParams.append("client_id", env.KEYCLOAK_CLIENT_ID);
callbackUrl = cburl.toString();
await makeAuthjsRequest(event, "signout", { }, true);
return redirect(302, callbackUrl);
return makeAuthjsRequest(event, "signout", { callbackUrl });
},
};

View file

@ -10,7 +10,7 @@ import { makeAuthjsRequest } from "$lib/server/auth";
*/
const COOKIE_NAME = "autoLoginTs";
async function doLogin(event: RequestEvent): Promise<void> {
async function doLogin(event: RequestEvent): Promise<never> {
const callbackUrl = event.url.searchParams.get("returnURL") ?? baseUrl(event.url);
return makeAuthjsRequest(event, "signin/keycloak", { callbackUrl });