
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
sveltekit-zitadel-oidc
Advanced tools
**`sveltekit-zitadel-oidc`** is a simple SvelteKit package that integrates **Zitadel** OpenID Connect (OIDC) for Single Page Applications (SPA). It leverages the `oidc-client-ts` library and provides easy-to-use functions to manage authentication, login,
sveltekit-zitadel-oidc
sveltekit-zitadel-oidc
is a simple SvelteKit package that integrates Zitadel OpenID Connect (OIDC) for Single Page Applications (SPA). It leverages the oidc-client-ts
library and provides easy-to-use functions to manage authentication, login, logout, and token refresh in your SvelteKit app.
Install the package via npm or yarn:
npm install sveltekit-zitadel-oidc
# or
yarn add sveltekit-zitadel-oidc
Before using the package, you need to configure your Zitadel project:
/auth/oidc/callback
) and silent renew (/auth/oidc/refresh
).Create a .env
file in the root of your project and add the following environment variables:
PUBLIC_URL=http://localhost:5173 # Your app's base URL
PUBLIC_OIDC_URL=http://id.loc # Zitadel issuer URL
PUBLIC_OIDC_CLIENT_ID=YOUR_CLIENT_ID # Zitadel Client ID
Create two routes in your SvelteKit project for handling login and silent token refresh:
src/routes/auth/oidc/callback/+page.svelte
:<script lang="ts">
import AuthCallback from "$lib/auth/oidc/AuthCallback.svelte";
</script>
<AuthCallback action="login" />
src/routes/auth/oidc/refresh/+page.svelte
:<script lang="ts">
import AuthCallback from "$lib/auth/oidc/AuthCallback.svelte";
</script>
<AuthCallback action="refresh"/>
In your layout file (src/routes/+layout.ts
), initialize the OIDC manager to restore user authentication after page reloads:
import { authorize } from '$lib/auth/oidc';
export async function load() {
await authorize();
return {};
}
Now you can use authentication-related functions (login
, logout
, etc.) throughout your app by importing them from sveltekit-zitadel-oidc
.
Example in your components:
<script lang="ts">
import { login, logout, isAuthenticated, user } from '$lib/auth/oidc';
// Svelte store subscription
let $isAuthenticated;
let $user;
$: {
$isAuthenticated = $isAuthenticated;
$user = $user;
}
function handleLogin() {
login(); // Redirects to Zitadel login page
}
function handleLogout() {
logout(); // Logs out the user
}
</script>
<button on:click={handleLogin} disabled={$isAuthenticated}>Login</button>
<button on:click={handleLogout} disabled={!$isAuthenticated}>Logout</button>
{#if $isAuthenticated}
<p>Welcome, {$user?.profile?.name}!</p>
{:else}
<p>Please log in.</p>
{/if}
authorize()
UserManager
and attempts to load the user from storage, restoring the session after a page refresh.await authorize();
login()
login();
logout()
logout();
getUser()
Promise
that resolves to the User
object or null
if no user is authenticated.const user = await getUser();
handleCallback()
handleCallback();
handleSilentCallback()
handleSilentCallback();
The package exports two Svelte writable stores to track authentication status:
isAuthenticated
Writable<boolean>
import { isAuthenticated } from '$lib/auth/oidc';
user
Writable<User | null>
import { user } from '$lib/auth/oidc';
src/
├── lib/
│ └── auth/
│ └── oidc/
│ ├── store.ts # Svelte stores for authentication state
│ ├── oidc.ts # Core OIDC functionality
│ └── AuthCallback.svelte # Handles callback logic for login and silent renew
├── routes/
│ └── auth/
│ └── oidc/
│ ├── callback/ # OIDC login callback route
│ └── refresh/ # OIDC silent renew callback route
This package is licensed under the MIT License.
FAQs
This project demonstrates how to integrate OIDC (OpenID Connect) authentication using Zitadel with a SvelteKit application. The integration leverages the `oidc-client-ts` library to handle authentication flows and manage user sessions.
The npm package sveltekit-zitadel-oidc receives a total of 2 weekly downloads. As such, sveltekit-zitadel-oidc popularity was classified as not popular.
We found that sveltekit-zitadel-oidc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.