Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
sk-oidc-oauth
Advanced tools
OIDC/OAuth2 authentication and authorization for prerendered/client-side-rendered SvelteKit apps.
⚠️ Under Construction!
OIDC/OAuth2 authentication and authorization for prerendered/client-side-rendered SvelteKit apps.
npm i -D sk-oidc-oauth
For full usage information, see the docs.
Authentication
provider in your root +layout.svelte
.<!-- src/routes/+layout.svelte -->
<script lang="ts">
import { Authentication, type UserManagerSettings } from 'sk-oidc-oauth';
const userManagerSettings: UserManagerSettings = {
authority: 'https://login.microsoftonline.com/tenant-id/v2.0',
client_id: '1234',
redirect_uri: 'http://localhost:5173/auth/callback/azure',
loadUserInfo: true,
};
</script>
<Authentication {userManagerSettings}>
<slot />
</Authentication>
redirect_uri
.<!--
src/routes/auth/callback/azure/+page.svelte
We just need the route to be defined, so this file can/should be empty.
-->
You're all set! You can use all of the library's components, functions, and stores anywhere inside the root layout.
Use the AuthorizationGuard
in a nested +layout.svelte
to protect all of the routes within:
<!-- src/routes/private/+layout.svelte -->
<script lang="ts">
import { AuthorizationGuard, isFullyAuthenticated } from 'sk-oidc-oauth';
$: yourCustomCondition = false;
</script>
<AuthorizationGuard
passCondition={$isAuthenticated && yourCustomCondition}
redirect="/auth/signin"
>
<slot />
</AuthorizationGuard>
<!-- src/lib/components/AuthButton/AuthButton.svelte -->
<script lang="ts">
import {
isFullyAuthenticated,
startSigninRedirect,
startSignoutRedirect,
} from 'sk-oidc-oauth';
</script>
{#if $isFullyAuthenticated}
<button type="button" on:click={startSignoutRedirect}>Sign out</button>
{:else}
<button type="button" on:click={startSigninRedirect}>Sign in</button>
{/if}
<!-- src/lib/components/User/User.svelte -->
<script lang="ts">
import { userInfo } from 'sk-oidc-oauth';
</script>
<ul>
<li>{$userInfo.profile.name}</li>
<li>Email: {$userInfo.profile.email}</li>
</ul>
Zach Scroggins
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
Give a ⭐️ if this project helped you!
Copyright © 2023 Zach Scroggins.
This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator
FAQs
OIDC/OAuth2 authentication and authorization for prerendered/client-side-rendered SvelteKit apps.
We found that sk-oidc-oauth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.