All Projects → subhendukundu → worker-auth-providers

subhendukundu / worker-auth-providers

Licence: other
worker-auth-providers is an open-source providers to make authentication easy with workers. Very lightweight script which doesn't need a lot of dependencies. Plug it with any framework or template of workers.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to worker-auth-providers

Simpleauth
A easy to use social authentication android library. (Facebook, Google, Twitter, Instagram)
Stars: ✭ 216 (+154.12%)
Mutual labels:  auth, facebook-login, google-login
angular5-social-login
Social authentication module for Angular 5. Includes Facebook and Google login with AOT compatibility.
Stars: ✭ 40 (-52.94%)
Mutual labels:  facebook-login, google-login
inkrss
Notify when rss feeds are updated | RSS 更新通知
Stars: ✭ 234 (+175.29%)
Mutual labels:  cloudflare, cloudflare-workers
cfw-easy-utils
An in-depth library to assist with common tasks with CF Workers. Includes utils for responses, cookies, and more!
Stars: ✭ 52 (-38.82%)
Mutual labels:  cloudflare, cloudflare-workers
workers-graphql-gateway-example
GraphQL running on Cloudflare Workers
Stars: ✭ 68 (-20%)
Mutual labels:  cloudflare, cloudflare-workers
faaskit
A lightweight middleware framework for functions as a service
Stars: ✭ 24 (-71.76%)
Mutual labels:  cloudflare, cloudflare-workers
cloudflare-worker-router
A super lightweight router (1.3K) with middleware support and ZERO dependencies for CloudFlare Workers.
Stars: ✭ 144 (+69.41%)
Mutual labels:  cloudflare, cloudflare-workers
workers-unsplash-api
Serverless API for requesting images from Unsplash's API, designed for use with a React frontend
Stars: ✭ 20 (-76.47%)
Mutual labels:  cloudflare, cloudflare-workers
Bon Voyage
A Hotel booking Android application. This app consists of a Google, Facebook and email login. Firebase is used as the database. The user can select the destination, select the hotel, and book the rooms there. After the booking process is complete, a confirmation email is sent to the user.
Stars: ✭ 19 (-77.65%)
Mutual labels:  facebook-login, google-login
social-auth-kivy
Integrate Google, Facebook, Github & Twitter login in kivy applications
Stars: ✭ 133 (+56.47%)
Mutual labels:  facebook-login, google-login
cloudflare-worker-graphql-ws-template
A template for WebSockets powered Cloudflare Worker project using graphql-ws
Stars: ✭ 21 (-75.29%)
Mutual labels:  cloudflare, cloudflare-workers
slshx
⚔️ Strongly-typed Discord commands on Cloudflare Workers
Stars: ✭ 163 (+91.76%)
Mutual labels:  cloudflare, cloudflare-workers
cfworker-middware-telegraf
Make telegraf (a telegram bot framework) useable in Cloudflare Workers
Stars: ✭ 23 (-72.94%)
Mutual labels:  cloudflare, cloudflare-workers
Graphql Starter
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, and Material UI.
Stars: ✭ 3,377 (+3872.94%)
Mutual labels:  cloudflare, cloudflare-workers
wrangler2
🤠 wrangle your Cloudflare Workers
Stars: ✭ 349 (+310.59%)
Mutual labels:  cloudflare, cloudflare-workers
supaflare
URL shortener / redirection service powered by Supabase, Cloudflare Workers, Workers KV and Cloudflare Pages.
Stars: ✭ 51 (-40%)
Mutual labels:  cloudflare, cloudflare-workers
telegram-bot-api-worker
Take an alternate route to Telegram Bot API :)
Stars: ✭ 75 (-11.76%)
Mutual labels:  cloudflare, cloudflare-workers
relay-starter-kit
💥 Monorepo template (seed project) pre-configured with GraphQL API, PostgreSQL, React, Relay, Material UI.
Stars: ✭ 3,513 (+4032.94%)
Mutual labels:  cloudflare, cloudflare-workers
DNS-over-Discord
A 1.1.1.1 DNS resolver built for Discord
Stars: ✭ 228 (+168.24%)
Mutual labels:  cloudflare, cloudflare-workers
IPFS PHOTO SHARE
💰用甚嚒服务器,ServerLess搭建一个图片分享站点!| 基于CloudFlareWorker无服务器函数和IPFS去中心化存储的图片分享网站
Stars: ✭ 76 (-10.59%)
Mutual labels:  cloudflare, cloudflare-workers

worker-auth-providers

worker-auth-providers

An open-source auth providers for Cloudflare workers

Repo Size Issues Pull Requests Last Commit

worker-auth-providers is an open-source providers to make authentication easy with workers. Very lightweight script which doesn't need a lot of dependencies. Plug it with any framework or template of workers.

🚀 Demo

Try now

🧐 Features

  • Open Source
  • Fast & Lightweight
  • Easy

🛠️ Installation

Step 1: Install the dependencies

npm install worker-auth-providers

Step 2: Import the dependencies

import {
  github, google, awsSNS,
  twilio, facebook, discord,
  spotify
} from "worker-auth-providers";

Step 3: Redirect users

const githubLoginUrl = await github.redirect({
    options: {
        clientId,
    },
});
return {
    status: 302,
    headers: {
        location: githubLoginUrl,
    },
};

// or send otp

const res = await awsSNS.send({
  options: {
    phone,
    region: 'ap-south-1',
    kvProvider: WORKER_AUTH_PROVIDERS_STORE,
  },
})

Step 4: Get user

const { user: providerUser, tokens } = await github.users({
    options: { clientSecret, clientId },
    request,
});
console.log("[providerUser]", providerUser);

// or verify otp
const res = await awsSNS.verify({
  options: {
    phone,
    otp,
    kvProvider: WORKER_AUTH_PROVIDERS_STORE,
    secret: 'eyJhbGciOiJIUzI1NiJ9.ew0KICAic3ViIjogIjE2Mjc4MTE1MDEiLA0KICAibmFtZSI6ICJoYWFsLmluIiwNCiAgImlhdCI6ICIwMTA4MjAyMCINCn0.aNr18szvBz3Db3HAsJ-2KHYbnnHwHfK65CiZ_AWwpc0',
  },
})

📃 Documentation

Coming soon

👩‍💻 Tech

🍰 Contributing

Contributions are always welcome! See contributing.md for ways to get started. Please adhere to this project's code of conduct.

Roadmap

  • Docs.
  • Google.
  • Github
  • OTP AWS SNS
  • OTP Twilio
  • Mailgun Email
  • Sendgrid Email
  • Facebook
  • Discord
  • Instagram
  • Amazon
  • Twitter
  • Spotify
  • Auth0

##FAQs

How to persist login?

Use cookie. Setting a cookie to indicate that they’re authorized for future requests

const cookieKey = "worker-auth-providers"
const persistAuth = async exchange => {
    const date = new Date()  date.setDate(date.getDate() + 1)
    const headers = { 
      Location: "/",
      "Set-cookie": `${cookieKey}=${id}; Secure; HttpOnly; SameSite=Lax; Expires=${date.toUTCString()}`,
    }
    return { headers, status: 302 }
}

How to logout?

Easy, delete the cookie

export const logout = event => {
  const cookieHeader = event.request.headers.get('Cookie')
  if (cookieHeader && cookieHeader.includes(cookieKey)) {
    return {
      headers: {
        'Set-cookie': `${cookieKey}=""; HttpOnly; Secure; SameSite=Lax;`,
      },
    }
  }
  return {}
}

Feedback

If you have any feedback, please reach out to me at [email protected]

✍️ Authors

💼 License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].