1.0.0-beta.9 • Published 2 years ago

@jerrythomas/sentry v1.0.0-beta.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Sentry

Drop in authentication including route protection and redirects for SvelteKit apps.

sentry

Why?

Adding authentication to front end is one of the most time consuming tasks. Building apps in Svelte is great but there is no standard way to implement authentication. There are multiple libraries that allow us to add authentication for multiple providers. However, switching from one to another is not easy. The UI components for all the providers also need to meet the provider guidelines for the final app to be approved.

This is an attempt to make adding authentication to SvelteKit apps as simple as possible. This framework has been designed for Svelte.

Features

  • Configuration driven
  • Secrets using environment variables
  • Emulator tests where available
  • Route protection
    • Public pages
    • Protected routes
    • Role based protection for route
    • Caching blocked routes to be redirected on login
  • Different auth libraries
    • Firebase
    • Auth0
    • Supabase
    • Amplify
  • Multiple providers
    • Google
    • Password
    • Github
    • Microsoft
    • Twitter
    • Facebook

Getting started

Get started quickly using degit. Select the library you want to use and run degit to get a sample app.

degit jerrythomas/sentry/examples/firebase my-app

Take a look at the following files in the sample to understand how it works.

  • config.js
  • hooks.js
  • __layout.svelte
  • login.svelte
  • logout.svelte

Tailwind

This library uses tailwind and the components will not render properly if the tailwind does not include the requires css classes. Ensure that the sentry library is included in the purge array of tailwind.config.cjs

purge: [
    './src/**/*.{html,js,svelte,ts}',
    'node_modules/@jerrythomas/sentry/src/**/*.{html,js,svelte,ts,css}}',
  ],

Route Configuration

Routes are configurable as shown in the example config.js file. Sentry assumes that all routes are private by default. Public routes need to be listed so that they can be accessed without logging in.

There are three attributes in the routes configuration.

  • home: Landing page after logging in.
  • start: Start page to be used as welcome/login page
  • public: A list of routes to be treated as public. All child routes are assumed to be public too.

Components

This library consists of the following components.

  • UI component with buttons for different OAuth providers
  • Utility functions for various stages of auth lifecycle
  • Store for managing the user session
  • Cookie to allow server to identify authentication

License

MIT © Jerry Thomas

1.0.0-beta.28

2 years ago

1.0.0-beta.27

2 years ago

1.0.0-beta.26

2 years ago

1.0.0-beta.22

2 years ago

1.0.0-beta.23

2 years ago

1.0.0-beta.21

2 years ago

1.0.0-beta.24

2 years ago

1.0.0-beta.25

2 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0-beta.20

2 years ago

1.0.0-beta.11

2 years ago

1.0.0-beta.12

2 years ago

1.0.0-beta.10

2 years ago

1.0.0-beta.9

2 years ago

1.0.0-beta.19

2 years ago

1.0.0-beta.17

2 years ago

1.0.0-beta.18

2 years ago

1.0.0-beta.15

2 years ago

1.0.0-beta.16

2 years ago

1.0.0-beta.13

2 years ago

1.0.0-beta.14

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

0.1.0-beta.8

3 years ago

0.1.0-beta.3

3 years ago

0.1.0-beta.2

3 years ago

0.1.0-beta.5

3 years ago

0.1.0-beta.4

3 years ago

0.1.0-beta.7

3 years ago

0.1.0-beta.6

3 years ago