0.0.17 • Published 6 years ago

@kammy-ui/auth-provider v0.0.17

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

AuthProvider

One-stop-shop for any 'auth-related' functions

yarn add @kammy-ui/auth-provider

React

This will initiate the auth class and give you access to it's functions on React Context.

import { AuthProvider } from '@kammy-ui/auth-provider';

//clientside
<AuthProvider cookieToken='my-token'>
...
</AuthProvider>

This will initiate the auth class and give you access to it's functions on Koa's ctx.

//serverside
<AuthProvider cookieToken='my-token' ctx={ctx}>
...
</AuthProvider>

Koa Auth Middleware

This middleware is to rendering of 'private routes' on the server.

It uses 'universal-cookie' to ensure a cookies on the client can be read by the server.

It put's an instance of the auth class on to Koa ctx object.

import authMiddleware from '@kammy-ui/koa-auth-middleware';

server.use(authMiddleware({ cookieToken: 'my-token' }));