@functionalcms/svelte-components 2.36.0 → 2.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,6 @@ const createUserSession = async (provider, event, sessionProvider) => {
28
28
  headers.append('Location', retrunToAddress != '' ? retrunToAddress : provider.redirectPath);
29
29
  headers.append('Set-Cookie', `${authSessionCookieName}=${sessionId}; HttpOnly; Secure; SameSite=Lax; Max-Age=${token.expires_in + 120}; Path=/`);
30
30
  headers.append('Set-Cookie', `retrunToAddress=; HttpOnly; Secure; SameSite=Lax; Max-Age=${token.expires_in + 120}; Path=/`);
31
- // `${authSessionCookieName}=${sessionId}; HttpOnly; Secure; SameSite=Lax; Max-Age=${token.expires_in}; Path=/`);
32
31
  }
33
32
  else {
34
33
  headers.append('Location', '/');
@@ -1,3 +1,3 @@
1
1
  import { type Handle } from '@sveltejs/kit';
2
- declare const authorizationHandle: (protectedPaths: Array<string>) => Handle;
2
+ declare const authorizationHandle: () => Handle;
3
3
  export default authorizationHandle;
@@ -1,22 +1,21 @@
1
1
  import { redirect } from '@sveltejs/kit';
2
- const authorizationHandle = (protectedPaths) => {
2
+ const authorizationHandle = () => {
3
3
  return async ({ event, resolve }) => {
4
4
  const path = event.url.pathname;
5
5
  if (path.startsWith('/auth/') === false) {
6
- for (let protectedPath of protectedPaths) {
7
- if (path.match(protectedPath)) {
8
- const session = event?.locals?.session;
9
- if (!session) {
10
- const cookieHeader = `retrunToAddress=${event.url.toString()}; HttpOnly; Secure; SameSite=Lax; Max-Age=3600; Path=/`;
11
- return new Response('Login user', {
12
- status: 303,
13
- headers: {
14
- location: '/auth/validate',
15
- 'set-cookie': cookieHeader,
16
- referrer: event.url.toString()
17
- }
18
- });
19
- }
6
+ const route = event.route;
7
+ if (route.id.includes('/(protect)/')) {
8
+ const session = event?.locals?.session;
9
+ if (!session) {
10
+ const cookieHeader = `retrunToAddress=${event.url.toString()}; HttpOnly; Secure; SameSite=Lax; Max-Age=3600; Path=/`;
11
+ return new Response('Login user', {
12
+ status: 303,
13
+ headers: {
14
+ location: '/auth/login',
15
+ 'set-cookie': cookieHeader,
16
+ referrer: event.url.toString()
17
+ }
18
+ });
20
19
  }
21
20
  }
22
21
  }
@@ -1,8 +1,5 @@
1
1
  import { AUTH_KEYCLOAK_ID, AUTH_KEYCLOAK_SECRET, AUTH_KEYCLOAK_ISSUER } from '$env/static/private';
2
- const authStateCookieName = 'auth_state';
3
- const stateIdGenerator = () => crypto.randomUUID();
4
2
  const getKeycloakIdentity = async (issuer, client_id, scope, redirectUrl) => {
5
- const state = stateIdGenerator();
6
3
  const headers = new Headers();
7
4
  headers.append('Location', '/auth/validate');
8
5
  return headers;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "2.36.0",
3
+ "version": "2.36.1",
4
4
  "watch": {
5
5
  "build": {
6
6
  "patterns": [