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
|
|
@ -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
|
|
||||||
|
|
@ -23,9 +23,7 @@ jobs:
|
||||||
- name: 👁️ Checkout repository
|
- name: 👁️ Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: 📦 pnpm install
|
- name: 📦 pnpm install
|
||||||
run: |
|
run: pnpm install
|
||||||
pnpm install
|
|
||||||
cp .env.test .env
|
|
||||||
- name: 🧐 lint
|
- name: 🧐 lint
|
||||||
run: |
|
run: |
|
||||||
npm run check
|
npm run check
|
||||||
|
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -4,5 +4,7 @@ node_modules
|
||||||
/.svelte-kit
|
/.svelte-kit
|
||||||
/package
|
/package
|
||||||
.env
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
vite.config.js.timestamp-*
|
vite.config.js.timestamp-*
|
||||||
vite.config.ts.timestamp-*
|
vite.config.ts.timestamp-*
|
||||||
|
|
|
||||||
11
CHANGELOG.md
11
CHANGELOG.md
|
|
@ -3,17 +3,6 @@
|
||||||
All notable changes to this project will be documented in this file.
|
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
|
## [v0.3.0](https://code.thetadev.de/HSA/Visitenbuch/compare/v0.2.1..v0.3.0) - 2024-05-12
|
||||||
|
|
||||||
### 🚀 Features
|
### 🚀 Features
|
||||||
|
|
|
||||||
|
|
@ -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
|
DATABASE_URL=postgresql://postgres:1234@localhost:5432/visitenbuch?schema=public
|
||||||
|
|
||||||
AUTH_SECRET=ptfg+yUj3mQfdPh+5d1ooIkiB7KLO6J2q3jiBhILzE/eabiL # generate with openssl rand -base64 36
|
AUTH_SECRET=ptfg+yUj3mQfdPh+5d1ooIkiB7KLO6J2q3jiBhILzE/eabiL # generate with openssl rand -base64 36
|
||||||
KEYCLOAK_CLIENT_ID=visitenbuch
|
KEYCLOAK_CLIENT_ID=visitenbuch
|
||||||
KEYCLOAK_CLIENT_SECRET=supersecret
|
KEYCLOAK_CLIENT_SECRET=supersecret
|
||||||
KEYCLOAK_ISSUER=http://localhost:9090
|
KEYCLOAK_ISSUER=https://example.com/realms/master
|
||||||
KEYCLOAK_LOGOUT=http://localhost:9090/session/end
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "visitenbuch",
|
"name": "visitenbuch",
|
||||||
"version": "0.3.1",
|
"version": "0.3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
|
|
@ -13,15 +13,3 @@ services:
|
||||||
POSTGRES_PASSWORD: "1234"
|
POSTGRES_PASSWORD: "1234"
|
||||||
volumes:
|
volumes:
|
||||||
- ./postgres:/var/lib/postgresql/data
|
- ./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
|
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,7 @@ export async function makeAuthjsRequest(
|
||||||
event: RequestEvent,
|
event: RequestEvent,
|
||||||
authjsEndpoint: string,
|
authjsEndpoint: string,
|
||||||
params: Record<string, string>,
|
params: Record<string, string>,
|
||||||
noRedirect = false,
|
): Promise<never> {
|
||||||
): Promise<void> {
|
|
||||||
const headers = new Headers(event.request.headers);
|
const headers = new Headers(event.request.headers);
|
||||||
headers.set("Content-Type", "application/x-www-form-urlencoded");
|
headers.set("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
|
||||||
|
|
@ -86,7 +85,7 @@ export async function makeAuthjsRequest(
|
||||||
for (const c of res?.cookies ?? []) {
|
for (const c of res?.cookies ?? []) {
|
||||||
event.cookies.set(c.name, c.value, { path: "/", ...c.options });
|
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> {
|
export async function auth(event: RequestEvent): Promise<Session | null> {
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,13 @@
|
||||||
import type { Actions } from "./$types";
|
import type { Actions } from "./$types";
|
||||||
|
|
||||||
import { redirect } from "@sveltejs/kit";
|
|
||||||
|
|
||||||
import { baseUrl } from "$lib/shared/util";
|
import { baseUrl } from "$lib/shared/util";
|
||||||
|
|
||||||
import { env } from "$env/dynamic/private";
|
|
||||||
import { makeAuthjsRequest } from "$lib/server/auth";
|
import { makeAuthjsRequest } from "$lib/server/auth";
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
default: async (event) => {
|
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");
|
return makeAuthjsRequest(event, "signout", { callbackUrl });
|
||||||
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);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import { makeAuthjsRequest } from "$lib/server/auth";
|
||||||
*/
|
*/
|
||||||
const COOKIE_NAME = "autoLoginTs";
|
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);
|
const callbackUrl = event.url.searchParams.get("returnURL") ?? baseUrl(event.url);
|
||||||
|
|
||||||
return makeAuthjsRequest(event, "signin/keycloak", { callbackUrl });
|
return makeAuthjsRequest(event, "signin/keycloak", { callbackUrl });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue